findbugs

Is there any Checkstyle/PMD/Findbugs rule to force “else if” to be on the same line?

为君一笑 提交于 2019-12-05 10:04:24
In our project for chained if/else/if we would like to have following formatting: if (flag1) { // Do something 1 } else if (flag2) { // Do something 2 } else if (flag3) { // Do something 3 } And forbid following one: if (flag1) { // Do something 1 } else { if (flag2) { // Do something 2 } else { if (flag3) { // Do something 3 } } } Is there some predefined rule in either of listed above static code analysis tools to force this code style? If no - I know there is an ability to write custom rules in all of those tools, which one would you suggest to implement such a rule (not really familiar

Best practice for updating/writing to static variable?

怎甘沉沦 提交于 2019-12-05 08:52:16
I have a project which displays department documentation. I store all the docs (get from database) in a static arrayList. Every X hour, I have that arrayList rebuilt based on the new doc (if any) from the database. There is also a static variable to control to rebuild that array or not, set and unset in a method which does the rebuild task. Each web browser hit the server will create this class's instance, but the doc arrayList and that control variable is shared among all the class instances. Find-Bugs tool complains that "Write to static field someArrayName and someVariableName from instance

java compilation error using findbugs. com.sun.tools.javac.code.Symbol$CompletionFailure: class file for javax.annotation.meta.When not found

对着背影说爱祢 提交于 2019-12-05 07:15:34
I am trying to use the annotations of findbugs 1.3.2. I used the edu.umd.cs.findbugs.annotations.NonNull annotation in a simple test, and it works fine. However, now I have a large project, composed of sub-modules, using maven, and I get the following compilation error by just importing that annotation in some java file: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for javax.annotation.meta.When not found what can be the problem? i tried adding the findbugs dependency in all sub-modules. maybe it is a conflict with jsr305? I see that one of our dependencies uses jsr305 1.3.9.

What is the actual meaning of priority/confidence in findbugs ?

五迷三道 提交于 2019-12-05 05:47:07
When I use fingbugs-eclipse plugin or findbugs-ant plugin, there is a confidence option to be set. But according to findbugs document, bugs are given a rank 1-20, and grouped into the categories scariest (rank 1-4), scary (rank 5-9), troubling (rank 10-14), and of concern (rank 15-20). So what is the actual meaning of priority/confidence ? Does it have a relationship for Bug Rank? If so, how to understand? It not, why does findbug define a confidence for every bug ? A rule's confidence measures the likelihood that it has flagged a real bug. Simple rules that use evidence from a single

Using fb-contrib library with Gradle's FindBugs plugin

◇◆丶佛笑我妖孽 提交于 2019-12-05 05:30:21
Is it possible to integrate the fb-contrib library with Gradle's FindBugs plugin ? I've been looking around for a solution for a while but so far I haven't found anything... If it helps, here's the script I have right now. It's a work in progress but the report is generated correctly. apply plugin: "findbugs" task findbugs(type: FindBugs) { classes = fileTree(project.rootDir.absolutePath).include("**/*.class"); source = fileTree(project.rootDir.absolutePath).include("**/*.java"); classpath = files() findbugs { toolVersion = "2.0.3" ignoreFailures = true effort = "max" reportLevel = "low"

List of FindBugs 2.0 bugs by rank?

烂漫一生 提交于 2019-12-05 04:14:27
I know there is list of bugs, but I would like to have a list with additional information about rank (1 to 20 in version 2.0) or at least about ranking groups (Of concern, Troubling, Scary, Scariest). Maybe I'm missing something, but FindBugs forum does not seem to be active?! Perhaps http://code.google.com/p/findbugs/source/browse/trunk/findbugs/etc/bugrank.txt but I don't know if it is exhaustive ( FindBugs Bug Descriptions has more entries). 来源: https://stackoverflow.com/questions/9583953/list-of-findbugs-2-0-bugs-by-rank

How can I print reported bugs to console in gradle findbugs plugin?

此生再无相见时 提交于 2019-12-05 03:04:22
I am using Gradle FindBugs Plugin. How can I print reported bugs to console? PMD plugin has a consoleOutput property. Is there a similar property for FindBugs? Opal As you can see here there's no such property or configuration possibility for FindBugs plugin. However it seems that the plugin can be customized in some way. E.g. by parsing and displaying the results. See here and here . This is rudimentary ... but it's a start task checkFindBugsReport << { def xmlReport = findbugsMain.reports.xml if (!xmlReport.destination.exists()) return; def slurped = new XmlSlurper().parse(xmlReport

FIndbug not identifying null pointer exception

有些话、适合烂在心里 提交于 2019-12-05 02:28:06
问题 I am using Findbugs integerated with eclipse. When I run findbugs on my project the below code is not captured for possible null pointer exception. In the below snippet the object test is prone to null pointer exception which is not identified by findbugs. @Override public boolean saveIrr(TestObject test) throws DuplicateRecordException { boolean status = false try { test.getAddDate(); status = adhocMaintPopupMapper.saveIrr(IRRPopupMaint); } catch (DataIntegrityViolationException e) { logger

Gradle - how to exclude Findbugs on /src/test/java

≡放荡痞女 提交于 2019-12-05 02:21:58
Is there a way to exclude Findbugs execution on classes under /src/test/java. I tried the following but it doesn't seem to work. classes = classes.filter { !it.path.contains("**classes\\test\\org*") } Sure. The documentation of the Findbugs extension says: sourceSets : The source sets to be analyzed as part of the check and build tasks. And the example just above shows an example doing exactly what you want: apply plugin: "findbugs" findbugs { sourceSets = [sourceSets.main] } i.e. only analyze the main sourceSet, and not the test sourceSet. For Gradle 4.5.1 apply plugin: 'findbugs' findbugs {