summaryrefslogtreecommitdiffstats
path: root/plugins/sonar-findbugs-plugin
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-05-15 15:43:03 +0200
committerFabrice Bellingard <bellingard@gmail.com>2012-05-15 15:59:36 +0200
commit0caeb90df921882572b8963d4851e36852358fa5 (patch)
treeb60f734fcc76f9c48e4e6f739894b63487b4d6e2 /plugins/sonar-findbugs-plugin
parentb6d1c37af4d3eb6f57b1f7b27b21df2d883d77a6 (diff)
downloadsonarqube-0caeb90df921882572b8963d4851e36852358fa5.tar.gz
sonarqube-0caeb90df921882572b8963d4851e36852358fa5.zip
SONAR-3074 Add new Findbugs 2.0 new rules
Diffstat (limited to 'plugins/sonar-findbugs-plugin')
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml72
-rw-r--r--plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/rules.xml168
-rw-r--r--plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java9
3 files changed, 244 insertions, 5 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml b/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml
index ffa99664c9d..1fc95f1a2ec 100644
--- a/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml
+++ b/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/profile-sonar-way-findbugs.xml
@@ -1126,4 +1126,76 @@
<Match>
<Bug pattern="DLS_OVERWRITTEN_INCREMENT"/>
</Match>
+ <Match>
+ <Bug pattern="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION"/>
+ </Match>
+ <Match>
+ <Bug pattern="BX_UNBOXING_IMMEDIATELY_REBOXED"/>
+ </Match>
+ <Match>
+ <Bug pattern="CO_COMPARETO_RESULTS_MIN_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_ARGUMENTS_WRONG_ORDER"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_DOH"/>
+ </Match>
+ <Match>
+ <Bug pattern="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS"/>
+ </Match>
+ <Match>
+ <Bug pattern="DM_DEFAULT_ENCODING"/>
+ </Match>
+ <Match>
+ <Bug pattern="ICAST_INT_2_LONG_AS_INSTANT"/>
+ </Match>
+ <Match>
+ <Bug pattern="INT_BAD_COMPARISON_WITH_INT_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT"/>
+ </Match>
+ <Match>
+ <Bug pattern="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE"/>
+ </Match>
+ <Match>
+ <Bug pattern="PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_NEGATING_RESULT_OF_COMPARETO"/>
+ </Match>
+ <Match>
+ <Bug pattern="RV_RETURN_VALUE_IGNORED_INFERRED"/>
+ </Match>
+ <Match>
+ <Bug pattern="SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
+ </Match>
+ <Match>
+ <Bug pattern="VA_FORMAT_STRING_USES_NEWLINE"/>
+ </Match>
+ <Match>
+ <Bug pattern="VO_VOLATILE_INCREMENT"/>
+ </Match>
</FindBugsFilter> \ No newline at end of file
diff --git a/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/rules.xml b/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/rules.xml
index 4c2de7efcbd..44df2180ea9 100644
--- a/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/rules.xml
+++ b/plugins/sonar-findbugs-plugin/src/main/resources/org/sonar/plugins/findbugs/rules.xml
@@ -2751,4 +2751,172 @@
<configKey><![CDATA[LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE]]></configKey>
</rule>
+
+ <rule key="AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Sequence of calls to concurrent abstraction may not be atomic]]></name>
+ <configKey><![CDATA[AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION]]></configKey>
+
+ </rule>
+
+ <rule key="BX_UNBOXING_IMMEDIATELY_REBOXED">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Boxed value is unboxed and then immediately reboxed]]></name>
+ <configKey><![CDATA[BX_UNBOXING_IMMEDIATELY_REBOXED]]></configKey>
+
+ </rule>
+
+ <rule key="CO_COMPARETO_RESULTS_MIN_VALUE">
+ <priority>MAJOR</priority>
+ <name><![CDATA[compareTo()/compare() returns Integer.MIN_VALUE]]></name>
+ <configKey><![CDATA[CO_COMPARETO_RESULTS_MIN_VALUE]]></configKey>
+
+ </rule>
+
+ <rule key="DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Dead store to local variable that shadows field]]></name>
+ <configKey><![CDATA[DLS_DEAD_LOCAL_STORE_SHADOWS_FIELD]]></configKey>
+
+ </rule>
+
+ <rule key="DMI_ARGUMENTS_WRONG_ORDER">
+ <priority>MINOR</priority>
+ <name><![CDATA[Reversed method arguments]]></name>
+ <configKey><![CDATA[DMI_ARGUMENTS_WRONG_ORDER]]></configKey>
+
+ </rule>
+
+ <rule key="DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE">
+ <priority>MAJOR</priority>
+ <name><![CDATA[BigDecimal constructed from double that isn't represented precisely]]></name>
+ <configKey><![CDATA[DMI_BIGDECIMAL_CONSTRUCTED_FROM_DOUBLE]]></configKey>
+
+ </rule>
+
+ <rule key="DMI_DOH">
+ <priority>MAJOR</priority>
+ <name><![CDATA[D'oh! A nonsensical method invocation]]></name>
+ <configKey><![CDATA[DMI_DOH]]></configKey>
+
+ </rule>
+
+ <rule key="DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Adding elements of an entry set may fail due to reuse of Entry objects]]></name>
+ <configKey><![CDATA[DMI_ENTRY_SETS_MAY_REUSE_ENTRY_OBJECTS]]></configKey>
+
+ </rule>
+
+ <rule key="DM_DEFAULT_ENCODING">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Reliance on default encoding]]></name>
+ <configKey><![CDATA[DM_DEFAULT_ENCODING]]></configKey>
+
+ </rule>
+
+ <rule key="ICAST_INT_2_LONG_AS_INSTANT">
+ <priority>MAJOR</priority>
+ <name><![CDATA[int value converted to long and used as absolute time]]></name>
+ <configKey><![CDATA[ICAST_INT_2_LONG_AS_INSTANT]]></configKey>
+
+ </rule>
+
+ <rule key="INT_BAD_COMPARISON_WITH_INT_VALUE">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Bad comparison of int value with long constant]]></name>
+ <configKey><![CDATA[INT_BAD_COMPARISON_WITH_INT_VALUE]]></configKey>
+
+ </rule>
+
+ <rule key="JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Using monitor style wait methods on util.concurrent abstraction]]></name>
+ <configKey><![CDATA[JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT]]></configKey>
+
+ </rule>
+
+ <rule key="NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Read of unwritten public or protected field]]></name>
+ <configKey><![CDATA[NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD]]></configKey>
+
+ </rule>
+
+ <rule key="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE">
+ <priority>CRITICAL</priority>
+ <name><![CDATA[Method may fail to clean up stream or resource on checked exception]]></name>
+ <configKey><![CDATA[OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE]]></configKey>
+
+ </rule>
+
+ <rule key="PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Don't reuse entry objects in iterators]]></name>
+ <configKey><![CDATA[PZ_DONT_REUSE_ENTRY_OBJECTS_IN_ITERATORS]]></configKey>
+
+ </rule>
+
+ <rule key="RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Code checks for specific values returned by compareTo]]></name>
+ <configKey><![CDATA[RV_CHECK_COMPARETO_FOR_SPECIFIC_RETURN_VALUE]]></configKey>
+
+ </rule>
+
+ <rule key="RV_NEGATING_RESULT_OF_COMPARETO">
+ <priority>MINOR</priority>
+ <name><![CDATA[Negating the result of compareTo()/compare()]]></name>
+ <configKey><![CDATA[RV_NEGATING_RESULT_OF_COMPARETO]]></configKey>
+
+ </rule>
+
+ <rule key="RV_RETURN_VALUE_IGNORED_INFERRED">
+ <priority>MINOR</priority>
+ <name><![CDATA[Method ignores return value, is this OK?]]></name>
+ <configKey><![CDATA[RV_RETURN_VALUE_IGNORED_INFERRED]]></configKey>
+
+ </rule>
+
+ <rule key="SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Self assignment of local rather than assignment to field]]></name>
+ <configKey><![CDATA[SA_LOCAL_SELF_ASSIGNMENT_INSTEAD_OF_FIELD]]></configKey>
+
+ </rule>
+
+ <rule key="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD">
+ <priority>INFO</priority>
+ <name><![CDATA[Unread public/protected field]]></name>
+ <configKey><![CDATA[URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD]]></configKey>
+
+ </rule>
+
+ <rule key="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD">
+ <priority>INFO</priority>
+ <name><![CDATA[Unused public or protected field]]></name>
+ <configKey><![CDATA[UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD]]></configKey>
+
+ </rule>
+
+ <rule key="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD">
+ <priority>MINOR</priority>
+ <name><![CDATA[Unwritten public or protected field]]></name>
+ <configKey><![CDATA[UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD]]></configKey>
+
+ </rule>
+
+ <rule key="VA_FORMAT_STRING_USES_NEWLINE">
+ <priority>MAJOR</priority>
+ <name><![CDATA[Format string should use %n rather than \n]]></name>
+ <configKey><![CDATA[VA_FORMAT_STRING_USES_NEWLINE]]></configKey>
+
+ </rule>
+
+ <rule key="VO_VOLATILE_INCREMENT">
+ <priority>CRITICAL</priority>
+ <name><![CDATA[An increment to a volatile field isn't atomic]]></name>
+ <configKey><![CDATA[VO_VOLATILE_INCREMENT]]></configKey>
+
+ </rule>
</rules>
diff --git a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java
index cec6f6d13bd..0186ca90b37 100644
--- a/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java
+++ b/plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/SonarWayWithFindbugsProfileTest.java
@@ -19,14 +19,13 @@
*/
package org.sonar.plugins.findbugs;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
-
import org.junit.Test;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.utils.ValidationMessages;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
public class SonarWayWithFindbugsProfileTest {
@Test
@@ -35,7 +34,7 @@ public class SonarWayWithFindbugsProfileTest {
SonarWayWithFindbugsProfile sonarWayWithFindbugs = new SonarWayWithFindbugsProfile(importer);
ValidationMessages validation = ValidationMessages.create();
RulesProfile profile = sonarWayWithFindbugs.createProfile(validation);
- assertThat(profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).size(), greaterThan(300));
+ assertThat(profile.getActiveRulesByRepository(FindbugsConstants.REPOSITORY_KEY).size(), is(399));
assertThat(validation.hasErrors(), is(false));
}
}