Discussion:
false-positive in sf_switch_no_default
Zahra Karimi
2014-07-24 09:58:34 UTC
Permalink
 
I found a false-positive in sf_switch_no_default  :

if (actualTrials <= 4) { switch (actualTrials) { case 1: trials1Count = trials1Count +1; break; case 2: trials2Count = trials2Count +1; break; case 3: trials3Count = trials3Count +1; break; case 4: trials4Count = trials4Count +1; break; } } else { trials5OrMoreCount = trials5OrMoreCount +1; } 


 Definitely, actualtrials is less than 5 and, therefore default is not needed.

Best regards,
Zahra
sebb
2014-07-24 10:51:16 UTC
Permalink
if (actualTrials <= 4) { switch (actualTrials) { case 1: trials1Count =
trials1Count +1; break; case 2: trials2Count = trials2Count +1; break; case
3: trials3Count = trials3Count +1; break; case 4: trials4Count =
trials4Count +1; break; } } else { trials5OrMoreCount = trials5OrMoreCount
+1; }
Definitely, actualtrials is less than 5 and, therefore default is not
needed.
What about case 0? Also -1?
e.t.c.
Best regards,
Zahra
_______________________________________________
Findbugs-discuss mailing list
https://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss
Loading...