[sonar-dev] SonarQube plugin: JAR archives in FileSystem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[sonar-dev] SonarQube plugin: JAR archives in FileSystem

krasnyt

I have a stand-alone external library which I want to use in my custom SQ plugin. The input of this library are two collections of JAR archives. So far I've specified paths to these archives in sonar-project.properties, e.g.:

myplugin.folder1.jars=target/jars1
myplugin.folder2.jars=target/jars2

The external library then runs analysis over these collections and returns a result which contains description of errors between those JAR archives. The error also says which class in which JAR archive contains the error. Now I'd like to add an issue over this class which will be displayed in SQ instance.

I know I can add new issues through Issuable interface:

Issuable issuable = perspectives.as(Issuable.class, inputFile);
IssueBuilder issueBuilder = issuable.newIssueBuilder()
     .ruleKey("rule_key")
     .message("message")
     .line(line_nr);
issuable.addIssue(issueBuilder.build());

Now I don't know how to get the 2nd parameter of as method called inputFile from FileSystem. I know the full name of the class (e.g.: mypackage.MyClass) which contains the error but this class is not in the FileSystem so I can not do something like

InputFile inputFile = fs.inputFile(fs.predicates().hasAbsolutePath("mypackage/MyClass.class"));

How can I "unzip" these JAR files and add classes to the FileSystem so they can be accessed later? Is this even a good approach? I've checked sources of java-squid, package org.sonar.java.bytecodebut I am pretty confused about it.

Thanks in advance.

Tomas

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] SonarQube plugin: JAR archives in FileSystem

Julien HENRY
Hi Tomas,

SonarQube is focusing on source code analysis (ie plain text files). It is fine to analyze .class (like Findbugs) but you should report your issue on the source file (for example src/main/java/mypackage/MyClass.java).

++

Julien

2015-05-13 21:00 GMT+02:00 Tomáš Krásný <[hidden email]>:

I have a stand-alone external library which I want to use in my custom SQ plugin. The input of this library are two collections of JAR archives. So far I've specified paths to these archives in sonar-project.properties, e.g.:

myplugin.folder1.jars=target/jars1
myplugin.folder2.jars=target/jars2

The external library then runs analysis over these collections and returns a result which contains description of errors between those JAR archives. The error also says which class in which JAR archive contains the error. Now I'd like to add an issue over this class which will be displayed in SQ instance.

I know I can add new issues through Issuable interface:

Issuable issuable = perspectives.as(Issuable.class, inputFile);
IssueBuilder issueBuilder = issuable.newIssueBuilder()
     .ruleKey("rule_key")
     .message("message")
     .line(line_nr);
issuable.addIssue(issueBuilder.build());

Now I don't know how to get the 2nd parameter of as method called inputFile from FileSystem. I know the full name of the class (e.g.: mypackage.MyClass) which contains the error but this class is not in the FileSystem so I can not do something like

InputFile inputFile = fs.inputFile(fs.predicates().hasAbsolutePath("mypackage/MyClass.class"));

How can I "unzip" these JAR files and add classes to the FileSystem so they can be accessed later? Is this even a good approach? I've checked sources of java-squid, package org.sonar.java.bytecodebut I am pretty confused about it.

Thanks in advance.

Tomas


Loading...