[Fb-contrib-commit] SF.net SVN: fb-contrib:[1747] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2013-06-01 19:30:50
|
Revision: 1747
http://sourceforge.net/p/fb-contrib/code/1747
Author: dbrosius
Date: 2013-06-01 19:30:46 +0000 (Sat, 01 Jun 2013)
Log Message:
-----------
merge from git
Modified Paths:
--------------
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/bugrank.txt
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/htdocs/index.shtml
trunk/fb-contrib/pom.xml
trunk/fb-contrib/samples/ISB_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java
Added Paths:
-----------
trunk/fb-contrib/samples/NPMC_Sample.java
trunk/fb-contrib/samples/UMTP_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/build.xml 2013-06-01 19:30:46 UTC (rev 1747)
@@ -17,7 +17,7 @@
<property name="javac.deprecation" value="on" />
<property name="javac.debug" value="on" />
- <property name="fb-contrib.version" value="4.8.3" />
+ <property name="fb-contrib.version" value="4.9.0" />
<property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" />
@@ -191,8 +191,8 @@
</target>
<target name="srczip" description="builds the source distribution zip file">
- <zip destfile="${basedir}/fb-contrib-src-${fb-contrib.version}.zip" basedir="${basedir}">
- <fileset dir="${src.dir}">
+ <zip destfile="${basedir}/fb-contrib-src-${fb-contrib.version}.zip">
+ <fileset dir="${basedir}">
<include name="**/*.java" />
<include name="**/*.xml" />
<include name="**/*.xsd" />
Modified: trunk/fb-contrib/etc/bugrank.txt
===================================================================
--- trunk/fb-contrib/etc/bugrank.txt 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/etc/bugrank.txt 2013-06-01 19:30:46 UTC (rev 1747)
@@ -79,7 +79,7 @@
0 BugPattern SPP_EQUALS_ON_ENUM
0 BugPattern SPP_INVALID_BOOLEAN_NULL_CHECK
0 BugPattern SPP_USE_CHARAT
-0 BugPattern SPP_USELESS_TRINARY
+0 BugPattern SPP_USELESS_TERNARY
0 BugPattern SPP_SUSPECT_STRING_TEST
0 BugPattern SPP_USE_STRINGBUILDER_LENGTH
0 BugPattern SPP_INVALID_CALENDAR_COMPARE
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/etc/findbugs.xml 2013-06-01 19:30:46 UTC (rev 1747)
@@ -17,7 +17,7 @@
<Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" />
- <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING" />
+ <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering" speed="fast" reports="ISB_INEFFICIENT_STRING_BUFFERING,ISB_EMPTY_STRING_APPENDING,ISB_TOSTRING_APPENDING" />
<Detector class="com.mebigfatguy.fbcontrib.detect.SyncCollectionIterators" speed="slow" reports="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" />
@@ -30,9 +30,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedCollectionContents" speed="fast" reports="UCC_UNRELATED_COLLECTION_CONTENTS" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeclaredRuntimeException" speed="fast" reports="DRE_DECLARED_RUNTIME_EXCEPTION" />
-<!-- COMMENT OUT FOR RELEASE
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" />
- COMMENT OUT FOR RELEASE -->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.LiteralStringComparison" speed="fast" reports="LSC_LITERAL_STRING_COMPARISON" />
<Detector class="com.mebigfatguy.fbcontrib.detect.PartiallyConstructedObjectAccess" speed="fast" reports="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" />
@@ -73,9 +73,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.AbstractOverriddenMethod" speed="fast" reports="AOM_ABSTRACT_OVERRIDDEN_METHOD" />
<Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML" speed="fast" reports="CBX_CUSTOM_BUILT_XML" />
-<!-- COMMENT OUT FOR RELEASE
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" />
- COMMENT OUT FOR RELEASE -->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ConstantListIndex" speed="fast" reports="CLI_CONSTANT_LIST_INDEX" />
<Detector class="com.mebigfatguy.fbcontrib.detect.SloppyClassReflection" speed="fast" reports="SCR_SLOPPY_CLASS_REFLECTION" />
@@ -132,7 +132,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SC_SUSPICIOUS_COMPARATOR_RETURN_VALUES" />
<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,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS" />
+ 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_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS" />
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
@@ -176,9 +176,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryNewNullCheck" speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern" speed="fast" reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" />
-<!-- COMMENT OUT FOR RELEASE
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" />
- COMMENT OUT FOR RELEASE -->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern" speed="fast" reports="TBP_TRISTATE_BOOLEAN_PATTERN" />
@@ -193,9 +193,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" speed="fast" reports="PDP_POORLY_DEFINED_PARAMETER" />
<Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals" speed="fast" reports="NSE_NON_SYMMETRIC_EQUALS" />
-<!-- COMMENT OUT FOR RELEASE
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" />
- COMMENT OUT FOR RELEASE -->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" />
@@ -221,9 +221,9 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse" speed="fast" reports="SGSU_SUSPICIOUS_GETTER_SETTER_USE" />
<Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" />
-<!-- COMMENT OUT FOR RELEASE
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" />
- COMMENT OUT FOR RELEASE -->
+<!-- COMMENT OUT FOR RELEASE -->
<Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals" speed="fast" reports="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" />
<Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode" speed="fast" reports="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" />
@@ -235,7 +235,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers" speed="fast" reports="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" />
<Detector class="com.mebigfatguy.fbcontrib.detect.CloneUsability" speed="fast" reports="CU_CLONE_USABILITY_OBJECT_RETURN,CU_CLONE_USABILITY_MISMATCHED_RETURN,CU_CLONE_USABILITY_THROWS" />
-<!--
+
<Detector class="com.mebigfatguy.fbcontrib.detect.ConfusingArrayAsList" speed="fast" reports="CAAL_CONFUSING_ARRAY_AS_LIST" />
<Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" />
@@ -243,11 +243,12 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter" speed="fast" reports="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" />
<Detector class="com.mebigfatguy.fbcontrib.detect.NonProductiveMethodCall" speed="fast" reports="NPMC_NON_PRODUCTIVE_METHOD_CALL" />
--->
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
<BugPattern abbrev="ISB" type="ISB_EMPTY_STRING_APPENDING" category="PERFORMANCE" />
+ <BugPattern abbrev="ISB" type="ISB_TOSTRING_APPENDING" category="CORRECTNESS" />
<BugPattern abbrev="SCI" type="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" category="CORRECTNESS" />
<BugPattern abbrev="CC" type="CC_CYCLOMATIC_COMPLEXITY" category="STYLE" />
<BugPattern abbrev="OCP" type="OCP_OVERLY_CONCRETE_PARAMETER" category="STYLE" />
@@ -329,7 +330,7 @@
<BugPattern abbrev="SPP" type="SPP_EQUALS_ON_ENUM" category="CORRECTNESS" />
<BugPattern abbrev="SPP" type="SPP_INVALID_BOOLEAN_NULL_CHECK" category="CORRECTNESS" />
<BugPattern abbrev="SPP" type="SPP_USE_CHARAT" category="PERFORMANCE" />
- <BugPattern abbrev="SPP" type="SPP_USELESS_TRINARY" category="PERFORMANCE" />
+ <BugPattern abbrev="SPP" type="SPP_USELESS_TERNARY" category="PERFORMANCE" />
<BugPattern abbrev="SPP" type="SPP_SUSPECT_STRING_TEST" category="CORRECTNESS" />
<BugPattern abbrev="SPP" type="SPP_USE_STRINGBUILDER_LENGTH" category="PERFORMANCE" />
<BugPattern abbrev="SPP" type="SPP_INVALID_CALENDAR_COMPARE" category="CORRECTNESS" />
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/etc/messages.xml 2013-06-01 19:30:46 UTC (rev 1747)
@@ -1359,6 +1359,18 @@
]]>
</Details>
</BugPattern>
+
+ <BugPattern type="ISB_TOSTRING_APPENDING">
+ <ShortDescription>Method concatenates the result of a toString() call</ShortDescription>
+ <LongDescription>Method {1} concatenates the result of a toString() call</LongDescription>
+ <Details>
+ <![CDATA[
+ <p> This method concatenates the output of a toString() call into a StringBuffer/Builder.
+ It is simpler just pass the object you want to append to the to append call, as that form
+ does not suffer the potential for NullPointerExceptions, and is easier to read.</p>
+ ]]>
+ </Details>
+ </BugPattern>
<BugPattern type="SCI_SYNCHRONIZED_COLLECTION_ITERATORS">
<ShortDescription>Method creates iterators on synchronized collections</ShortDescription>
@@ -2431,13 +2443,13 @@
</Details>
</BugPattern>
- <BugPattern type="SPP_USELESS_TRINARY">
- <ShortDescription>Method uses a trinary operator to cast a boolean to true or false</ShortDescription>
- <LongDescription>Method {1} uses a trinary operator to cast a boolean to true or false</LongDescription>
+ <BugPattern type="SPP_USELESS_TERNARY">
+ <ShortDescription>Method uses a ternary operator to cast a boolean to true or false</ShortDescription>
+ <LongDescription>Method {1} uses a ternary operator to cast a boolean to true or false</LongDescription>
<Details>
<![CDATA[
- <p>This method tests the value of a boolean and using a trinary operator to return either true or false.
- The trinary operator is completely unecessary, just use the original boolean value.</p>
+ <p>This method tests the value of a boolean and using a ternary operator to return either true or false.
+ The ternary operator is completely unecessary, just use the original boolean value.</p>
]]>
</Details>
</BugPattern>
Modified: trunk/fb-contrib/htdocs/index.shtml
===================================================================
--- trunk/fb-contrib/htdocs/index.shtml 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/htdocs/index.shtml 2013-06-01 19:30:46 UTC (rev 1747)
@@ -73,9 +73,9 @@
</div>
<hr/>
- <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/>
+ <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/>
Detectors added in svn<br/>
- <div id="svn" style="display:none;">
+ <div id="svn" style="display:block;">
<ul>
<li><b>[CVAA] ContraVariant Array Assignment</b><br/>
Looks for contravariant array assignments. Since arrays are mutable data structures, their use
@@ -86,6 +86,11 @@
same kind of exception, and throw the same exception always. These blocks can
be coalesced into one.
</li>
+ <li><b>[CAAL] Confusing Array As List</b><br/>
+ Looks for calls to Arrays.asList where the parameter is a primitive array.
+ This does not produce a list that holds the primitive boxed value, but a list of
+ one item, the array itself.
+ </li>
<li><b>[PSC] Presize Collections</b><br/>
Looks for methods that create and populate collections, and while knowing
the end size of those collections, does not pre allocate the collection
@@ -105,9 +110,9 @@
</ul>
</div>
<hr/>
- <img id="v4_8_0_image" src="flip2.gif" onClick="toggleBlock('v4_8_0', 'v4_8_0_image');" align="top"/>
+ <img id="v4_8_0_image" src="flip1.gif" onClick="toggleBlock('v4_8_0', 'v4_8_0_image');" align="top"/>
Detectors added in v4.8.0<br/>
- <div id="v4_8_0" style="display:block;">
+ <div id="v4_8_0" style="display:none;">
<ul>
<li><b>[LGO] Lingering Graphics Object</b><br/>
Looks for creation of java.awt.Graphics object that do not have the
Modified: trunk/fb-contrib/pom.xml
===================================================================
--- trunk/fb-contrib/pom.xml 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/pom.xml 2013-06-01 19:30:46 UTC (rev 1747)
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
- <version>4.8.3</version>
+ <version>4.9.0</version>
<parent>
<groupId>org.sonatype.oss</groupId>
Modified: trunk/fb-contrib/samples/ISB_Sample.java
===================================================================
--- trunk/fb-contrib/samples/ISB_Sample.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/samples/ISB_Sample.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -68,6 +68,12 @@
return sb.toString();
}
+ public String testTOStringAppending() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(this.toString());
+ return sb.toString();
+ }
+
@Override
public String toString()
{
Added: trunk/fb-contrib/samples/NPMC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/NPMC_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/NPMC_Sample.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -0,0 +1,60 @@
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+
+public class NPMC_Sample implements Cloneable
+{
+ public void testToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("hello").append("world").toString();
+ }
+
+ public void testXValue()
+ {
+ Integer i = Integer.valueOf(4);
+ i.intValue();
+ Long l = Long.valueOf(4);
+ l.longValue();
+ Double d = Double.valueOf(4);
+ d.doubleValue();
+ Float f = Float.valueOf(4);
+ f.doubleValue();
+ }
+
+ public void testEquals(Object o)
+ {
+ equals(o);
+ }
+
+ public void testHashCode()
+ {
+ hashCode();
+ }
+
+ public NPMC_Sample clone()
+ {
+ try
+ {
+ super.clone();
+
+ return null;
+ }
+ catch (CloneNotSupportedException cnse)
+ {
+ throw new Error();
+ }
+ }
+
+ public String[] testToArrayList()
+ {
+ List<String> l = new ArrayList<String>();
+ l.toArray();
+ Set<String> s = new HashSet<String>();
+ s.toArray();
+
+ return null;
+ }
+}
Property changes on: trunk/fb-contrib/samples/NPMC_Sample.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/fb-contrib/samples/UMTP_Sample.java
===================================================================
--- trunk/fb-contrib/samples/UMTP_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/UMTP_Sample.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -0,0 +1,38 @@
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class UMTP_Sample {
+
+ public <T, C> C getT(String s, int i, Class<C> cls) {
+ T t = (T) getFoo();
+ System.out.println(t);
+
+ return (C) new Object();
+ }
+
+ public <T> String fpUseClass(T t) {
+ return t.toString();
+ }
+
+ public <T> String fpUseClass(Class<T> c) {
+ return c.getName().toString();
+ }
+
+ public <T> String fpUseArray(T[] t) {
+ return t[0].toString();
+ }
+
+ private <K, V> Map<V, K> fpKVReverseMap(Map<K, V> map) {
+ Map<V, K> m = new HashMap<V, K>();
+ for (Map.Entry<K, V> entry : map.entrySet()) {
+ m.put(entry.getValue(), entry.getKey());
+ }
+
+ return m;
+ }
+
+ public Object getFoo() {
+ return null;
+ }
+}
Property changes on: trunk/fb-contrib/samples/UMTP_Sample.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -35,6 +35,8 @@
*/
public class InefficientStringBuffering extends BytecodeScanningDetector
{
+ private enum AppendType { NONE, CLEAR, NESTED, TOSTRING };
+
private BugReporter bugReporter;
private OpcodeStack stack;
private boolean sawLDCEmpty;
@@ -77,7 +79,7 @@
@Override
public void sawOpcode(final int seen) {
- Boolean nestedSB = null;
+ AppendType apType = AppendType.NONE;
try {
stack.mergeJumps(this);
@@ -90,13 +92,13 @@
if ("()V".equals(signature)) {
OpcodeStack.Item itm = getStringBufferItemAt(2);
if (itm != null) {
- nestedSB = Boolean.TRUE;
+ apType = AppendType.NESTED;
}
} else if ("(Ljava/lang/String;)V".equals(signature)) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
- nestedSB = (Boolean)itm.getUserValue();
- if ((nestedSB != null) && nestedSB.booleanValue()) {
+ apType = (AppendType)itm.getUserValue();
+ if (apType == AppendType.NESTED) {
bugReporter.reportBug(
new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", NORMAL_PRIORITY)
.addClass(this)
@@ -138,31 +140,38 @@
String methodName = getNameConstantOperand();
if ("append".equals(methodName)) {
OpcodeStack.Item itm = getStringBufferItemAt(1);
- nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue();
+ apType = (itm == null) ? AppendType.NONE : (AppendType )itm.getUserValue();
if (stack.getStackDepth() > 0) {
itm = stack.getStackItem(0);
- Boolean uValue = (Boolean)itm.getUserValue();
- if ((uValue != null) && uValue.booleanValue()) {
+ AppendType apValue = (AppendType)itm.getUserValue();
+ if (apValue == AppendType.NESTED) {
bugReporter.reportBug(
new BugInstance(this, "ISB_INEFFICIENT_STRING_BUFFERING", "toString".equals(getMethodName()) ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClass(this)
.addMethod(this)
.addSourceLine(this));
-
+ } else if (apValue == AppendType.TOSTRING){
+ bugReporter.reportBug(
+ new BugInstance(this, "ISB_TOSTRING_APPENDING", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
}
}
} else if ("toString".equals(methodName)) {
OpcodeStack.Item itm = getStringBufferItemAt(0);
- nestedSB = (itm == null) ? null : (Boolean)itm.getUserValue();
+ apType = (itm == null) ? AppendType.NONE : (AppendType)itm.getUserValue();
}
+ } else if ("toString".equals(getNameConstantOperand()) && "()Ljava/lang/String;".equals(getSigConstantOperand())) {
+ apType = AppendType.TOSTRING;
}
} else if ((seen == GOTO) || (seen == GOTO_W)) {
int depth = stack.getStackDepth();
for (int i = 0; i < depth; i++) {
OpcodeStack.Item itm = stack.getStackItem(i);
- itm.setUserValue(Boolean.FALSE);
+ itm.setUserValue(AppendType.NONE);
}
} else if ((seen == LDC) || (seen == LDC_W)) {
Constant c = getConstantRefOperand();
@@ -171,15 +180,17 @@
if (s.length() == 0)
sawLDCEmpty = true;
}
+ } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) {
+ apType = AppendType.CLEAR;
}
} finally {
TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
TernaryPatcher.post(stack, seen);
- if (nestedSB != null) {
+ if (apType != AppendType.NONE) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
- itm.setUserValue(nestedSB);
+ itm.setUserValue(apType);
}
}
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -267,12 +267,14 @@
}
}
} else if ("(Ljava/lang/Object;)V".equals(sig)) {
- final JavaClass clazz = stack.getStackItem(0).getJavaClass();
- if(clazz.instanceOf(THROWABLE_CLASS)) {
- bugReporter.reportBug(new BugInstance(this, "LO_LOGGER_LOST_EXCEPTION_STACK_TRACE", NORMAL_PRIORITY)
- .addClass(this)
- .addMethod(this)
- .addSourceLine(this));
+ if (stack.getStackDepth() > 0) {
+ final JavaClass clazz = stack.getStackItem(0).getJavaClass();
+ if(clazz.instanceOf(THROWABLE_CLASS)) {
+ bugReporter.reportBug(new BugInstance(this, "LO_LOGGER_LOST_EXCEPTION_STACK_TRACE", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
}
}
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -142,7 +142,7 @@
}
} else if ((seen == GOTO) || (seen == GOTO_W)) {
if (stack.getStackDepth() > 0) {
- methodSuspect = false; //Trinaries confuse us too much, if the code has a trinary well - oh well
+ methodSuspect = false; //Trinaries confuse us too much, if the code has a ternary well - oh well
}
} else if (seen == INVOKEVIRTUAL) {
String clsName = getClassConstantOperand();
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -0,0 +1,138 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2013 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.fbcontrib.detect;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.bcel.classfile.Code;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.BytecodeScanningDetector;
+import edu.umd.cs.findbugs.OpcodeStack;
+import edu.umd.cs.findbugs.ba.ClassContext;
+
+/**
+ * looks for common methods that are believed to be non mutating, where the value
+ * is discarded. Since the method makes no changes to the object, calling this method
+ * is useless. The method call can be removed.
+ */
+public class NonProductiveMethodCall extends BytecodeScanningDetector {
+
+ private static final Set<Pattern> IMMUTABLE_METHODS = new HashSet<Pattern>();
+
+ static {
+ IMMUTABLE_METHODS.add(Pattern.compile(".*@toString\\(\\)Ljava/lang/String;"));
+ IMMUTABLE_METHODS.add(Pattern.compile("java/lang/.+@.+Value\\(\\)[BCDFIJSZ]"));
+ IMMUTABLE_METHODS.add(Pattern.compile(".*@equals\\(Ljava/lang/Object;\\)Z"));
+ IMMUTABLE_METHODS.add(Pattern.compile(".*@hashCode\\(\\)I"));
+ IMMUTABLE_METHODS.add(Pattern.compile(".*@clone\\(\\).+"));
+ IMMUTABLE_METHODS.add(Pattern.compile("java/util/.+@toArray\\(\\)\\[.+"));
+ }
+
+ private BugReporter bugReporter;
+ private OpcodeStack stack;
+
+ /**
+ * constructs a NPMC detector given the reporter to report bugs on
+ * @param bugReporter the sync of bug reports
+ */
+ public NonProductiveMethodCall(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ /**
+ * implements the visitor to set and clear the stack
+ */
+ public void visitClassContext(ClassContext classContext) {
+ try {
+ stack = new OpcodeStack();
+ super.visitClassContext(classContext);
+ } finally {
+ stack = null;
+ }
+ }
+
+ /**
+ * implements the visitor to reset the opcode stack
+ *
+ * @param obj the context object of the currently parsed code block
+ */
+ public void visitCode(Code obj) {
+ stack.resetForMethodEntry(this);
+ super.visitCode(obj);
+ }
+
+ /**
+ * implements the visitor to look for return values of common immutable method
+ * calls, that are thrown away.
+ *
+ * @param seen the opcode of the currently parsed instruction
+ */
+ public void sawOpcode(int seen) {
+ String methodInfo = null;
+ try {
+ switch (seen) {
+ case INVOKEVIRTUAL:
+ case INVOKEINTERFACE:
+ case INVOKESTATIC:
+ String sig = getSigConstantOperand();
+ if (!sig.endsWith("V")) {
+ methodInfo = getClassConstantOperand() + "@" + getNameConstantOperand() + getSigConstantOperand();
+ }
+ break;
+
+ case POP:
+ case POP2:
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ String mInfo = (String) item.getUserValue();
+ if (mInfo != null) {
+ for (Pattern p : IMMUTABLE_METHODS) {
+ Matcher m = p.matcher(mInfo);
+
+ if (m.matches()) {
+ bugReporter.reportBug(new BugInstance(this, "NPMC_NON_PRODUCTIVE_METHOD_CALL", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this)
+ .addString(mInfo));
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+
+
+ } finally {
+ stack.sawOpcode(this, seen);
+ if (methodInfo != null) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ item.setUserValue(methodInfo);
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -26,6 +26,8 @@
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.CodeException;
+import org.apache.bcel.classfile.LineNumber;
+import org.apache.bcel.classfile.LineNumberTable;
import org.apache.bcel.generic.Type;
import com.mebigfatguy.fbcontrib.collect.Statistics;
@@ -272,21 +274,26 @@
if (!signature.endsWith("V") && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) && !isRiskyName(className, methodName)) {
Object[] parms = mc.getParms();
if (Arrays.equals(parms, parmConstants)) {
- Statistics statistics = Statistics.getStatistics();
- Statistics.MethodInfo mi = statistics.getMethodStatistics(getClassConstantOperand(), methodName, signature);
-
- bugReporter.reportBug(new BugInstance(this, "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS",
- ((mi.numBytes >= highByteCountLimit) || (mi.numMethodCalls >= highMethodCallLimit)) ?
- HIGH_PRIORITY :
- ((mi.numBytes >= normalByteCountLimit) || (mi.numMethodCalls >= normalMethodCallLimit)) ?
- NORMAL_PRIORITY :
- ((mi.numBytes == 0) || (mi.numMethodCalls == 0)) ?
- LOW_PRIORITY :
- EXP_PRIORITY)
- .addClass(this)
- .addMethod(this)
- .addSourceLine(this)
- .addString(methodName + signature));
+ int pc = getPC();
+ int ln = getLineNumber(pc);
+
+ if ((ln != mc.getLineNumber()) || (Math.abs(pc - mc.getPC()) < 10)) {
+ Statistics statistics = Statistics.getStatistics();
+ Statistics.MethodInfo mi = statistics.getMethodStatistics(getClassConstantOperand(), methodName, signature);
+
+ bugReporter.reportBug(new BugInstance(this, "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS",
+ ((mi.numBytes >= highByteCountLimit) || (mi.numMethodCalls >= highMethodCallLimit)) ?
+ HIGH_PRIORITY :
+ ((mi.numBytes >= normalByteCountLimit) || (mi.numMethodCalls >= normalMethodCallLimit)) ?
+ NORMAL_PRIORITY :
+ ((mi.numBytes == 0) || (mi.numMethodCalls == 0)) ?
+ LOW_PRIORITY :
+ EXP_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this)
+ .addString(methodName + signature));
+ }
}
}
@@ -309,17 +316,19 @@
}
}
} else {
+ int pc = getPC();
+ int ln = getLineNumber(pc);
if (seen == INVOKESTATIC) {
- staticMethodCalls.put(className, new MethodCall(methodName, signature, parmConstants));
+ staticMethodCalls.put(className, new MethodCall(methodName, signature, parmConstants, pc, ln));
} else {
if (reg >= 0) {
- localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants));
+ localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants, pc, ln));
} else if (field != null) {
OpcodeStack.Item obj = stack.getStackItem(parmCount);
String fieldSource = (String) obj.getUserValue();
if (fieldSource == null)
fieldSource = "";
- fieldMethodCalls.put(fieldSource + ":" + field.getName(), new MethodCall(methodName, signature, parmConstants));
+ fieldMethodCalls.put(fieldSource + ":" + field.getName(), new MethodCall(methodName, signature, parmConstants, pc, ln));
}
}
}
@@ -355,6 +364,42 @@
}
return false;
}
+
+ /**
+ * returns the source line number for the pc, or just the pc if the line number table
+ * doesn't exist
+ *
+ * @param pc current pc
+ * @return the line number
+ */
+ private int getLineNumber(int pc) {
+ LineNumberTable lnt = getMethod().getLineNumberTable();
+ if (lnt == null)
+ return pc;
+
+ LineNumber[] lns = lnt.getLineNumberTable();
+ if (lns == null)
+ return pc;
+
+ if (pc > lns[lns.length-1].getStartPC())
+ return lns[lns.length-1].getLineNumber();
+
+ int lo = 0;
+ int hi = lns.length - 2;
+ int mid = 0;
+ while (lo <= hi) {
+ mid = (lo + hi) / 2;
+ if (pc < lns[mid].getStartPC()) {
+ hi = mid - 1;
+ } else if (pc >= lns[mid+1].getStartPC()) {
+ lo = mid + 1;
+ } else {
+ break;
+ }
+ }
+
+ return lns[mid].getLineNumber();
+ }
/**
* contains information about a method call
@@ -364,11 +409,15 @@
private final String methodName;
private final String methodSignature;
private final Object[] methodParms;
+ private final int methodPC;
+ private final int methodLineNumber;
- public MethodCall(String name, String signature, Object[] parms) {
+ public MethodCall(String name, String signature, Object[] parms, int pc, int lineNumber) {
methodName = name;
methodSignature = signature;
methodParms = parms;
+ methodPC = pc;
+ methodLineNumber = lineNumber;
}
public String getName() {
@@ -382,5 +431,13 @@
public Object[] getParms() {
return methodParms;
}
+
+ public int getPC() {
+ return methodPC;
+ }
+
+ public int getLineNumber() {
+ return methodLineNumber;
+ }
}
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -288,7 +288,7 @@
}
if (bug) {
- bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TRINARY", NORMAL_PRIORITY)
+ bugReporter.reportBug(new BugInstance(this, "SPP_USELESS_TERNARY", NORMAL_PRIORITY)
.addClass(this)
.addMethod(this)
.addSourceLine(this));
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -0,0 +1,129 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2013 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.fbcontrib.detect;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.bcel.classfile.Attribute;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.classfile.Signature;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.Detector;
+import edu.umd.cs.findbugs.ba.ClassContext;
+import edu.umd.cs.findbugs.visitclass.PreorderVisitor;
+
+/**
+ * Looks for methods that declare method level template parameter(s) that are not bound to any of the
+ * method's parameters, and thus is not adding any validation/type safety to the method, and is
+ * just confusing.
+ */
+public class UnboundMethodTemplateParameter extends PreorderVisitor implements Detector {
+
+ private static final Pattern TEMPLATED_SIGNATURE = Pattern.compile("(\\<[^\\>]+\\>)(.+)");
+ private static final Pattern TEMPLATE = Pattern.compile("\\<?([^:]+):[^;]*;");
+ private BugReporter bugReporter;
+
+
+ public UnboundMethodTemplateParameter(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ /**
+ * implements the visitor to accept the class for visiting
+ *
+ * @param classContext the context object of the currently parsed class
+ */
+ public void visitClassContext(ClassContext classContext) {
+ JavaClass cls = classContext.getJavaClass();
+ cls.accept(this);
+ }
+
+ /**
+ * implements the visitor to find methods that declare template parameters
+ * that are not bound to any parameter.
+ *
+ * @param obj the context object of the currently parsed method
+ */
+ @Override
+ public void visitMethod(Method obj) {
+ Attribute[] attributes = obj.getAttributes();
+ for (Attribute a : attributes) {
+ if (a.getName().equals("Signature")) {
+ TemplateSignature ts = parseSignatureAttribute((Signature) a);
+ if (ts != null) {
+ for (String templateParm : ts.templateParameters) {
+ if (!ts.signature.contains("T" + templateParm + ";") && !ts.signature.contains("[T" + templateParm + ";")) {
+ bugReporter.reportBug(new BugInstance(this, "UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addString("Template Parameter: " + templateParm));
+ return;
+ }
+ }
+ }
+ return;
+ }
+ }
+ }
+
+ public void report() {
+ }
+
+ /**
+ * builds a template signature object based on the signature attribute of the method
+ *
+ * @param signatureAttribute the signature attribute
+ * @return a template signature if there are templates defined, otherwise null
+ */
+ private TemplateSignature parseSignatureAttribute(Signature signatureAttribute) {
+
+ Matcher m = TEMPLATED_SIGNATURE.matcher(signatureAttribute.getSignature());
+ if (m.matches()) {
+ TemplateSignature ts = new TemplateSignature();
+ ts.signature = m.group(2);
+
+ String template = m.group(1);
+
+ m = TEMPLATE.matcher(template);
+ List<String> templates = new ArrayList<String>(4);
+ while (m.find()) {
+ templates.add(m.group(1));
+ }
+ ts.templateParameters = templates.toArray(new String[templates.size()]);
+
+ return ts;
+ }
+
+ return null;
+ }
+
+ /**
+ * a simple data only class for holding the template parameters and method signature
+ */
+ static class TemplateSignature {
+ String[] templateParameters;
+ String signature;
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -76,7 +76,7 @@
CodeException[] ce = obj.getExceptionTable();
if (ce != null) {
for (CodeException element : ce) {
- transitionPoints.add(Integer.valueOf(element.getHandlerPC()));
+ transitionPoints.add(Integer.valueOf(element.getEndPC()));
}
}
super.visitCode(obj);
@@ -103,6 +103,12 @@
case MULTIANEWARRAY:
sawAlloc = true;
break;
+
+ case INVOKESPECIAL:
+ if ("<init>".equals(getNameConstantOperand())) {
+ sawAlloc = true;
+ }
+ break;
case ASTORE:
case ASTORE_0:
@@ -126,9 +132,7 @@
case ALOAD_2:
case ALOAD_3:
int reg = RegisterUtils.getALoadReg(this, seen);
- if (allocationRegs.contains(Integer.valueOf(reg))) {
- sawAlloc = true;
- }
+ sawAlloc = (allocationRegs.contains(Integer.valueOf(reg)));
break;
case IFNONNULL:
@@ -184,11 +188,10 @@
TernaryPatcher.pre(stack, seen);
stack.sawOpcode(this, seen);
TernaryPatcher.post(stack, seen);
- if (sawAlloc) {
- if (stack.getStackDepth() > 0) {
- OpcodeStack.Item item = stack.getStackItem(0);
- item.setUserValue(Boolean.TRUE);
- }
+
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ item.setUserValue(sawAlloc ? Boolean.TRUE : null);
}
}
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2013-04-20 17:38:45 UTC (rev 1746)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java 2013-06-01 19:30:46 UTC (rev 1747)
@@ -86,8 +86,17 @@
binaryOps.set(FREM);
binaryOps.set(DREM);
binaryOps.set(IOR);
+ binaryOps.set(LOR);
binaryOps.set(IAND);
+ binaryOps.set(LAND);
binaryOps.set(IXOR);
+ binaryOps.set(LXOR);
+ binaryOps.set(ISHL);
+ binaryOps.set(LSHL);
+ binaryOps.set(ISHR);
+ binaryOps.set(LSHR);
+ binaryOps.set(IUSHR);
+ binaryOps.set(LUSHR);
}
private final BugReporter bugReporter;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|