Note that there are some explanatory texts on larger screens.

plurals
  1. POFindbugs and comparing
    primarykey
    data
    text
    <p>I recently started using the findbugs static analysis tool in a java build I was doing. The first report came back with loads of High Priority warnings. Being the obsessive type of person, I was ready to go knock them all out. However, I must be missing something. I get most of the warnings when comparing things. Such as the following code:</p> <pre><code> public void setSpacesPerLevel(int value) { if( value &gt;= 0) { spacesPerLevel = value; } else { spacesPerLevel = 0; } } </code></pre> <p>produces a high priority warning at the if statement that reads.</p> <blockquote> <p>File: Indenter.java, Line: 60, Type: BIT_AND_ZZ, Priority: High, Category: CORRECTNESS Check to see if ((...) &amp; 0) == 0 in sample.Indenter.setSpacesPerLevel(int)</p> </blockquote> <p>I am comparing an int to an int, seems like a common thing. I get quite a few of that type of error with similar simple comparisons.</p> <p>I have alot of other high priority warnings on what appears to be simple code blocks. Am I missing something here? I realize that static analysis can produce false positives, but the errors I am seeing seem too trivial of a case to be a false positive.</p> <p>This one has me scratching my head as well.</p> <pre><code> for(int spaces = 0;spaces &lt; spacesPerLevel;spaces++) { result = result.concat(" "); } </code></pre> <p>Which gives the following findbugs warning:</p> <pre><code>File: Indenter.java, Line: 160, Type: IL_INFINITE_LOOP, Priority: High, Category: CORRECTNESS There is an apparent infinite loop in sample.Indenter.indent() This loop doesn't seem to have a way to terminate (other than by perhaps throwing an exception). </code></pre> <p>Any ideas?</p> <p>So basically I have a handful of files and 50-60 high priority warnings similar to the ones above. I am using findbugs 1.3.9 and calling it from the findbugs ant task</p> <p><strong>UPDATE:</strong> I have this build being executed by a hudson server and had the code being instrumented by Clover for code coverage. When I turned that off, all of my high priority warnings disappeared. That makes sense now. Thanks for the feedback.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload