Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring Spotbugs ReportLevel #15

Closed
dovogt opened this issue Mar 28, 2019 · 7 comments
Closed

Configuring Spotbugs ReportLevel #15

dovogt opened this issue Mar 28, 2019 · 7 comments

Comments

@dovogt
Copy link

dovogt commented Mar 28, 2019

Can I use the plugin to specify the reportlevel at which the messages are displayed and what is the default reportlevel like?

thx

@xvik
Copy link
Owner

xvik commented Mar 29, 2019

Yes, you can configure it

effort - The analysis effort level. The value specified should be one of min, default, or max. Higher levels increase precision and find more bugs at the expense of running time and memory consumption.

reportLevel - The priority threshold for reporting bugs. If set to low, all bugs are reported. If set to medium (the default), medium and high priority bugs are reported. If set to high, only high priority bugs are reported.

Quotes from gradle docs (for findbugs plugin, but it's the same for spotbugs)

Default values are

quality {
    spotbugsEffort = 'max' 
    spotbugsLevel = 'medium'
}

@dovogt
Copy link
Author

dovogt commented Mar 29, 2019

I used the two switches. Besides Gradle we also use the EclipsePlugin. There is another setting in Eclipse, which causes the results to differ between Gradle and Eclipse.

image

@xvik
Copy link
Owner

xvik commented Mar 29, 2019

Spotbugs plugin did not allow to filter by ranks directly, but it is possible through filters.
Quality plugin automatically apply only exclude filter, but you'll need include filter, so you'll have to configure it manually:

afterEvaluate {
     spotbugs.includeFilter = file("${quality.configDir}/spotbugs/includeFilter.xml")
}

includeFilter.xml:

<FindBugsFilter>
     <Match>
         <Rank value="15"/>
     </Match>
</FindBugsFilter>

After that only 15-20 ranks should be reported. I did not test it myself, just used this source

Generally support for this should be added directly to plugin:

  1. add inclusion filter file support
  2. add spotbugsMinRank=12 (probably)

@dovogt
Copy link
Author

dovogt commented Apr 1, 2019

Thank you so much for your trouble. I'll give it a try.

@xvik xvik closed this as completed in 257af6b Nov 6, 2019
@xvik
Copy link
Owner

xvik commented Nov 6, 2019

I was wrong, rank rule must be applied in exclusions filter, not in inclusion filter (or it should be inverted in inclusion filter).

New version will provide special setting for rank filtering:

quality{
    spotbugsMaxRank = 15
}

(means violations with ranks 16-20 will be filtered)

Also, ranks are shown now in console report:

[Performance | URF_UNREAD_FIELD] sample.(Sample.java:11)  [priority 2 / rank 18]
	>> Unread field: sample.Sample.sample
  This field is never read. Consider removing it from the class.

@dovogt
Copy link
Author

dovogt commented Nov 6, 2019

Thank you. Can you tell when the new version will be released?

@xvik
Copy link
Owner

xvik commented Nov 6, 2019

Ideally, just after pmd 6.20 release. There is a bug with very confusing warning.

But, maybe, I'll simply downgrade to 6.18 and release.. not sure now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants