[Fb-contrib-commit] SF.net SVN: fb-contrib:[1219] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-07-15 04:48:53
|
Revision: 1219
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1219&view=rev
Author: dbrosius
Date: 2009-07-15 04:48:45 +0000 (Wed, 15 Jul 2009)
Log Message:
-----------
add SPP_USELESS_CASING
Modified Paths:
--------------
trunk/fb-contrib/etc/bugrank.txt
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/samples/SPP_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
Modified: trunk/fb-contrib/etc/bugrank.txt
===================================================================
--- trunk/fb-contrib/etc/bugrank.txt 2009-07-11 05:17:19 UTC (rev 1218)
+++ trunk/fb-contrib/etc/bugrank.txt 2009-07-15 04:48:45 UTC (rev 1219)
@@ -82,11 +82,12 @@
0 BugPattern SPP_USELESS_TRINARY
0 BugPattern SPP_SUSPECT_STRING_TEST
0 BugPattern SPP_USE_STRINGBUILDER_LENGTH
-0 BugPattern SPP_INVALID_CALENDAR_COMPARE" category="CORRECTNESS"/>
-0 BugPattern SPP_USE_CONTAINSKEY" category="STYLE"/>
-0 BugPattern SPP_USE_ISEMPTY" category="STYLE"/>
-0 BugPattern SPP_USE_GETPROPERTY" category="STYLE"/>
-0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE" category="STYLE"/>
+0 BugPattern SPP_INVALID_CALENDAR_COMPARE
+0 BugPattern SPP_USE_CONTAINSKEY
+0 BugPattern SPP_USE_ISEMPTY
+0 BugPattern SPP_USE_GETPROPERTY
+0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE
+0 BugPattern SPP_USELESS_CASING
0 BugPattern BAS_BLOATED_ASSIGNMENT_SCOPE
0 BugPattern SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR
0 BugPattern DWI_DELETING_WHILE_ITERATING
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2009-07-11 05:17:19 UTC (rev 1218)
+++ trunk/fb-contrib/etc/findbugs.xml 2009-07-15 04:48:45 UTC (rev 1219)
@@ -256,7 +256,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SillynessPotPourri"
speed="fast"
- reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY" />
+ reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TRINARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING" />
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope"
speed="fast"
@@ -442,6 +442,7 @@
<BugPattern abbrev="SPP" type="SPP_USE_CONTAINSKEY" category="STYLE"/>
<BugPattern abbrev="SPP" type="SPP_USE_ISEMPTY" category="STYLE"/>
<BugPattern abbrev="SPP" type="SPP_USE_GETPROPERTY" category="STYLE"/>
+ <BugPattern abbrev="SPP" type="SPP_USELESS_CASING" category="PERFORMANCE" experimental="true"/>
<BugPattern abbrev="SPP" type="SPP_SERIALVER_SHOULD_BE_PRIVATE" category="STYLE"/>
<BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" />
<BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" />
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2009-07-11 05:17:19 UTC (rev 1218)
+++ trunk/fb-contrib/etc/messages.xml 2009-07-15 04:48:45 UTC (rev 1219)
@@ -2156,6 +2156,18 @@
</Details>
</BugPattern>
+ <BugPattern type="SPP_USELESS_CASING">
+ <ShortDescription>method compares string without case after enforcing a case</ShortDescription>
+ <LongDescription>method {1} compares string without case after enforcing a case</LongDescription>
+ <Details>
+ <![CDATA[
+ This method compares two strings with compareToIgnoreCase or equalsIgnoreCase, after having
+ called toUpperCase or toLowerCase on the string in question. As you are comparing with out
+ concern to case, the toUpperCase or toLowerCase calls are pointless and can be removed.
+ ]]>
+ </Details>
+ </BugPattern>
+
<BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE">
<ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription>
<LongDescription>Method {1} assigns a variable in a larger scope then is needed</LongDescription>
Modified: trunk/fb-contrib/samples/SPP_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SPP_Sample.java 2009-07-11 05:17:19 UTC (rev 1218)
+++ trunk/fb-contrib/samples/SPP_Sample.java 2009-07-15 04:48:45 UTC (rev 1219)
@@ -270,4 +270,15 @@
{
String lf = System.getProperties().getProperty("line.separator");
}
+
+ public boolean testCasing(String a, String b)
+ {
+ if (a.toUpperCase().equalsIgnoreCase(b))
+ return true;
+
+ if (a.toLowerCase().compareToIgnoreCase(b) == 0)
+ return true;
+
+ return false;
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2009-07-11 05:17:19 UTC (rev 1218)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2009-07-15 04:48:45 UTC (rev 1219)
@@ -421,6 +421,20 @@
}
} else if ("toCharArray".equals(methodName)) {
userValue = "toCharArray";
+ } else if ("toLowerCase".equals(methodName)
+ || "toUpperCase".equals(methodName)) {
+ userValue = "IgnoreCase";
+ } else if ("equalsIgnoreCase".equals(methodName)
+ || "compareToIgnoreCase".equals(methodName)) {
+ if (stack.getStackDepth() > 1) {
+ OpcodeStack.Item item = stack.getStackItem(1);
+ if ("IgnoreCase".equals(item.getUserValue())) {
+ bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_CASING", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
+ }
}
} else if ("equals(Ljava/lang/Object;)Z".equals(methodName + getSigConstantOperand())) {
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|