hmvictor / radar-netbeans

A SonarQube plugin for Netbeans
Other
33 stars 22 forks source link

"Get Issues with Sonar Runner" returns All Issues instead of New Issues #46

Open Icedmang opened 8 years ago

Icedmang commented 8 years ago

radar-netbeans Version 1454562877_radar-netbeans-2.5 SonarQube Server Version 5.4 (This may be the reason as it states support for Version 5.3)

Netbeans Product Version: NetBeans IDE 8.1 (Build 201510222201) Updates: NetBeans IDE is updated to version NetBeans 8.1 Patch 1 Java: 1.8.0_91; Java HotSpot(TM) 64-Bit Server VM 25.91-b14 Runtime: Java(TM) SE Runtime Environment 1.8.0_91-b14

Configuration Under Tools | Options -> Miscellaneous, Select SonarQube tab and choose "Analysis Mode for Runner" as "Preview".

I believe only the following Analysis Modes are available: Publish, Preview, Issues (Incremental is no longer supported) as mentioned in http://docs.sonarqube.org/display/SONAR/Analyzing+Source+Code

Preview mode performs a full analysis on the entire code base and does not send the results to the database. Typically this mode is used when you want a quick feedback about the issues that you might have introduced before pushing your modifications to the main code base. See all the possibilities in the "Pre-commit Check" documentation.

On unchanged code from a repository, I would expect to see 0 issues listed but instead see all of them as currently reported in the SonarQube dashboard

Running an analysis from the command-line using Maven seems to result in the expected result:

C:\Temp>mvn sonar:sonar -Dsonar.host.url=http://sonar -Dsonar.analysis.mode=preview -Dsonar.issuesReport.console.enable=true -Dsonar.login
=**** -Dsonar.password=****
...
[INFO]

-------------  Issues Report  -------------

  No new issue

-------------------------------------------

[INFO] ANALYSIS SUCCESSFUL
...
Icedmang commented 8 years ago

I took a look at the code and it looks like SonarRunnerResult should be taking into account the isNew field on each issue if it's Preview mode. I had to make a number of upstream changes to use SonarRunnerIssue instead of Issue to account for this information. Currently, I have modifications to a local copy of the code that filters issues on this field as that's all the information I'm interested in within Netbeans.

Icedmang commented 8 years ago

A general comment, if you plan to support multiple versions of SonarQube, can I suggest you make a decision on what you want to support whether it's the latest SonarQube or remain backwards compatible for everything. Trying to be backwards compatible with one version is going to get ugly. If you want to be backwards compatible, perhaps it's time to consider different releases

Git-GT commented 8 years ago

Hi, I have the same issue, using the local analysis I would like to see only the new issue introduced by me. I tried to create a sonar-project.properties file in the project root with the parameter sonar.timemachine.period1=previous_analysis But it seems that the plugin doesn't care about this file. Is there some workaround to have this kind of analysis? Where is the properties file used by the radar plugin to perform the local analysis located?

hmvictor commented 8 years ago

Hi, @Gittino The plugin does not use a properties file. At this very moment, all the information is calculated from the Netbeans Project API and passed directly to sonar runner.

Icedmang commented 7 years ago

Hi @hmvictor, I tried version 3.0.1 and the issue still exists. Does closing mean this won't be fixed?

hmvictor commented 7 years ago

I'm closing old issues and keeping the new or more relevants open to focus the development. If this stills an issue, I can reopen but since I think there are two threads in this one maybe is better to create new issues. And because there were some API changes in SonarQube in the last versions is better to see what applies now.

Icedmang commented 7 years ago

@hmvictor 2 Issues meaning: 1) Get issues with Sonar Runner returning all issues. and 2) The use of properties file?

hmvictor commented 7 years ago

@Icedmang

Yes, exactly.