Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib:[1615] trunk/fb-contrib (Page 3)
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-09-19 03:37:37
|
Revision: 1615
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1615&view=rev
Author: dbrosius
Date: 2010-09-19 03:37:29 +0000 (Sun, 19 Sep 2010)
Log Message:
-----------
add SPP_EMPTY_CASING to SPP
Modified Paths:
--------------
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/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-09-19 02:30:45 UTC (rev 1614)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-09-19 03:37:29 UTC (rev 1615)
@@ -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" />
+ 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" />
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
@@ -310,6 +310,7 @@
<BugPattern abbrev="SPP" type="SPP_USELESS_CASING" category="PERFORMANCE" />
<BugPattern abbrev="SPP" type="SPP_SERIALVER_SHOULD_BE_PRIVATE" category="STYLE" />
<BugPattern abbrev="SPP" type="SPP_NON_ARRAY_PARM" category="CORRECTNESS" />
+ <BugPattern abbrev="SPP" type="SPP_EMPTY_CASING" category="STYLE" />
<BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" />
<BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" />
<BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" />
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2010-09-19 02:30:45 UTC (rev 1614)
+++ trunk/fb-contrib/etc/messages.xml 2010-09-19 03:37:29 UTC (rev 1615)
@@ -2402,6 +2402,17 @@
]]>
</Details>
</BugPattern>
+
+ <BugPattern type="SPP_EMPTY_CASING">
+ <ShortDescription>Method passes an empty string to equalsIgnoreCase or compareToIgnoreCase</ShortDescription>
+ <LongDescription>Method {1} passes an empty string to equalsIgnoreCase or compareToIgnoreCase</LongDescription>
+ <Details>
+ <![CDATA[
+ This method passes the empty string "" to equalsIgnoreCase or compareToIgnoreCase, as the empty string
+ is not case sensitive using equals is simpler. It would be even simpler to do a length() == 0 test.
+ ]]>
+ </Details>
+ </BugPattern>
<BugPattern type="BAS_BLOATED_ASSIGNMENT_SCOPE">
<ShortDescription>Method assigns a variable in a larger scope then is needed</ShortDescription>
Modified: trunk/fb-contrib/samples/SPP_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SPP_Sample.java 2010-09-19 02:30:45 UTC (rev 1614)
+++ trunk/fb-contrib/samples/SPP_Sample.java 2010-09-19 03:37:29 UTC (rev 1615)
@@ -278,11 +278,13 @@
public boolean testCasing(String a, String b)
{
- if (a.toUpperCase().equalsIgnoreCase(b))
- return true;
+ if (a.toUpperCase().equalsIgnoreCase(b)) {
+ return true;
+ }
- if (a.toLowerCase().compareToIgnoreCase(b) == 0)
- return true;
+ if (a.toLowerCase().compareToIgnoreCase(b) == 0) {
+ return true;
+ }
return false;
}
@@ -314,4 +316,9 @@
Array.setInt(notAnArray, 0, 1);
}
+
+ public boolean testEmptyIgnoreCase(String s)
+ {
+ return (s.equalsIgnoreCase(""));
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2010-09-19 02:30:45 UTC (rev 1614)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2010-09-19 03:37:29 UTC (rev 1615)
@@ -279,7 +279,7 @@
bug = false;
}
branchInsSet = branchTargets.get(Integer.valueOf(lastPCs[3]));
- if ((branchInsSet != null) && branchInsSet.size() > 1)
+ if ((branchInsSet != null) && (branchInsSet.size() > 1))
{
bug = false;
}
@@ -473,6 +473,14 @@
.addMethod(this)
.addSourceLine(this));
}
+ item = stack.getStackItem(0);
+ String parm = (String)item.getConstant();
+ if ((parm != null) && (parm.length() == 0)) {
+ bugReporter.reportBug(new BugInstance(this, "SPP_EMPTY_CASING", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
}
}
} else if ("equals(Ljava/lang/Object;)Z".equals(methodName + getSigConstantOperand())) {
@@ -633,7 +641,7 @@
} finally {
stack.sawOpcode(this, seen);
- if ((userValue != null) && stack.getStackDepth() > 0) {
+ if ((userValue != null) && (stack.getStackDepth() > 0)) {
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(userValue);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-09-19 04:53:18
|
Revision: 1616
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1616&view=rev
Author: dbrosius
Date: 2010-09-19 04:53:11 +0000 (Sun, 19 Sep 2010)
Log Message:
-----------
suppress fp's with self modification --> if (a != null) a = a.trim();
Modified Paths:
--------------
trunk/fb-contrib/samples/SNG_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java
Modified: trunk/fb-contrib/samples/SNG_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SNG_Sample.java 2010-09-19 03:37:29 UTC (rev 1615)
+++ trunk/fb-contrib/samples/SNG_Sample.java 2010-09-19 04:53:11 UTC (rev 1616)
@@ -36,4 +36,16 @@
s1 = null;
}
}
+
+ public void fpSelfAdjustingLocal(String s) {
+ if (s != null) {
+ s = s.trim();
+ }
+ }
+
+ public void fpSelfAdjustingField() {
+ if (f1 != null) {
+ f1 = f1.toString();
+ }
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2010-09-19 03:37:29 UTC (rev 1615)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2010-09-19 04:53:11 UTC (rev 1616)
@@ -19,6 +19,7 @@
package com.mebigfatguy.fbcontrib.detect;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import org.apache.bcel.classfile.Code;
@@ -123,13 +124,25 @@
.addClass(this)
.addMethod(this)
.addSourceLine(this));
- nullGuards.remove(guard);
+ removeNullGuard(guard);
}
}
}
}
break;
+ case ALOAD:
+ case ALOAD_0:
+ case ALOAD_1:
+ case ALOAD_2:
+ case ALOAD_3: {
+ NullGuard guard = findNullGuardWithRegister(RegisterUtils.getALoadReg(this, seen));
+ if (guard != null) {
+ removeNullGuard(guard);
+ }
+ }
+ break;
+
case PUTFIELD: {
if (stack.getStackDepth() > 1) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -142,13 +155,26 @@
.addClass(this)
.addMethod(this)
.addSourceLine(this));
- nullGuards.remove(guard);
+ removeNullGuard(guard);
}
}
}
}
}
break;
+
+ case GETFIELD: {
+ if (stack.getStackDepth() > 0) {
+ XField xf = getXFieldOperand();
+ if (xf != null) {
+ NullGuard guard = findNullGuardWithField(xf);
+ if (guard != null) {
+ removeNullGuard(guard);
+ }
+ }
+ }
+ }
+ break;
case IFEQ:
case IFNE:
@@ -195,6 +221,17 @@
return null;
}
+ private void removeNullGuard(NullGuard guard) {
+ Iterator<NullGuard> it = nullGuards.values().iterator();
+ while (it.hasNext()) {
+ NullGuard potentialNG = it.next();
+ if (potentialNG.equals(guard)) {
+ it.remove();
+ break;
+ }
+ }
+ }
+
static class NullGuard {
int register;
XField field;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-09-22 06:10:27
|
Revision: 1617
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1617&view=rev
Author: dbrosius
Date: 2010-09-22 06:10:21 +0000 (Wed, 22 Sep 2010)
Log Message:
-----------
Patch 3071180: Convert fb-contrib to FindBugs Eclipse plugin - supplied by Andrei Loskutov - thanks
Modified Paths:
--------------
trunk/fb-contrib/build.properties
Added Paths:
-----------
trunk/fb-contrib/.classpath
trunk/fb-contrib/.project
trunk/fb-contrib/META-INF/
trunk/fb-contrib/META-INF/MANIFEST.MF
trunk/fb-contrib/plugin.xml
Added: trunk/fb-contrib/.classpath
===================================================================
--- trunk/fb-contrib/.classpath (rev 0)
+++ trunk/fb-contrib/.classpath 2010-09-22 06:10:21 UTC (rev 1617)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="etc"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="samples"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="lib" path="lib/annotations.jar"/>
+ <classpathentry kind="lib" path="lib/asm-3.1.jar"/>
+ <classpathentry kind="lib" path="lib/asm-tree-3.1.jar"/>
+ <classpathentry kind="lib" path="lib/bcel.jar"/>
+ <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
+ <classpathentry kind="lib" path="lib/findbugs-ant.jar"/>
+ <classpathentry kind="lib" path="lib/findbugs.jar" sourcepath="/findbugs"/>
+ <classpathentry kind="lib" path="lib/jsr305.jar"/>
+ <classpathentry kind="lib" path="samples/lib/jsp-api.jar"/>
+ <classpathentry kind="lib" path="samples/lib/junit.jar"/>
+ <classpathentry kind="lib" path="samples/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="samples/lib/servlet-api.jar"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Property changes on: trunk/fb-contrib/.classpath
___________________________________________________________________
Added: svn:eol
+ native
Added: svn:mime-type
+ text/xml
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/.project
===================================================================
--- trunk/fb-contrib/.project (rev 0)
+++ trunk/fb-contrib/.project 2010-09-22 06:10:21 UTC (rev 1617)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>fb-contrib</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
+ </natures>
+</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>fb-contrib</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/fb-contrib/.project
___________________________________________________________________
Added: svn:eol
+ native
Added: svn:mime-type
+ text/xml
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/META-INF/MANIFEST.MF
===================================================================
--- trunk/fb-contrib/META-INF/MANIFEST.MF (rev 0)
+++ trunk/fb-contrib/META-INF/MANIFEST.MF 2010-09-22 06:10:21 UTC (rev 1617)
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: FB-Contrib Plug-in
+Bundle-SymbolicName: com.mebigfatguy.fbcontrib;singleton:=true
+Bundle-Version: 4.5.0.qualifier
+Bundle-ClassPath: .
+Bundle-Vendor: FB-Contrib Project
+Require-Bundle:
+ edu.umd.cs.findbugs.plugin.eclipse,
+ findbugs;resolution:=optional
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+
Property changes on: trunk/fb-contrib/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:eol
+ native
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: trunk/fb-contrib/build.properties
===================================================================
--- trunk/fb-contrib/build.properties 2010-09-19 04:53:11 UTC (rev 1616)
+++ trunk/fb-contrib/build.properties 2010-09-22 06:10:21 UTC (rev 1617)
@@ -1 +1,8 @@
-jdk14.home=C:/j2sdk1.4.2_13
\ No newline at end of file
+jdk14.home=C:/j2sdk1.4.2_13
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .
+jars.compile.order = .
+source.. = src/,\
+ etc/
+output.. = bin/
Added: trunk/fb-contrib/plugin.xml
===================================================================
--- trunk/fb-contrib/plugin.xml (rev 0)
+++ trunk/fb-contrib/plugin.xml 2010-09-22 06:10:21 UTC (rev 1617)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="edu.umd.cs.findbugs.plugin.eclipse.detectorPlugins">
+ <detectorPlugin
+ libraryPath=".">
+ </detectorPlugin>
+ </extension>
+
+</plugin>
Property changes on: trunk/fb-contrib/plugin.xml
___________________________________________________________________
Added: svn:eol
+ native
Added: svn:mime-type
+ text/xml
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-09-22 06:20:42
|
Revision: 1618
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1618&view=rev
Author: dbrosius
Date: 2010-09-22 06:20:35 +0000 (Wed, 22 Sep 2010)
Log Message:
-----------
fix bad patch command
Modified Paths:
--------------
trunk/fb-contrib/.classpath
trunk/fb-contrib/.project
Modified: trunk/fb-contrib/.classpath
===================================================================
--- trunk/fb-contrib/.classpath 2010-09-22 06:10:21 UTC (rev 1617)
+++ trunk/fb-contrib/.classpath 2010-09-22 06:20:35 UTC (rev 1618)
@@ -1,13 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="etc"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
<classpathentry kind="src" path="samples"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
@@ -24,5 +16,6 @@
<classpathentry kind="lib" path="samples/lib/junit.jar"/>
<classpathentry kind="lib" path="samples/lib/log4j.jar"/>
<classpathentry kind="lib" path="samples/lib/servlet-api.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/fb-contrib/.project
===================================================================
--- trunk/fb-contrib/.project 2010-09-22 06:10:21 UTC (rev 1617)
+++ trunk/fb-contrib/.project 2010-09-22 06:20:35 UTC (rev 1618)
@@ -32,26 +32,4 @@
<nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
</natures>
</projectDescription>
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>fb-contrib</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
- </natures>
-</projectDescription>
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-09-26 00:57:16
|
Revision: 1621
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1621&view=rev
Author: dbrosius
Date: 2010-09-26 00:57:09 +0000 (Sun, 26 Sep 2010)
Log Message:
-----------
Build.xml patch for Eclipse plugin - ID: 3074606: by Andrei Loskutov
Modified Paths:
--------------
trunk/fb-contrib/META-INF/MANIFEST.MF
trunk/fb-contrib/build.xml
Modified: trunk/fb-contrib/META-INF/MANIFEST.MF
===================================================================
--- trunk/fb-contrib/META-INF/MANIFEST.MF 2010-09-23 10:50:21 UTC (rev 1620)
+++ trunk/fb-contrib/META-INF/MANIFEST.MF 2010-09-26 00:57:09 UTC (rev 1621)
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: FB-Contrib Plug-in
-Bundle-SymbolicName: com.mebigfatguy.fbcontrib;singleton:=true
+Bundle-SymbolicName: fb-contrib;singleton:=true
Bundle-Version: 4.5.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: FB-Contrib Project
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2010-09-23 10:50:21 UTC (rev 1620)
+++ trunk/fb-contrib/build.xml 2010-09-26 00:57:09 UTC (rev 1621)
@@ -4,9 +4,9 @@
-->
<project name="fb-contrib" default="install">
-
+
<property file="build.properties"/>
-
+
<property name="src.dir" value="${basedir}/src"/>
<property name="classes.dir" value="${basedir}/classes"/>
<property name="lib.dir" value="${basedir}/lib"/>
@@ -19,9 +19,9 @@
<property name="javac.target" value="1.5"/>
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
-
+
<property name="fb-contrib.version" value="4.5.0"/>
-
+
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
<delete dir="${javadoc.dir}"/>
@@ -35,7 +35,7 @@
</delete>
<delete dir="${basedir}/plugin"/>
</target>
-
+
<target name="-init" description="prepares repository for a build">
<mkdir dir="${classes.dir}"/>
<mkdir dir="${javadoc.dir}"/>
@@ -55,7 +55,7 @@
<mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib/detect"/>
<echo message="*.class" file="${classes.dir}/com/mebigfatguy/fbcontrib/detect/.cvsignore"/>
</target>
-
+
<target name="validate_xml" depends="-init" description="validates the xml files">
<xmlvalidate lenient="false" failonerror="yes">
<attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
@@ -63,7 +63,7 @@
<fileset dir="${etc.dir}" includes="*.xml"/>
</xmlvalidate>
</target>
-
+
<target name="compile" depends="-init" description="compiles java files">
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
@@ -74,7 +74,7 @@
<classpath refid="fb-contrib.classpath"/>
</javac>
</target>
-
+
<target name="compile_samples" depends="-init" description="compiles sample problem files">
<javac srcdir="${samples.dir}"
destdir="${samples.dir}"
@@ -96,8 +96,8 @@
<classpath refid="fb-contrib.classpath"/>
<classpath refid="fb-contrib.samples.classpath"/>
</javac>
- </target>
-
+ </target>
+
<target name="jar" depends="compile" description="produces the fb-contrib jar file">
<jar destfile="${basedir}/fb-contrib-${fb-contrib.version}.jar">
<fileset dir="etc">
@@ -110,6 +110,7 @@
<include name="**/*.class"/>
</fileset>
<fileset dir="${basedir}">
+ <include name="plugin.xml"/>
<include name="license.txt"/>
</fileset>
<manifest>
@@ -117,21 +118,23 @@
<attribute name="Main-Class" value="com.mebigfatguy.fbcontrib.FBContrib"/>
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="fb-contrib plugin"/>
- <attribute name="Bundle-SymbolicName" value="com.mebigfatguy.fbcontrib"/>
- <attribute name="Bundle-Version" value="${fb-contrib.version}"/>
- <attribute name="Import-Package" value="org.apache.bcel,org.apache.bcel.classfile,org.apache.bcel.generic,edu.umd.cs.findbugs,edu.umd.cs.findbugs.ba,edu.umd.cs.findbugs.visitclass"/>
- <attribute name="Export-Package" value="com.mebigfatguy.fbcontrib,com.mebigfatguy.fbcontrib.collect,com.mebigfatguy.fbcontrib.detect,com.mebigfatguy.fbcontrib.utils"/>
+ <attribute name="Bundle-SymbolicName" value="fb-contrib; singleton:=true"/>
+ <attribute name="Bundle-Version" value="${fb-contrib.version}"/>
+ <attribute name="Bundle-ClassPath" value="."/>
+ <attribute name="Bundle-Vendor" value="FB-Contrib Project"/>
+ <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse"/>
+ <attribute name="Bundle-ActivationPolicy" value="lazy"/>
</manifest>
- </jar>
+ </jar>
</target>
-
+
<target name="html" depends="-init" description="generates dynamic html">
- <xslt basedir="${etc.dir}"
- destdir="${htdocs.dir}"
+ <xslt basedir="${etc.dir}"
+ destdir="${htdocs.dir}"
style="${etc.dir}/bugdescriptions.xsl"
in="${etc.dir}/messages.xml" out="${htdocs.dir}/bugdescriptions.html"/>
</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}">
@@ -144,7 +147,7 @@
</fileset>
</zip>
</target>
-
+
<target name="javadoc" depends="-init" description="build the javadoc for the project">
<javadoc packagenames="com.mebigfatguy.*"
sourcepath="${src.dir}"
@@ -155,10 +158,10 @@
<bottom><![CDATA[<i>Copyright © 2005-2010 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
-
+
<target name="build" depends="clean, -init, validate_xml, compile, compile_samples, jar" description="builds the plugin jar">
</target>
-
+
<target name="install" depends="build" description="installs the plugin into FindBugs">
<property environment="env"/>
<copy todir="${env.FINDBUGS_HOME}/plugin">
@@ -167,7 +170,7 @@
</fileset>
</copy>
</target>
-
+
<target name="release" depends="build, srczip, html, javadoc" description="prepares everything for a release"/>
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-09-27 23:21:16
|
Revision: 1625
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1625&view=rev
Author: dbrosius
Date: 2010-09-27 23:21:10 +0000 (Mon, 27 Sep 2010)
Log Message:
-----------
get ready for the 4.6.0 release
Modified Paths:
--------------
trunk/fb-contrib/.project
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/findbugs.xml
Modified: trunk/fb-contrib/.project
===================================================================
--- trunk/fb-contrib/.project 2010-09-26 06:08:19 UTC (rev 1624)
+++ trunk/fb-contrib/.project 2010-09-27 23:21:10 UTC (rev 1625)
@@ -3,6 +3,7 @@
<name>fb-contrib</name>
<comment></comment>
<projects>
+ <project>findbugs</project>
</projects>
<buildSpec>
<buildCommand>
@@ -32,4 +33,3 @@
<nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
</natures>
</projectDescription>
-
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2010-09-26 06:08:19 UTC (rev 1624)
+++ trunk/fb-contrib/build.xml 2010-09-27 23:21:10 UTC (rev 1625)
@@ -20,7 +20,7 @@
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
- <property name="fb-contrib.version" value="4.5.0"/>
+ <property name="fb-contrib.version" value="4.6.0"/>
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-09-26 06:08:19 UTC (rev 1624)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-09-27 23:21:10 UTC (rev 1625)
@@ -17,7 +17,6 @@
<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.SyncCollectionIterators" speed="slow" reports="SCI_SYNCHRONIZED_COLLECTION_ITERATORS" />
@@ -31,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" />
-
+<!--
<Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" />
-
+-->
<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" />
@@ -74,8 +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" />
-
- <!-- <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> -->
+<!--
+ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" />
+-->
<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" />
@@ -133,9 +133,9 @@
<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" />
-
+<!--
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
-
+-->
<Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" />
@@ -176,7 +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" />
- <!-- <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" /> -->
+<!--
+ <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" speed="fast" reports="SMA_STUTTERED_METHOD_ARGUMENTS" hidden="true" />
+-->
<Detector class="com.mebigfatguy.fbcontrib.detect.TristateBooleanPattern" speed="fast" reports="TBP_TRISTATE_BOOLEAN_PATTERN" />
@@ -191,9 +193,10 @@
<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" />
+<!--
+ <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" />
+ -->
- <!-- <Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" /> -->
-
<Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" />
<Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousNullGuard" speed="fast" reports="SNG_SUSPICIOUS_NULL_FIELD_GUARD,SNG_SUSPICIOUS_NULL_LOCAL_GUARD" />
@@ -216,6 +219,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SideEffectConstructor" speed="fast" reports="SEC_SIDE_EFFECT_CONSTRUCTOR" />
<Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousGetterSetterUse" speed="fast" reports="SGSU_SUSPICIOUS_GETTER_SETTER_USE" />
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-10-14 04:46:37
|
Revision: 1629
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1629&view=rev
Author: dbrosius
Date: 2010-10-14 04:46:30 +0000 (Thu, 14 Oct 2010)
Log Message:
-----------
add test for transient trims in SPP
Modified Paths:
--------------
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/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-10-14 04:45:37 UTC (rev 1628)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-10-14 04:46:30 UTC (rev 1629)
@@ -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" />
+ 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" />
<!--
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
-->
@@ -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" />
-<!--
+<!-- -->
<Detector class="com.mebigfatguy.fbcontrib.detect.ContraVariantArrayAssignment" speed="fast" hidden="true" reports="CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT,CVAA_CONTRAVARIANT_ELEMENT_ASSIGNMENT" />
- -->
+<!-- -->
<Detector class="com.mebigfatguy.fbcontrib.detect.NonFunctionalField" speed="fast" reports="NFF_NON_FUNCTIONAL_FIELD" />
@@ -315,6 +315,7 @@
<BugPattern abbrev="SPP" type="SPP_SERIALVER_SHOULD_BE_PRIVATE" category="STYLE" />
<BugPattern abbrev="SPP" type="SPP_NON_ARRAY_PARM" category="CORRECTNESS" />
<BugPattern abbrev="SPP" type="SPP_EMPTY_CASING" category="STYLE" />
+ <BugPattern abbrev="SPP" type="SPP_TEMPORARY_TRIM" category="STYLE" />
<BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" />
<BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTATOR" category="STYLE" />
<BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" />
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2010-10-14 04:45:37 UTC (rev 1628)
+++ trunk/fb-contrib/etc/messages.xml 2010-10-14 04:46:30 UTC (rev 1629)
@@ -2413,7 +2413,21 @@
]]>
</Details>
</BugPattern>
-
+
+ <BugPattern type="SPP_TEMPORARY_TRIM">
+ <ShortDescription>Method trims a String temporarily</ShortDescription>
+ <LongDescription>Method {1} trims a String temporarily</LongDescription>
+ <Details>
+ <![CDATA[
+ This method calls trim() on a String without assigning the new string to another variable.
+ It then calls length() or equals on this trimmed string. If trimming the string was important
+ for determining it's length of it's equality, it should be trimmed when you actually go to use it.
+ It would make more sense to first trim the String, store the trimmed value in a variable, and then
+ continue to test and use that trimmed string.
+ ]]>
+ </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 2010-10-14 04:45:37 UTC (rev 1628)
+++ trunk/fb-contrib/samples/SPP_Sample.java 2010-10-14 04:46:30 UTC (rev 1629)
@@ -321,4 +321,15 @@
{
return (s.equalsIgnoreCase(""));
}
+
+ public void testTrim(String s)
+ {
+ if (s.trim().length() > 0)
+ System.out.println(s);
+
+ if (s.trim().equals("Booyah"))
+ {
+ System.out.println("Booyah->" + s);
+ }
+ }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2010-10-14 04:45:37 UTC (rev 1628)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2010-10-14 04:46:30 UTC (rev 1629)
@@ -482,6 +482,28 @@
.addSourceLine(this));
}
}
+ } else if ("trim".equals(methodName)) {
+ userValue = "trim";
+ } else if ("length".equals(methodName)) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ if ("trim".equals(item.getUserValue())) {
+ bugReporter.reportBug(new BugInstance(this, "SPP_TEMPORARY_TRIM", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
+ }
+ } else if ("equals".equals(methodName)) {
+ if (stack.getStackDepth() > 1) {
+ OpcodeStack.Item item = stack.getStackItem(1);
+ if ("trim".equals(item.getUserValue())) {
+ bugReporter.reportBug(new BugInstance(this, "SPP_TEMPORARY_TRIM", 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.
|
|
From: <dbr...@us...> - 2010-11-24 23:16:37
|
Revision: 1647
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1647&view=rev
Author: dbrosius
Date: 2010-11-24 23:16:31 +0000 (Wed, 24 Nov 2010)
Log Message:
-----------
add fp sample for WOC and fix it
Modified Paths:
--------------
trunk/fb-contrib/samples/WOC_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
Modified: trunk/fb-contrib/samples/WOC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/WOC_Sample.java 2010-11-24 05:59:04 UTC (rev 1646)
+++ trunk/fb-contrib/samples/WOC_Sample.java 2010-11-24 23:16:31 UTC (rev 1647)
@@ -1,10 +1,10 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
@@ -70,6 +70,15 @@
}
}
+ public Set<String> testFPTrinary(boolean b)
+ {
+ Set<String> s = new HashSet<String>();
+ s.add("foo");
+ s.add("bar");
+
+ return b ? s : Collections.<String>emptySet();
+ }
+
private void helper(int i, Map<String, String> x)
{
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2010-11-24 05:59:04 UTC (rev 1646)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2010-11-24 23:16:31 UTC (rev 1647)
@@ -312,6 +312,16 @@
}
}
break;
+
+ case GOTO:
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ Object uo = item.getUserValue();
+ if (!(uo instanceof Boolean)) {
+ clearUserValue(item);
+ }
+ }
+ break;
}
} finally {
stack.sawOpcode(this, seen);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-03-06 16:30:24
|
Revision: 1655
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1655&view=rev
Author: dbrosius
Date: 2011-03-06 16:30:15 +0000 (Sun, 06 Mar 2011)
Log Message:
-----------
LLOAD goes to 3
Modified Paths:
--------------
trunk/fb-contrib/.classpath
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/samples/BAS_Sample.java
trunk/fb-contrib/samples/samples-bugs.xml
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/.classpath
===================================================================
--- trunk/fb-contrib/.classpath 2011-03-01 07:07:16 UTC (rev 1654)
+++ trunk/fb-contrib/.classpath 2011-03-06 16:30:15 UTC (rev 1655)
@@ -15,7 +15,7 @@
<classpathentry kind="lib" path="lib/jsr305.jar"/>
<classpathentry kind="lib" path="samples/lib/jsp-api.jar"/>
<classpathentry kind="lib" path="samples/lib/junit.jar"/>
- <classpathentry kind="lib" path="samples/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="samples/lib/log4j.jar" sourcepath="/home/dave/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15-sources.jar"/>
<classpathentry kind="lib" path="samples/lib/servlet-api.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/findbugs"/>
<classpathentry kind="output" path="classes"/>
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2011-03-01 07:07:16 UTC (rev 1654)
+++ trunk/fb-contrib/etc/findbugs.xml 2011-03-06 16:30:15 UTC (rev 1655)
@@ -133,9 +133,9 @@
<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" />
-<!--
+
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
--->
+
<Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" />
Modified: trunk/fb-contrib/samples/BAS_Sample.java
===================================================================
--- trunk/fb-contrib/samples/BAS_Sample.java 2011-03-01 07:07:16 UTC (rev 1654)
+++ trunk/fb-contrib/samples/BAS_Sample.java 2011-03-06 16:30:15 UTC (rev 1655)
@@ -3,7 +3,7 @@
import java.util.Set;
@SuppressWarnings("all")
-public class BAS_Sample
+public class BAS_Sample
{
public void testIfScope(String s)
{
@@ -13,7 +13,7 @@
s = o.toString();
}
}
-
+
public String testFPForScope(String s)
{
Object o = new Object();
@@ -24,7 +24,7 @@
}
return s;
}
-
+
public String testFP2Scopes(String s)
{
Object o = new Object();
@@ -36,10 +36,10 @@
{
s = o.toString();
}
-
+
return s;
}
-
+
public String test2InnerScopes(String s)
{
Object o = new Object();
@@ -54,10 +54,10 @@
s = o.toString();
}
}
-
+
return s;
}
-
+
public String testFPLoopCond(List<String> in)
{
StringBuilder sb = new StringBuilder();
@@ -67,30 +67,30 @@
}
return sb.toString();
}
-
+
public List<String> getList()
{
return null;
}
-
+
public String testSwitch(int a)
{
String v = "Test";
-
+
switch (a)
{
case 1:
v = "Testa";
break;
-
+
case 2:
v = "Tesseract";
break;
-
+
case 3:
v = "Testy";
break;
-
+
default:
v = "Rossa";
break;
@@ -98,45 +98,54 @@
return null;
}
-
+
public void testFPSync(Set<String> a, Set<String> b)
{
String c, d;
-
+
synchronized(this)
{
c = a.iterator().next();
d = b.iterator().next();
}
-
+
if (d.length() > 0)
{
d = c;
}
}
-
+
public int testFPObjChange(Calendar c, boolean b)
{
int hour = c.get(Calendar.HOUR_OF_DAY);
c.set(2000, Calendar.JANUARY, 1);
-
+
if (b)
{
return hour;
}
-
+
return 0;
}
-
+
public void testFPSrcOverwrite(int src, boolean b)
{
int d = src;
src = 0;
-
+
if (b)
{
System.out.println(d);
}
}
+ public void testFPRiskies1(boolean b) {
+ long start = System.currentTimeMillis();
+
+ if (b) {
+ long delta = System.currentTimeMillis() - start;
+ System.out.println(delta);
+ }
+ }
+
}
Modified: trunk/fb-contrib/samples/samples-bugs.xml
===================================================================
--- trunk/fb-contrib/samples/samples-bugs.xml 2011-03-01 07:07:16 UTC (rev 1654)
+++ trunk/fb-contrib/samples/samples-bugs.xml 2011-03-06 16:30:15 UTC (rev 1655)
@@ -1,12 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<BugCollection version="1.2.0-rc1" sequence="0" timestamp="-1" analysisTimestamp="1173623337203" release="">
- <Project filename="O:\fb-contrib\samples\samples.fb">
- <Jar>O:\fb-contrib\samples</Jar>
- <AuxClasspathEntry>O:\fb-contrib\samples\lib\jsp-api.jar</AuxClasspathEntry>
- <SrcDir>O:\fb-contrib\samples</SrcDir>
+ <Project projectName="">
+ <Jar>/home/dave/dev/fb-contrib/samples/O:\fb-contrib\samples</Jar>
+ <AuxClasspathEntry>/home/dave/dev/fb-contrib/samples/O:\fb-contrib\samples\lib\jsp-api.jar</AuxClasspathEntry>
+ <SrcDir>/home/dave/dev/fb-contrib/samples/O:\fb-contrib\samples</SrcDir>
+ <WrkDir>/home/dave/dev/fb-contrib/samples</WrkDir>
+ <SuppressionFilter>
+ <LastVersion value="-1" relOp="NEQ"/>
+ </SuppressionFilter>
+ <Cloud id="1"></Cloud>
</Project>
- <BugInstance type="ABC_ARRAY_BASED_COLLECTIONS" priority="2" abbrev="ABC" category="CORRECTNESS">
+ <CloudDetails online="false"/>
+ <BugInstance type="ABC_ARRAY_BASED_COLLECTIONS" priority="2" abbrev="ABC" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="ABC_Sample">
<SourceLine classname="ABC_Sample" sourcefile="ABC_Sample.java" sourcepath="ABC_Sample.java"/>
</Class>
@@ -15,7 +21,7 @@
</Method>
<SourceLine classname="ABC_Sample" start="29" end="29" startBytecode="2" endBytecode="2" sourcefile="ABC_Sample.java" sourcepath="ABC_Sample.java"/>
</BugInstance>
- <BugInstance type="ABC_ARRAY_BASED_COLLECTIONS" priority="2" abbrev="ABC" category="CORRECTNESS">
+ <BugInstance type="ABC_ARRAY_BASED_COLLECTIONS" priority="2" abbrev="ABC" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="ABC_Sample">
<SourceLine classname="ABC_Sample" sourcefile="ABC_Sample.java" sourcepath="ABC_Sample.java"/>
</Class>
@@ -24,7 +30,7 @@
</Method>
<SourceLine classname="ABC_Sample" start="16" end="16" startBytecode="11" endBytecode="11" sourcefile="ABC_Sample.java" sourcepath="ABC_Sample.java"/>
</BugInstance>
- <BugInstance type="ABC_ARRAY_BASED_COLLECTIONS" priority="2" abbrev="ABC" category="CORRECTNESS">
+ <BugInstance type="ABC_ARRAY_BASED_COLLECTIONS" priority="2" abbrev="ABC" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="ABC_Sample">
<SourceLine classname="ABC_Sample" sourcefile="ABC_Sample.java" sourcepath="ABC_Sample.java"/>
</Class>
@@ -33,12 +39,12 @@
</Method>
<SourceLine classname="ABC_Sample" start="23" end="23" startBytecode="10" endBytecode="10" sourcefile="ABC_Sample.java" sourcepath="ABC_Sample.java"/>
</BugInstance>
- <BugInstance type="SIC_INNER_SHOULD_BE_STATIC_ANON" priority="3" abbrev="SIC" category="PERFORMANCE">
+ <BugInstance type="SIC_INNER_SHOULD_BE_STATIC_ANON" priority="3" abbrev="SIC" category="PERFORMANCE" firstSeen="12/25/10 2:59 PM">
<Class classname="ABC_Sample$UseComparator$1">
<SourceLine classname="ABC_Sample$UseComparator$1" sourcefile="ABC_Sample.java" sourcepath="ABC_Sample.java"/>
</Class>
</BugInstance>
- <BugInstance type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" priority="2" abbrev="ACEM" category="STYLE">
+ <BugInstance type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" priority="2" abbrev="ACEM" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="ACEM_Sample">
<SourceLine classname="ACEM_Sample" sourcefile="ACEM_Sample.java" sourcepath="ACEM_Sample.java"/>
</Class>
@@ -47,7 +53,7 @@
</Method>
<SourceLine classname="ACEM_Sample" start="7" end="7" startBytecode="0" endBytecode="0" sourcefile="ACEM_Sample.java" sourcepath="ACEM_Sample.java"/>
</BugInstance>
- <BugInstance type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" priority="2" abbrev="ACEM" category="STYLE">
+ <BugInstance type="ACEM_ABSTRACT_CLASS_EMPTY_METHODS" priority="2" abbrev="ACEM" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="ACEM_Sample">
<SourceLine classname="ACEM_Sample" sourcefile="ACEM_Sample.java" sourcepath="ACEM_Sample.java"/>
</Class>
@@ -56,7 +62,7 @@
</Method>
<SourceLine classname="ACEM_Sample" start="11" end="11" startBytecode="9" endBytecode="9" sourcefile="ACEM_Sample.java" sourcepath="ACEM_Sample.java"/>
</BugInstance>
- <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS">
+ <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="AFBR_Sample">
<SourceLine classname="AFBR_Sample" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</Class>
@@ -65,7 +71,7 @@
</Method>
<SourceLine classname="AFBR_Sample" start="17" end="17" startBytecode="19" endBytecode="19" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</BugInstance>
- <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS">
+ <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="AFBR_Sample">
<SourceLine classname="AFBR_Sample" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</Class>
@@ -74,7 +80,7 @@
</Method>
<SourceLine classname="AFBR_Sample" start="31" end="31" startBytecode="18" endBytecode="18" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</BugInstance>
- <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS">
+ <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="AFBR_Sample">
<SourceLine classname="AFBR_Sample" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</Class>
@@ -83,7 +89,7 @@
</Method>
<SourceLine classname="AFBR_Sample" start="43" end="43" startBytecode="18" endBytecode="18" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</BugInstance>
- <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS">
+ <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="2" abbrev="AFBR" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="AFBR_Sample">
<SourceLine classname="AFBR_Sample" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</Class>
@@ -92,7 +98,7 @@
</Method>
<SourceLine classname="AFBR_Sample" start="59" end="59" startBytecode="15" endBytecode="15" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</BugInstance>
- <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="3" abbrev="AFBR" category="CORRECTNESS">
+ <BugInstance type="AFBR_ABNORMAL_FINALLY_BLOCK_RETURN" priority="3" abbrev="AFBR" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="AFBR_Sample">
<SourceLine classname="AFBR_Sample" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</Class>
@@ -101,7 +107,7 @@
</Method>
<SourceLine classname="AFBR_Sample" start="78" end="78" startBytecode="50" endBytecode="50" sourcefile="AFBR_Sample.java" sourcepath="AFBR_Sample.java"/>
</BugInstance>
- <BugInstance type="AOM_ABSTRACT_OVERRIDDEN_METHOD" priority="2" abbrev="AOM" category="CORRECTNESS">
+ <BugInstance type="AOM_ABSTRACT_OVERRIDDEN_METHOD" priority="2" abbrev="AOM" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="AOM_Sample">
<SourceLine classname="AOM_Sample" sourcefile="AOM_Sample.java" sourcepath="AOM_Sample.java"/>
</Class>
@@ -109,7 +115,7 @@
<SourceLine classname="AOM_Sample" startBytecode="0" sourcefile="AOM_Sample.java" sourcepath="AOM_Sample.java"/>
</Method>
</BugInstance>
- <BugInstance type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" priority="2" abbrev="AWCBR" category="STYLE">
+ <BugInstance type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" priority="2" abbrev="AWCBR" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="AWCBR_Sample">
<SourceLine classname="AWCBR_Sample" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</Class>
@@ -118,7 +124,7 @@
</Method>
<SourceLine classname="AWCBR_Sample" start="22" end="22" startBytecode="16" endBytecode="16" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</BugInstance>
- <BugInstance type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" priority="2" abbrev="AWCBR" category="STYLE">
+ <BugInstance type="AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE" priority="2" abbrev="AWCBR" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="AWCBR_Sample">
<SourceLine classname="AWCBR_Sample" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</Class>
@@ -127,7 +133,7 @@
</Method>
<SourceLine classname="AWCBR_Sample" start="14" end="14" startBytecode="16" endBytecode="16" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</BugInstance>
- <BugInstance type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" priority="2" abbrev="USBR" category="STYLE">
+ <BugInstance type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" priority="2" abbrev="USBR" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="AWCBR_Sample">
<SourceLine classname="AWCBR_Sample" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</Class>
@@ -136,7 +142,7 @@
</Method>
<SourceLine classname="AWCBR_Sample" start="31" end="31" startBytecode="13" endBytecode="13" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</BugInstance>
- <BugInstance type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" priority="2" abbrev="USBR" category="STYLE">
+ <BugInstance type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" priority="2" abbrev="USBR" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="AWCBR_Sample">
<SourceLine classname="AWCBR_Sample" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</Class>
@@ -145,7 +151,7 @@
</Method>
<SourceLine classname="AWCBR_Sample" start="23" end="23" startBytecode="18" endBytecode="18" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</BugInstance>
- <BugInstance type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" priority="2" abbrev="USBR" category="STYLE">
+ <BugInstance type="USBR_UNNECESSARY_STORE_BEFORE_RETURN" priority="2" abbrev="USBR" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="AWCBR_Sample">
<SourceLine classname="AWCBR_Sample" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</Class>
@@ -154,7 +160,7 @@
</Method>
<SourceLine classname="AWCBR_Sample" start="15" end="15" startBytecode="18" endBytecode="18" sourcefile="AWCBR_Sample.java" sourcepath="AWCBR_Sample.java"/>
</BugInstance>
- <BugInstance type="BAS_BLOATED_ASSIGNMENT_SCOPE" priority="2" abbrev="BAS" category="PERFORMANCE">
+ <BugInstance type="BAS_BLOATED_ASSIGNMENT_SCOPE" priority="2" abbrev="BAS" category="PERFORMANCE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -163,7 +169,7 @@
</Method>
<SourceLine classname="BAS_Sample" start="7" end="7" startBytecode="7" endBytecode="7" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="2" abbrev="DLS" category="STYLE">
+ <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="2" abbrev="DLS" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -173,7 +179,7 @@
<LocalVariable name="o" register="2" pc="8" role="LOCAL_VARIABLE_NAMED"/>
<SourceLine classname="BAS_Sample" start="16" end="16" startBytecode="7" endBytecode="7" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="2" abbrev="DLS" category="STYLE">
+ <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="2" abbrev="DLS" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -183,7 +189,7 @@
<LocalVariable name="s" register="1" pc="22" role="LOCAL_VARIABLE_NAMED"/>
<SourceLine classname="BAS_Sample" start="10" end="10" startBytecode="21" endBytecode="21" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="3" abbrev="DLS" category="STYLE">
+ <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="3" abbrev="DLS" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -193,7 +199,7 @@
<LocalVariable name="o" register="2" pc="22" role="LOCAL_VARIABLE_NAMED"/>
<SourceLine classname="BAS_Sample" start="19" end="19" startBytecode="21" endBytecode="21" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE">
+ <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -202,7 +208,7 @@
</Method>
<SourceLine classname="BAS_Sample" start="41" end="41" startBytecode="15" endBytecode="15" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE">
+ <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -211,7 +217,7 @@
</Method>
<SourceLine classname="BAS_Sample" start="43" end="43" startBytecode="32" endBytecode="32" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE">
+ <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -220,7 +226,7 @@
</Method>
<SourceLine classname="BAS_Sample" start="28" end="28" startBytecode="11" endBytecode="11" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE">
+ <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -229,7 +235,7 @@
</Method>
<SourceLine classname="BAS_Sample" start="30" end="30" startBytecode="28" endBytecode="28" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE">
+ <BugInstance type="LSC_LITERAL_STRING_COMPARISON" priority="3" abbrev="LSC" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BAS_Sample">
<SourceLine classname="BAS_Sample" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</Class>
@@ -238,7 +244,7 @@
</Method>
<SourceLine classname="BAS_Sample" start="8" end="8" startBytecode="11" endBytecode="11" sourcefile="BAS_Sample.java" sourcepath="BAS_Sample.java"/>
</BugInstance>
- <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="3" abbrev="DLS" category="STYLE">
+ <BugInstance type="DLS_DEAD_LOCAL_STORE" priority="3" abbrev="DLS" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="BSB_Sample">
<SourceLine classname="BSB_Sample" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</Class>
@@ -248,7 +254,7 @@
<LocalVariable name="?" register="5" pc="55" role="LOCAL_VARIABLE_UNKNOWN"/>
<SourceLine classname="BSB_Sample" start="74" end="74" startBytecode="55" endBytecode="55" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</BugInstance>
- <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS">
+ <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="BSB_Sample">
<SourceLine classname="BSB_Sample" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</Class>
@@ -257,7 +263,7 @@
</Method>
<SourceLine classname="BSB_Sample" start="42" end="42" startBytecode="19" endBytecode="19" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</BugInstance>
- <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS">
+ <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="BSB_Sample">
<SourceLine classname="BSB_Sample" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</Class>
@@ -266,7 +272,7 @@
</Method>
<SourceLine classname="BSB_Sample" start="54" end="54" startBytecode="16" endBytecode="16" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</BugInstance>
- <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS">
+ <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="BSB_Sample">
<SourceLine classname="BSB_Sample" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</Class>
@@ -275,7 +281,7 @@
</Method>
<SourceLine classname="BSB_Sample" start="18" end="18" startBytecode="14" endBytecode="14" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</BugInstance>
- <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS">
+ <BugInstance type="LSYC_LOCAL_SYNCHRONIZED_COLLECTION" priority="1" abbrev="LSYC" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="BSB_Sample">
<SourceLine classname="BSB_Sample" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</Class>
@@ -284,7 +290,7 @@
</Method>
<SourceLine classname="BSB_Sample" start="30" end="30" startBytecode="16" endBytecode="16" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</BugInstance>
- <BugInstance type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" priority="2" abbrev="NMCS" category="PERFORMANCE">
+ <BugInstance type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" priority="2" abbrev="NMCS" category="PERFORMANCE" firstSeen="12/25/10 2:59 PM">
<Class classname="BSB_Sample">
<SourceLine classname="BSB_Sample" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</Class>
@@ -292,63 +298,63 @@
<SourceLine classname="BSB_Sample" start="12" end="12" startBytecode="37" endBytecode="37" sourcefile="BSB_Sample.java" sourcepath="BSB_Sample.java"/>
</Field>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testcd(D)V"/>
<String value="testcd(Ljava/lang/Character;)V"/>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testcd(Ljava/lang/Character;)V"/>
<String value="testcd(D)V"/>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testcf(F)V"/>
<String value="testcf(Ljava/lang/Character;)V"/>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testcf(Ljava/lang/Character;)V"/>
<String value="testcf(F)V"/>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testci(I)V"/>
<String value="testci(Ljava/lang/Character;)V"/>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testci(Ljava/lang/Character;)V"/>
<String value="testci(I)V"/>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testcj(J)V"/>
<String value="testcj(Ljava/lang/Character;)V"/>
</BugInstance>
- <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS">
+ <BugInstance type="CAO_CONFUSING_AUTOBOXED_OVERLOADING" priority="2" abbrev="CAO" category="CORRECTNESS" firstSeen="12/25/10 2:59 PM">
<Class classname="CAO_Sample">
<SourceLine classname="CAO_Sample" sourcefile="CAO_Sample.java" sourcepath="CAO_Sample.java"/>
</Class>
<String value="testcj(Ljava/lang/Character;)V"/>
<String value="testcj(J)V"/>
</BugInstance>
- <BugInstance type="CBX_CUSTOM_BUILT_XML" priority="3" abbrev="CBX" category="STYLE">
+ <BugInstance type="CBX_CUSTOM_BUILT_XML" priority="3" abbrev="CBX" category="STYLE" firstSeen="12/25/10 2:59 PM">
<Class classname="CBX_Sample">
<SourceLine classname="CBX_Sample" sourcefile="CBX_Sample.java" sourcepath="CBX_Sample.java"/>
</Class>
@@ -357,7 +363,7 @@
</Method>
<SourceLine classname="CBX_Sample" start="7" end="7" startBytecode="11" endBytecode="11" sourcefile="CBX_Sample.java" sourcepath="CBX_Sample.java"/>
</BugInstance>
- <BugInstance type="ISB_INEFFICIENT_STRING_BUFFERING" priority="2" abbrev="ISB" category="PERFORMANCE">
+ <BugInstance type="ISB_INEFFICIENT_STRING_BUFFERING" priority="2" abbrev="ISB" category="PERFORMANCE" firstSeen="12/25/10 2:59 PM">
<Class classname="CBX_Sample">
<SourceLine classname="CBX_Sample" sourcefile="CBX_Sample.java" sourcepath="CBX_Sample.java...
[truncated message content] |
|
From: <dbr...@us...> - 2011-03-25 23:27:20
|
Revision: 1660
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1660&view=rev
Author: dbrosius
Date: 2011-03-25 23:27:14 +0000 (Fri, 25 Mar 2011)
Log Message:
-----------
formatting
Modified Paths:
--------------
trunk/fb-contrib/samples/BAS_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
Modified: trunk/fb-contrib/samples/BAS_Sample.java
===================================================================
--- trunk/fb-contrib/samples/BAS_Sample.java 2011-03-25 23:26:22 UTC (rev 1659)
+++ trunk/fb-contrib/samples/BAS_Sample.java 2011-03-25 23:27:14 UTC (rev 1660)
@@ -1,10 +1,14 @@
import java.util.Calendar;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
@SuppressWarnings("all")
public class BAS_Sample
{
+ private final Map<String, String> m = new HashMap<String, String>();
+
public void testIfScope(String s)
{
Object o = new Object();
@@ -147,5 +151,4 @@
System.out.println(delta);
}
}
-
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2011-03-25 23:26:22 UTC (rev 1659)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2011-03-25 23:27:14 UTC (rev 1660)
@@ -1,17 +1,17 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
* Copyright (C) 2005-2011 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
@@ -29,12 +29,12 @@
import edu.umd.cs.findbugs.ba.ClassContext;
/**
- * looks for private methods that can only return one constant value.
+ * looks for private methods that can only return one constant value.
* either the class should not return a value, or perhaps a branch was missed.
*/
-public class MethodReturnsConstant extends BytecodeScanningDetector
+public class MethodReturnsConstant extends BytecodeScanningDetector
{
- private BugReporter bugReporter;
+ private final BugReporter bugReporter;
private OpcodeStack stack;
private Object returnConstant;
private boolean methodSuspect;
@@ -47,20 +47,20 @@
public MethodReturnsConstant(BugReporter bugReporter) {
this.bugReporter = bugReporter;
}
-
+
@Override
public void visitClassContext(ClassContext classContext) {
- try {
+ try {
stack = new OpcodeStack();
super.visitClassContext(classContext);
} finally {
stack = null;
}
}
-
+
/**
* implements the visitor to reset the stack and proceed for private methods
- *
+ *
* @param obj the context object of the currently parsed code block
*/
@Override
@@ -79,27 +79,29 @@
BugInstance bi = new BugInstance(this, "MRC_METHOD_RETURNS_CONSTANT", ((aFlags & Constants.ACC_PRIVATE) != 0) ? NORMAL_PRIORITY : LOW_PRIORITY)
.addClass(this)
.addMethod(this);
- if (returnPC >= 0)
+ if (returnPC >= 0) {
bi.addSourceLine(this, returnPC);
-
+ }
+
bi.addString(returnConstant.toString());
bugReporter.reportBug(bi);
}
}
}
-
+
/**
* implements the visitor to look for methods that return a constant
- *
+ *
* @param seen the opcode of the currently parsed instruction
*/
@Override
public void sawOpcode(int seen) {
boolean sawSBToString = false;
try {
- if (!methodSuspect)
+ if (!methodSuspect) {
return;
-
+ }
+
if ((seen >= IRETURN) && (seen <= ARETURN)) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -117,12 +119,12 @@
methodSuspect = false;
return;
}
-
+
returnConstant = constant;
}
} else if ((seen == GOTO) || (seen == GOTO_W)) {
if (stack.getStackDepth() > 0) {
- methodSuspect = false; //Trinaries confuse us to much, if the code has a trinary well - oh well
+ methodSuspect = false; //Trinaries confuse us too much, if the code has a trinary well - oh well
}
} else if (seen == INVOKEVIRTUAL) {
String clsName = getClassConstantOperand();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-03-25 23:43:59
|
Revision: 1661
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1661&view=rev
Author: dbrosius
Date: 2011-03-25 23:43:53 +0000 (Fri, 25 Mar 2011)
Log Message:
-----------
fix WOC FP when field is fetched from a non-this object of the same class
Modified Paths:
--------------
trunk/fb-contrib/samples/WOC_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
Modified: trunk/fb-contrib/samples/WOC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/WOC_Sample.java 2011-03-25 23:27:14 UTC (rev 1660)
+++ trunk/fb-contrib/samples/WOC_Sample.java 2011-03-25 23:43:53 UTC (rev 1661)
@@ -97,7 +97,7 @@
};
}
- public List<String> fpOtherClass(WOC_Sample ws)
+ public List<String> fpOtherInstance(WOC_Sample ws)
{
return ws.fpList;
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2011-03-25 23:27:14 UTC (rev 1660)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java 2011-03-25 23:43:53 UTC (rev 1661)
@@ -98,6 +98,7 @@
private final BugReporter bugReporter;
private OpcodeStack stack;
+ private String clsSignature;
/** register to first allocation PC */
private Map<Integer, Integer> localWOCollections;
/** fieldname to field sig */
@@ -119,11 +120,12 @@
@Override
public void visitClassContext(ClassContext classContext) {
try {
+ clsSignature = "L" + classContext.getJavaClass().getClassName().replaceAll("\\.", "/") + ";";
stack = new OpcodeStack();
localWOCollections = new HashMap<Integer, Integer>();
fieldWOCollections = new HashMap<String, String>();
super.visitClassContext(classContext);
-
+
if (fieldWOCollections.size() > 0) {
String clsName = classContext.getJavaClass().getClassName();
for (Map.Entry<String, String> entry : fieldWOCollections.entrySet()) {
@@ -140,7 +142,7 @@
fieldWOCollections = null;
}
}
-
+
@Override
public void visitField(Field obj) {
if (obj.isPrivate() && !obj.isSynthetic()) {
@@ -149,7 +151,7 @@
String type = sig.substring(1, sig.length() - 1).replace('/', '.');
if (collectionClasses.contains(type)) {
fieldWOCollections.put(obj.getName(), obj.getSignature());
- }
+ }
}
}
}
@@ -199,7 +201,7 @@
break;
case INVOKEINTERFACE:
- case INVOKEVIRTUAL:
+ case INVOKEVIRTUAL: {
String sig = getSigConstantOperand();
int numParms = Type.getArgumentTypes(sig).length;
if (stack.getStackDepth() > numParms) {
@@ -218,6 +220,7 @@
}
}
processMethodParms();
+ }
break;
case INVOKESTATIC:
@@ -281,7 +284,8 @@
case GETFIELD:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
- if (item.getRegisterNumber() == 0) {
+ String sig = item.getSignature();
+ if ((item.getRegisterNumber() == 0) || ((sig != null) && sig.equals(clsSignature))) {
XField field = getXFieldOperand();
if (field != null) {
String fieldName = field.getName();
@@ -292,7 +296,7 @@
}
}
break;
-
+
case PUTSTATIC:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -302,7 +306,7 @@
}
}
break;
-
+
case GETSTATIC:
XField field = getXFieldOperand();
if (field != null) {
@@ -312,7 +316,7 @@
}
}
break;
-
+
case GOTO:
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -338,7 +342,7 @@
int nextPC = getNextPC();
return getCode().getCode()[nextPC] == POP;
}
-
+
private void clearUserValue(OpcodeStack.Item item) {
Object uo = item.getUserValue();
if (uo instanceof Integer) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-04-26 01:56:00
|
Revision: 1663
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1663&view=rev
Author: dbrosius
Date: 2011-04-26 01:55:51 +0000 (Tue, 26 Apr 2011)
Log Message:
-----------
don't report OCP for parameters that are returned
Modified Paths:
--------------
trunk/fb-contrib/samples/OCP_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java
Modified: trunk/fb-contrib/samples/OCP_Sample.java
===================================================================
--- trunk/fb-contrib/samples/OCP_Sample.java 2011-04-22 05:14:32 UTC (rev 1662)
+++ trunk/fb-contrib/samples/OCP_Sample.java 2011-04-26 01:55:51 UTC (rev 1663)
@@ -24,81 +24,87 @@
{
public String getDisplay(HashSet<String> s, String a, String b)
{
- if (s.contains(a))
+ if (s.contains(a)) {
s.add(b);
- else
+ } else {
s.add(a + b);
-
+ }
+
StringBuffer sb = new StringBuffer();
Iterator<String> it = s.iterator();
- while (it.hasNext())
+ while (it.hasNext()) {
sb.append(it.next());
+ }
return sb.toString();
}
-
+
public void parse(DefaultHandler dh, File f)
throws SAXException, ParserConfigurationException, IOException
{
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
-
+
xr.setContentHandler( dh );
xr.parse(new InputSource( new FileInputStream(f)));
}
-
+
public void falsePositive(B b)
{
b.test();
b.x = 4;
}
-
+
+ public Color fpGetColor(Color c) {
+ return c;
+ }
+
public static interface A
{
public void test();
-
+
public void fp() throws IOException;
}
-
+
public static class B implements A
{
public int x = 0;
-
- public void test()
+
+ public void test()
{
-
+
}
-
+
public void fp()
{
-
+
}
}
-
+
public void actionPerformed(ActionEvent ae)
{
-
+
}
-
+
public void ocpFalseFPDueToExceptionSig(B b)
{
b.fp();
}
-
+
@Override
public void usesOCP(LinkedList<String> ll)
{
ll.add("foo");
}
-
+
public void testFPaastore(Color c)
{
Color[] cc = new Color[] { c, c };
}
-
+
private void readObject(ObjectInputStream ois)
{
-
+
}
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2011-04-22 05:14:32 UTC (rev 1662)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2011-04-26 01:55:51 UTC (rev 1663)
@@ -1,17 +1,17 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
* Copyright (C) 2005-2011 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
@@ -61,7 +61,7 @@
private int parmCount;
private boolean methodSignatureIsConstrained;
private boolean methodIsStatic;
-
+
/**
* constructs a OCP detector given the reporter to report bugs on
* @param bugReporter the sync of bug reports
@@ -75,7 +75,7 @@
objectClass = null;
}
}
-
+
@Override
public void visitClassContext(ClassContext classContext) {
try {
@@ -97,21 +97,21 @@
stack = null;
}
}
-
+
@Override
public void visitMethod(Method obj) {
methodSignatureIsConstrained = false;
String methodName = obj.getName();
-
+
if (!"<init>".equals(methodName)
&& !"<clinit>".equals(methodName)) {
String methodSig = obj.getSignature();
-
+
methodSignatureIsConstrained = methodIsSpecial(methodName, methodSig);
if (!methodSignatureIsConstrained) {
String parms = methodSig.split("\\(|\\)")[1];
if (parms.indexOf(';') >= 0) {
-
+
outer:for (JavaClass cls : constrainingClasses) {
Method[] methods = cls.getMethods();
for (Method m : methods) {
@@ -127,29 +127,33 @@
}
}
}
-
+
@Override
public void visitCode(final Code obj) {
try {
- if (methodSignatureIsConstrained)
+ if (methodSignatureIsConstrained) {
return;
-
- if (obj.getCode() == null)
+ }
+
+ if (obj.getCode() == null) {
return;
+ }
Method m = getMethod();
- if (m.getName().startsWith("access$"))
+ if (m.getName().startsWith("access$")) {
return;
-
+ }
+
methodIsStatic = m.isStatic();
parmCount = m.getArgumentTypes().length;
-
- if (parmCount == 0)
+
+ if (parmCount == 0) {
return;
-
+ }
+
parameterDefiners.clear();
usedParameters.clear();
stack.resetForMethodEntry(this);
-
+
if (buildParameterDefiners()) {
super.visitCode(obj);
reportBugs();
@@ -158,15 +162,16 @@
bugReporter.reportMissingClass(cnfe);
}
}
-
+
@Override
public void sawOpcode(final int seen) {
- if (parameterDefiners.isEmpty())
+ if (parameterDefiners.isEmpty()) {
return;
-
+ }
+
try {
stack.mergeJumps(this);
-
+
if ((seen == INVOKEVIRTUAL) || (seen == INVOKESTATIC) || (seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE)) {
String methodSig = getSigConstantOperand();
Type[] parmTypes = Type.getArgumentTypes(methodSig);
@@ -184,8 +189,9 @@
OpcodeStack.Item itm = stack.getStackItem(parmTypes.length);
int reg = itm.getRegisterNumber();
int parm = reg;
- if (!methodIsStatic)
+ if (!methodIsStatic) {
parm--;
+ }
if ((parm >= 0) && (parm < parmCount)) {
removeUselessDefiners(reg);
}
@@ -199,68 +205,91 @@
OpcodeStack.Item itm = stack.getStackItem(0);
int reg = itm.getRegisterNumber();
int parm = reg;
- if (!methodIsStatic)
+ if (!methodIsStatic) {
parm--;
- if ((parm >= 0) && (parm < parmCount))
+ }
+ if ((parm >= 0) && (parm < parmCount)) {
parameterDefiners.remove(Integer.valueOf(reg));
+ }
} else {
parameterDefiners.clear();
}
-
+
if ((seen == GETFIELD) || (seen == PUTFIELD)) {
if (stack.getStackDepth() > 1) {
OpcodeStack.Item itm = stack.getStackItem(1);
int reg = itm.getRegisterNumber();
int parm = reg;
- if (!methodIsStatic)
+ if (!methodIsStatic) {
parm--;
- if ((parm >= 0) && (parm < parmCount))
+ }
+ if ((parm >= 0) && (parm < parmCount)) {
parameterDefiners.remove(Integer.valueOf(reg));
+ }
} else {
parameterDefiners.clear();
}
}
-
+
} else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) {
int reg = RegisterUtils.getALoadReg(this, seen);
int parm = reg;
- if (!methodIsStatic)
+ if (!methodIsStatic) {
parm--;
- if ((parm >= 0) && (parm < parmCount))
+ }
+ if ((parm >= 0) && (parm < parmCount)) {
usedParameters.add(Integer.valueOf(reg));
+ }
} else if (seen == AASTORE) {
- //Don't check parameters that are stored in
+ //Don't check parameters that are stored in
if (stack.getStackDepth() >= 3) {
OpcodeStack.Item itm = stack.getStackItem(0);
int reg = itm.getRegisterNumber();
int parm = reg;
- if (!methodIsStatic)
+ if (!methodIsStatic) {
parm--;
- if ((parm >= 0) && (parm < parmCount))
+ }
+ if ((parm >= 0) && (parm < parmCount)) {
parameterDefiners.remove(Integer.valueOf(reg));
+ }
} else {
parameterDefiners.clear();
}
+ } else if (seen == ARETURN) {
+ if (stack.getStackDepth() >= 1) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ int reg = item.getRegisterNumber();
+ int parm = reg;
+ if (!methodIsStatic) {
+ parm--;
+ }
+
+ if ((parm >= 0) && (parm < parmCount)) {
+ parameterDefiners.remove(Integer.valueOf(reg));
+ }
+ } else {
+ parameterDefiners.clear();
+ }
}
} finally {
stack.sawOpcode(this, seen);
}
}
-
+
private boolean methodIsSpecial(String methodName, String methodSig) {
if ("readObject".equals(methodName) && "(Ljava/io/ObjectInputStream;)V".equals(methodSig)) {
return true;
}
-
+
return false;
}
-
+
private void reportBugs() {
Iterator<Map.Entry<Integer, Map<JavaClass, List<MethodInfo>>>> it = parameterDefiners.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, Map<JavaClass, List<MethodInfo>>> entry = it.next();
-
+
Integer reg = entry.getKey();
if (!usedParameters.contains(reg)) {
it.remove();
@@ -273,14 +302,16 @@
LocalVariableTable lvt = getMethod().getLocalVariableTable();
if (lvt != null) {
LocalVariable lv = lvt.getLocalVariable(reg.intValue(), 0);
- if (lv != null)
+ if (lv != null) {
name = lv.getName();
+ }
}
int parm = reg.intValue();
- if (!methodIsStatic)
+ if (!methodIsStatic) {
parm--;
+ }
parm++; //users expect 1 based parameters
-
+
String infName = definers.keySet().iterator().next().getClassName();
bugReporter.reportBug( new BugInstance(this, "OCP_OVERLY_CONCRETE_PARAMETER", NORMAL_PRIORITY)
.addClass(this)
@@ -290,33 +321,35 @@
}
}
}
-
- /**
+
+ /**
* builds a map of method information for each method of each interface that each parameter implements of this method
* @return a map by parameter id of all the method signatures that interfaces of that parameter implements
- *
+ *
* @throws ClassNotFoundException if the class can't be loaded
*/
- private boolean buildParameterDefiners()
+ private boolean buildParameterDefiners()
throws ClassNotFoundException {
-
+
Type[] parms = getMethod().getArgumentTypes();
- if (parms.length == 0)
+ if (parms.length == 0) {
return false;
-
+ }
+
boolean hasPossiblyOverlyConcreteParm = false;
for (int i = 0; i < parms.length; i++) {
String parm = parms[i].getSignature();
if (parm.startsWith("L")) {
String clsName = parm.substring(1, parm.length() - 1).replace('/', '.');
- if (clsName.startsWith("java.lang."))
+ if (clsName.startsWith("java.lang.")) {
continue;
-
+ }
+
JavaClass cls = Repository.lookupClass(clsName);
if (cls.isClass() && (!cls.isAbstract())) {
Map<JavaClass, List<MethodInfo>> definers = getClassDefiners(cls);
-
+
if (definers.size() > 0) {
parameterDefiners.put( Integer.valueOf(i + (methodIsStatic ? 0 : 1)), definers );
hasPossiblyOverlyConcreteParm = true;
@@ -324,24 +357,25 @@
}
}
}
-
+
return hasPossiblyOverlyConcreteParm;
}
-
+
/**
* returns a map of method information for each public method for each interface this class implements
* @param cls the class whose interfaces to record
- *
+ *
* @return a map of (method name)(method sig) by interface
* @throws ClassNotFoundException if unable to load the class
*/
- private Map<JavaClass, List<MethodInfo>> getClassDefiners(final JavaClass cls)
+ private Map<JavaClass, List<MethodInfo>> getClassDefiners(final JavaClass cls)
throws ClassNotFoundException {
Map<JavaClass, List<MethodInfo>> definers = new HashMap<JavaClass, List<MethodInfo>>();
-
+
for (JavaClass ci : cls.getAllInterfaces()) {
- if ("java.lang.Comparable".equals(ci.getClassName()))
+ if ("java.lang.Comparable".equals(ci.getClassName())) {
continue;
+ }
List<MethodInfo> methodInfos = getPublicMethodInfos(ci);
if (methodInfos.size() > 0) {
definers.put(ci, methodInfos);
@@ -349,10 +383,10 @@
}
return definers;
}
-
+
/**
* returns a lost of method information of all public or protected methods in this class
- *
+ *
* @param cls the class to look for methods
* @return a map of (method name)(method signature)
*/
@@ -367,15 +401,15 @@
}
return methodInfos;
}
-
+
private void removeUselessDefiners(final int reg) {
-
+
Map<JavaClass, List<MethodInfo>> definers = parameterDefiners.get(Integer.valueOf(reg));
if ((definers != null) && (definers.size() > 0)) {
String methodSig = getSigConstantOperand();
String methodName = getNameConstantOperand();
MethodInfo methodInfo = new MethodInfo(methodName, methodSig, null);
-
+
Iterator<List<MethodInfo>> it = definers.values().iterator();
while (it.hasNext()) {
boolean methodDefined = false;
@@ -396,20 +430,21 @@
break;
}
}
- if (!methodDefined)
+ if (!methodDefined) {
it.remove();
+ }
}
if (definers.isEmpty()) {
parameterDefiners.remove(Integer.valueOf(reg));
}
}
}
-
+
/**
* returns whether this exception is handled either in a try/catch or throws clause at this pc
- *
+ *
* @param ex the name of the exception
- *
+ *
* @return whether the exception is handled
*/
private boolean isExceptionHandled(String ex) {
@@ -421,8 +456,9 @@
String[] throwClauseExNames = et.getExceptionNames();
for (String throwClauseExName : throwClauseExNames) {
JavaClass throwClauseEx = Repository.lookupClass(throwClauseExName);
- if (thrownEx.instanceOf(throwClauseEx))
+ if (thrownEx.instanceOf(throwClauseEx)) {
return true;
+ }
}
}
// Next look at the try catch blocks
@@ -435,8 +471,9 @@
if (type != 0) {
String catchExName = getConstantPool().getConstantString(type, Constants.CONSTANT_Class);
JavaClass catchException = Repository.lookupClass(catchExName);
- if (thrownEx.instanceOf(catchException))
+ if (thrownEx.instanceOf(catchException)) {
return true;
+ }
}
}
}
@@ -454,66 +491,71 @@
parameterDefiners.remove(Integer.valueOf(reg));
return;
}
-
+
Map<JavaClass, List<MethodInfo>> definers = parameterDefiners.get(Integer.valueOf(reg));
if ((definers != null) && (definers.size() > 0)) {
Iterator<JavaClass> it = definers.keySet().iterator();
while (it.hasNext()) {
JavaClass definer = it.next();
- if (!definer.getClassName().equals(parmSig))
+ if (!definer.getClassName().equals(parmSig)) {
it.remove();
+ }
}
-
- if (definers.isEmpty())
+
+ if (definers.isEmpty()) {
parameterDefiners.remove(Integer.valueOf(reg));
+ }
}
}
}
-
+
public static class MethodInfo
{
private final String methodName;
private final String methodSig;
private final String[] methodExceptions;
-
+
public MethodInfo(String name, String sig, String[] excs) {
methodName = name;
methodSig = sig;
methodExceptions = excs;
}
-
+
public String getMethodName() {
return methodName;
}
-
+
public String getMethodSignature() {
return methodSig;
}
-
+
public String[] getMethodExceptions() {
return methodExceptions;
}
-
+
@Override
public int hashCode() {
return methodName.hashCode() ^ methodSig.hashCode();
}
-
+
@Override
public boolean equals(Object o) {
- if (!(o instanceof MethodInfo))
+ if (!(o instanceof MethodInfo)) {
return false;
-
+ }
+
MethodInfo that = (MethodInfo)o;
-
- if (!methodName.equals(that.methodName))
+
+ if (!methodName.equals(that.methodName)) {
return false;
- if (!methodSig.equals(that.methodSig))
+ }
+ if (!methodSig.equals(that.methodSig)) {
return false;
-
+ }
+
return true;
}
-
+
@Override
public String toString() {
return methodName + methodSig;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-04-30 19:46:33
|
Revision: 1664
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1664&view=rev
Author: dbrosius
Date: 2011-04-30 19:46:27 +0000 (Sat, 30 Apr 2011)
Log Message:
-----------
add LGO detector and sample
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
Added Paths:
-----------
trunk/fb-contrib/samples/LGO_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2011-04-26 01:55:51 UTC (rev 1663)
+++ trunk/fb-contrib/etc/findbugs.xml 2011-04-30 19:46:27 UTC (rev 1664)
@@ -220,6 +220,7 @@
<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" />
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
@@ -384,4 +385,5 @@
<BugPattern abbrev="PUS" type="PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION" category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="SEC" type="SEC_SIDE_EFFECT_CONSTRUCTOR" category="STYLE" experimental="true" />
<BugPattern abbrev="SGSU" type="SGSU_SUSPICIOUS_GETTER_SETTER_USE" category="CORRECTNESS" experimental="true" />
+ <BugPattern abbrev="LGO" type="LGO_LINGERING_GRAPHICS_OBJECT" category="PERFORMANCE" experimental="true" />
</FindbugsPlugin>
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2011-04-26 01:55:51 UTC (rev 1663)
+++ trunk/fb-contrib/etc/messages.xml 2011-04-30 19:46:27 UTC (rev 1664)
@@ -1191,6 +1191,19 @@
]]>
</Details>
</Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects">
+ <Details>
+ <![CDATA[
+ <p>This detector looks for creation of java.awt.Graphics object that do not have the
+ .dispose() method called on them when finished. These objects will be cleaned up by
+ the Garbage collector, bug given the likelyhood that large numbers of these objects can
+ be created in a short period of time, it is better to dispose them as soon as possible
+ </p>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </Detector>
<!-- BugPattern -->
@@ -3276,6 +3289,19 @@
]]>
</Details>
</BugPattern>
+
+ <BugPattern type="LGO_LINGERING_GRAPHICS_OBJECT">
+ <ShortDescription>Method allocations a java.awt.Graphics object without disposing it</ShortDescription>
+ <LongDescription>Method {1} allocations a java.awt.Graphics object without disposing it</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method allocates a java.awt.Graphics object but doesn't dispose of it when done. While
+ the garbage collecter will clean this up, given that a large number of Graphics objects can be
+ created in a short period of time, it is recommended that you explicitly dispose() of them.
+ </p>
+ ]]>
+ </Details>
+ </BugPattern>
<!-- BugCode -->
@@ -3377,4 +3403,5 @@
<BugCode abbrev="PUS">Possible Unsuspected Serialization</BugCode>
<BugCode abbrev="SEC">Side Effect Constructor</BugCode>
<BugCode abbrev="SGSU">Suspicious Getter Setter Use</BugCode>
+ <BugCode abbrev="LGO">Lingering Graphics Object</BugCode>
</MessageCollection>
Added: trunk/fb-contrib/samples/LGO_Sample.java
===================================================================
--- trunk/fb-contrib/samples/LGO_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/LGO_Sample.java 2011-04-30 19:46:27 UTC (rev 1664)
@@ -0,0 +1,27 @@
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+
+
+public class LGO_Sample {
+
+ public void testCreate(Graphics g) {
+ Graphics g2 = g.create();
+ }
+
+ public void testBufferedImage(BufferedImage bi) {
+ Graphics g = bi.getGraphics();
+ }
+
+ public void fpWasDisposed(Graphics g) {
+ Graphics g2 = g.create();
+ try {
+
+ } finally {
+ g2.dispose();
+ }
+ }
+
+ public Graphics returnG(Graphics g) {
+ return g.create();
+ }
+}
Property changes on: trunk/fb-contrib/samples/LGO_Sample.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java 2011-04-30 19:46:27 UTC (rev 1664)
@@ -0,0 +1,146 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2011 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.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.bcel.classfile.Code;
+
+import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+
+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;
+
+public class LingeringGraphicsObjects extends BytecodeScanningDetector {
+
+ private static final Set<String> GRAPHICS_PRODUCERS = new HashSet<String>();
+ static {
+ GRAPHICS_PRODUCERS.add("java/awt/image/BufferedImage#getGraphics()Ljava/awt/Graphics;");
+ GRAPHICS_PRODUCERS.add("java/awt/Graphics#create()Ljava/awt/Graphics;");
+ }
+
+ private final BugReporter bugReporter;
+ private OpcodeStack stack;
+ private Map<Integer, Integer> graphicsRegs; //reg->pc
+
+ public LingeringGraphicsObjects(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ @Override
+ public void visitClassContext(ClassContext classContext) {
+ try {
+ stack = new OpcodeStack();
+ graphicsRegs = new HashMap<Integer, Integer>();
+ super.visitClassContext(classContext);
+ } finally {
+ stack = null;
+ graphicsRegs = null;
+ }
+ }
+
+ @Override
+ public void visitCode(Code obj) {
+ stack.resetForMethodEntry(this);
+ super.visitCode(obj);
+ for (Integer pc : graphicsRegs.values()) {
+ bugReporter.reportBug(new BugInstance(this, "LGO_LINGERING_GRAPHICS_OBJECT", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this, pc.intValue()));
+ }
+
+ }
+
+ @Override
+ public void sawOpcode(int seen) {
+ Integer sawNewGraphicsAt = null;
+ try {
+ switch (seen) {
+ case ALOAD:
+ case ALOAD_0:
+ case ALOAD_1:
+ case ALOAD_2:
+ case ALOAD_3: {
+ int reg = RegisterUtils.getALoadReg(this, seen);
+ sawNewGraphicsAt = graphicsRegs.get(Integer.valueOf(reg));
+ }
+ break;
+
+ case ASTORE:
+ case ASTORE_0:
+ case ASTORE_1:
+ case ASTORE_2:
+ case ASTORE_3: {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ sawNewGraphicsAt = (Integer)item.getUserValue();
+
+ Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen));
+ if (sawNewGraphicsAt != null) {
+ graphicsRegs.put(reg, sawNewGraphicsAt);
+ } else {
+ graphicsRegs.remove(reg);
+ }
+ sawNewGraphicsAt = null;
+ }
+ }
+ break;
+
+ case ARETURN:
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ graphicsRegs.remove(Integer.valueOf(item.getRegisterNumber()));
+ }
+ break;
+
+ case INVOKEVIRTUAL:
+ String clsName = getClassConstantOperand();
+ String methodName = getNameConstantOperand();
+ String methodSig = getSigConstantOperand();
+ String methodInfo = clsName + "#" + methodName + methodSig;
+ if (GRAPHICS_PRODUCERS.contains(methodInfo)) {
+ sawNewGraphicsAt = Integer.valueOf(getPC());
+ } else {
+ if ("java/awt/Graphics#dispose()V".equals(methodInfo)) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ graphicsRegs.remove(Integer.valueOf(item.getRegisterNumber()));
+ }
+ }
+ }
+ break;
+ }
+ } finally {
+ stack.sawOpcode(this, seen);
+ if (sawNewGraphicsAt != null) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ item.setUserValue(sawNewGraphicsAt);
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-06-11 16:51:43
|
Revision: 1677
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1677&view=rev
Author: dbrosius
Date: 2011-06-11 16:51:36 +0000 (Sat, 11 Jun 2011)
Log Message:
-----------
prepare for the 4.6.1 release
Modified Paths:
--------------
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/pom.xml
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2011-06-11 03:20:19 UTC (rev 1676)
+++ trunk/fb-contrib/build.xml 2011-06-11 16:51:36 UTC (rev 1677)
@@ -20,7 +20,7 @@
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
- <property name="fb-contrib.version" value="4.7.0"/>
+ <property name="fb-contrib.version" value="4.6.1"/>
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2011-06-11 03:20:19 UTC (rev 1676)
+++ trunk/fb-contrib/etc/findbugs.xml 2011-06-11 16:51:36 UTC (rev 1677)
@@ -133,9 +133,9 @@
<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" />
-
+<!--
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
-
+ -->
<Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" />
@@ -219,8 +219,10 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SideEffectConstructor" speed="fast" reports="SEC_SIDE_EFFECT_CONSTRUCTOR" />
<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" />
+-->
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
Modified: trunk/fb-contrib/pom.xml
===================================================================
--- trunk/fb-contrib/pom.xml 2011-06-11 03:20:19 UTC (rev 1676)
+++ trunk/fb-contrib/pom.xml 2011-06-11 16:51:36 UTC (rev 1677)
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
- <version>4.7.0-SNAPSHOT</version>
+ <version>4.6.1</version>
<parent>
<groupId>org.sonatype.oss</groupId>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-06-11 18:54:34
|
Revision: 1679
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1679&view=rev
Author: dbrosius
Date: 2011-06-11 18:54:28 +0000 (Sat, 11 Jun 2011)
Log Message:
-----------
go back to development (4.7.0)
Modified Paths:
--------------
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/pom.xml
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2011-06-11 16:54:54 UTC (rev 1678)
+++ trunk/fb-contrib/build.xml 2011-06-11 18:54:28 UTC (rev 1679)
@@ -20,7 +20,7 @@
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
- <property name="fb-contrib.version" value="4.6.1"/>
+ <property name="fb-contrib.version" value="4.7.0"/>
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2011-06-11 16:54:54 UTC (rev 1678)
+++ trunk/fb-contrib/etc/findbugs.xml 2011-06-11 18:54:28 UTC (rev 1679)
@@ -133,9 +133,9 @@
<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" />
-<!--
+
<Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" />
- -->
+
<Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" />
<Detector class="com.mebigfatguy.fbcontrib.detect.DeletingWhileIterating" speed="fast" reports="DWI_DELETING_WHILE_ITERATING,DWI_MODIFYING_WHILE_ITERATING" />
@@ -219,10 +219,10 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.SideEffectConstructor" speed="fast" reports="SEC_SIDE_EFFECT_CONSTRUCTOR" />
<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" />
--->
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
Modified: trunk/fb-contrib/pom.xml
===================================================================
--- trunk/fb-contrib/pom.xml 2011-06-11 16:54:54 UTC (rev 1678)
+++ trunk/fb-contrib/pom.xml 2011-06-11 18:54:28 UTC (rev 1679)
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
- <version>4.6.1</version>
+ <version>4.7.0</version>
<parent>
<groupId>org.sonatype.oss</groupId>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-06-13 06:45:57
|
Revision: 1688
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1688&view=rev
Author: dbrosius
Date: 2011-06-13 06:45:45 +0000 (Mon, 13 Jun 2011)
Log Message:
-----------
initial stub in of STB - non functional
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
Added Paths:
-----------
trunk/fb-contrib/samples/STB_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2011-06-13 05:07:07 UTC (rev 1687)
+++ trunk/fb-contrib/etc/findbugs.xml 2011-06-13 06:45:45 UTC (rev 1688)
@@ -222,6 +222,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" />
+ <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" />
<!-- BugPattern -->
@@ -388,4 +389,5 @@
<BugPattern abbrev="SEC" type="SEC_SIDE_EFFECT_CONSTRUCTOR" category="STYLE" experimental="true" />
<BugPattern abbrev="SGSU" type="SGSU_SUSPICIOUS_GETTER_SETTER_USE" category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="LGO" type="LGO_LINGERING_GRAPHICS_OBJECT" category="PERFORMANCE" experimental="true" />
+ <BugPattern abbrev="STB" type="STB_STACKED_TRY_BLOCKS" category="STYLE" experimental="true" />
</FindbugsPlugin>
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2011-06-13 05:07:07 UTC (rev 1687)
+++ trunk/fb-contrib/etc/messages.xml 2011-06-13 06:45:45 UTC (rev 1688)
@@ -1204,6 +1204,18 @@
]]>
</Details>
</Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks">
+ <Details>
+ <![CDATA[
+ <p>This detector looks for two or more try catch blocks that are consecutive
+ and catch the same kind of exception, and each catch block mandatorily throws
+ the same exception. These two catch blocks can and should be made into one
+ catch block to simply the code.</p>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </Detector>
<!-- BugPattern -->
@@ -3302,6 +3314,19 @@
]]>
</Details>
</BugPattern>
+
+ <BugPattern type="STB_STACKED_TRY_BLOCKS">
+ <ShortDescription>Method stacks similar try/catch blocks</ShortDescription>
+ <LongDescription>Method {1} stacks similar try/catch blocks</LongDescription>
+ <Details>
+ <![CDATA[
+ <P>This method declares two try catch blocks one after another, where each
+ catch block catches the same type of exception. They also throw uniformly the
+ same type of exception. These two catch blocks can be combined into one to
+ simplify the method.</p>
+ ]]>
+ </Details>
+ </BugPattern>
<!-- BugCode -->
@@ -3404,4 +3429,5 @@
<BugCode abbrev="SEC">Side Effect Constructor</BugCode>
<BugCode abbrev="SGSU">Suspicious Getter Setter Use</BugCode>
<BugCode abbrev="LGO">Lingering Graphics Object</BugCode>
+ <BugCode abbrev="STB">Stacked Catch Blocks</BugCode>
</MessageCollection>
Added: trunk/fb-contrib/samples/STB_Sample.java
===================================================================
--- trunk/fb-contrib/samples/STB_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/STB_Sample.java 2011-06-13 06:45:45 UTC (rev 1688)
@@ -0,0 +1,23 @@
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class STB_Sample {
+ public void testSTB(File f1, File f2) throws STBException {
+ try {
+ InputStream is = new FileInputStream(f1);
+ } catch (IOException ioe) {
+ throw new STBException();
+ }
+
+ try {
+ InputStream is = new FileInputStream(f2);
+ } catch (IOException ioe) {
+ throw new STBException();
+ }
+ }
+
+ static class STBException extends Exception {
+ }
+}
Property changes on: trunk/fb-contrib/samples/STB_Sample.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2011-06-13 06:45:45 UTC (rev 1688)
@@ -0,0 +1,165 @@
+package com.mebigfatguy.fbcontrib.detect;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.CodeException;
+
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.BytecodeScanningDetector;
+
+/**
+ * looks for two or more try catch blocks that are consecutive and catch the
+ * same kind of exception, and throw the same exception always. These blocks can
+ * be coalesced into one.
+ */
+
+public class StackedTryBlocks extends BytecodeScanningDetector {
+
+ private final BugReporter bugReporter;
+ private Map<TryBlock, TryBlock> blocks;
+ private List<TryBlock> inBlocks;
+
+ public StackedTryBlocks(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ @Override
+ public void visitCode(Code obj) {
+
+ try {
+ blocks = new HashMap<TryBlock, TryBlock>();
+ inBlocks = new ArrayList<TryBlock>();
+
+ CodeException[] ces = obj.getExceptionTable();
+ for (CodeException ce : ces) {
+ TryBlock tb = new TryBlock(ce);
+ TryBlock block = blocks.get(tb);
+ if (block != null) {
+ block.addCatchType(ce);
+ } else {
+ blocks.put(tb, tb);
+ }
+ }
+
+ Iterator<TryBlock> it = blocks.keySet().iterator();
+ int numSingleCatchBlocks = 0;
+ while (it.hasNext()) {
+ if (!it.next().hasMultipleHandlers()) {
+ numSingleCatchBlocks++;
+ }
+ }
+
+ if (numSingleCatchBlocks > 1) {
+ super.visitCode(obj);
+ }
+ } finally {
+ blocks = null;
+ inBlocks = null;
+ }
+ }
+
+ @Override
+ public void sawOpcode(int seen) {
+
+ TryBlock block = findBlockWithStart();
+ if (block != null) {
+ inBlocks.add(block);
+ }
+
+ if (inBlocks.size() > 0) {
+ int nextPC = getNextPC();
+ TryBlock innerBlock = inBlocks.get(inBlocks.size() - 1);
+ if (nextPC == innerBlock.getHandlerPC()) {
+ if ((seen == GOTO) || (seen == GOTO_W)) {
+ innerBlock.setEndHandlerPC(getBranchTarget());
+ } else {
+ innerBlock.setEndHandlerPC(getCode().getLength());
+ }
+ }
+ }
+
+ }
+
+ private TryBlock findBlockWithStart() {
+
+ int pc = getPC();
+
+ for (TryBlock block : blocks.keySet()) {
+ if (block.getStartPC() == pc) {
+ return block;
+ }
+ }
+
+ return null;
+ }
+
+ static class TryBlock {
+ int startPC;
+ int endPC;
+ int handlerPC;
+ int endHandlerPC;
+ BitSet catchTypes;
+ int throwType;
+
+ public TryBlock(CodeException ce) {
+ startPC = ce.getStartPC();
+ endPC = ce.getEndPC();
+ handlerPC = ce.getHandlerPC();
+ catchTypes = new BitSet();
+ catchTypes.set(ce.getCatchType());
+ }
+
+ public void addCatchType(CodeException ce) {
+ catchTypes.set(ce.getCatchType());
+ }
+
+ public boolean hasMultipleHandlers() {
+ int bit = catchTypes.nextSetBit(0);
+ return catchTypes.nextSetBit(bit + 1) >= 0;
+ }
+
+ public void setEndHandlerPC(int end) {
+ endHandlerPC = end;
+ }
+
+ public void setThrowType(int type) {
+ throwType = type;
+ }
+
+ public int getStartPC() {
+ return startPC;
+ }
+
+ public int getHandlerPC() {
+ return handlerPC;
+ }
+
+ @Override
+ public int hashCode() {
+ return startPC ^ endPC;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof TryBlock) {
+ TryBlock that = (TryBlock) o;
+ return (startPC == that.startPC) && (endPC == that.endPC);
+ }
+
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + startPC + " -> " + endPC + "} (catch "
+ + catchTypes.get(0) + ") {" + handlerPC + " -> "
+ + endHandlerPC + "}";
+ }
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-07-02 03:47:01
|
Revision: 1694
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1694&view=rev
Author: dbrosius
Date: 2011-07-02 03:46:55 +0000 (Sat, 02 Jul 2011)
Log Message:
-----------
ignore STBs when the method declares throwing the same exception type as is caught
Modified Paths:
--------------
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/samples/STB_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2011-07-02 03:46:18 UTC (rev 1693)
+++ trunk/fb-contrib/etc/messages.xml 2011-07-02 03:46:55 UTC (rev 1694)
@@ -3429,5 +3429,5 @@
<BugCode abbrev="SEC">Side Effect Constructor</BugCode>
<BugCode abbrev="SGSU">Suspicious Getter Setter Use</BugCode>
<BugCode abbrev="LGO">Lingering Graphics Object</BugCode>
- <BugCode abbrev="STB">Stacked Catch Blocks</BugCode>
+ <BugCode abbrev="STB">Stacked Try Blocks</BugCode>
</MessageCollection>
Modified: trunk/fb-contrib/samples/STB_Sample.java
===================================================================
--- trunk/fb-contrib/samples/STB_Sample.java 2011-07-02 03:46:18 UTC (rev 1693)
+++ trunk/fb-contrib/samples/STB_Sample.java 2011-07-02 03:46:55 UTC (rev 1694)
@@ -18,6 +18,20 @@
}
}
+ public void fpTestMethodDeclaresThrownType(File f1, File f2) throws STBException, IOException {
+ try {
+ InputStream is = new FileInputStream(f1);
+ } catch (IOException ioe) {
+ throw new STBException();
+ }
+
+ try {
+ InputStream is = new FileInputStream(f2);
+ } catch (IOException ioe) {
+ throw new STBException();
+ }
+ }
+
static class STBException extends Exception {
}
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2011-07-02 03:46:18 UTC (rev 1693)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2011-07-02 03:46:55 UTC (rev 1694)
@@ -1,19 +1,25 @@
package com.mebigfatguy.fbcontrib.detect;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.BitSet;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.CodeException;
+import org.apache.bcel.classfile.ConstantClass;
+import org.apache.bcel.classfile.ConstantPool;
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;
+import edu.umd.cs.findbugs.ba.XMethod;
/**
* looks for two or more try catch blocks that are consecutive and catch the
@@ -46,6 +52,11 @@
public void visitCode(Code obj) {
try {
+ XMethod xMethod = getXMethod();
+ String[] tes = xMethod.getThrownExceptions();
+ Set<String> thrownExceptions = new HashSet<String>(Arrays.<String> asList((tes == null) ? new String[0]
+ : tes));
+
blocks = new ArrayList<TryBlock>();
inBlocks = new ArrayList<TryBlock>();
@@ -64,7 +75,8 @@
Iterator<TryBlock> it = blocks.iterator();
while (it.hasNext()) {
TryBlock block = it.next();
- if (block.hasMultipleHandlers() || block.isFinally()) {
+ if (block.hasMultipleHandlers() || block.isFinally()
+ || block.catchIsThrown(getConstantPool(), thrownExceptions)) {
it.remove();
}
}
@@ -78,20 +90,12 @@
for (int i = 1; i < blocks.size(); i++) {
TryBlock secondBlock = blocks.get(i);
- if ((firstBlock.getCatchType() == secondBlock
- .getCatchType())
- && (firstBlock.getThrowSignature()
- .equals(secondBlock.getThrowSignature()))) {
- bugReporter.reportBug(new BugInstance(this,
- "STB_STACKED_TRY_BLOCKS", NORMAL_PRIORITY)
- .addClass(this)
- .addMethod(this)
- .addSourceLineRange(this,
- firstBlock.getStartPC(),
- firstBlock.getEndHandlerPC())
- .addSourceLineRange(this,
- secondBlock.getStartPC(),
- secondBlock.getEndHandlerPC()));
+ if ((firstBlock.getCatchType() == secondBlock.getCatchType())
+ && (firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature()))) {
+ bugReporter.reportBug(new BugInstance(this, "STB_STACKED_TRY_BLOCKS", NORMAL_PRIORITY)
+ .addClass(this).addMethod(this)
+ .addSourceLineRange(this, firstBlock.getStartPC(), firstBlock.getEndHandlerPC())
+ .addSourceLineRange(this, secondBlock.getStartPC(), secondBlock.getEndHandlerPC()));
}
@@ -136,8 +140,7 @@
if (innerBlock.inCatch()) {
if (((seen >= Constants.IFEQ) && ((seen <= Constants.RET)))
- || ((seen >= Constants.IRETURN) && (seen <= Constants.RETURN))
- || (seen == GOTO_W)) {
+ || ((seen >= Constants.IRETURN) && (seen <= Constants.RETURN)) || (seen == GOTO_W)) {
blocks.remove(innerBlock);
inBlocks.remove(inBlocks.size() - 1);
} else if (seen == ATHROW) {
@@ -212,6 +215,15 @@
return catchTypes.get(0);
}
+ public boolean catchIsThrown(ConstantPool pool, Set<String> thrownExceptions) {
+ if (thrownExceptions.size() > 0) {
+ int exIndex = catchTypes.nextSetBit(0);
+ String exName = ((ConstantClass) pool.getConstant(exIndex)).getBytes(pool);
+ return thrownExceptions.contains(exName);
+ }
+ return false;
+ }
+
public void setEndHandlerPC(int end) {
endHandlerPC = end;
}
@@ -221,8 +233,7 @@
}
public String getThrowSignature() {
- return (throwSig == null) ? String.valueOf(System
- .identityHashCode(this)) : throwSig;
+ return (throwSig == null) ? String.valueOf(System.identityHashCode(this)) : throwSig;
}
public int getStartPC() {
@@ -266,8 +277,7 @@
@Override
public String toString() {
- return "{" + startPC + " -> " + endPC + "} (catch "
- + catchTypes.nextSetBit(0) + ") {" + handlerPC + " -> "
+ return "{" + startPC + " -> " + endPC + "} (catch " + catchTypes.nextSetBit(0) + ") {" + handlerPC + " -> "
+ endHandlerPC + "}";
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-07-05 00:44:33
|
Revision: 1699
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1699&view=rev
Author: dbrosius
Date: 2011-07-05 00:44:27 +0000 (Tue, 05 Jul 2011)
Log Message:
-----------
add S508C_APPENDED_STRING bug pattern
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
trunk/fb-contrib/samples/S508C_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2011-07-04 23:47:34 UTC (rev 1698)
+++ trunk/fb-contrib/etc/findbugs.xml 2011-07-05 00:44:27 UTC (rev 1699)
@@ -103,7 +103,7 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.NonRecycleableTaglibs" speed="fast" reports="NRTL_NON_RECYCLEABLE_TAG_LIB" />
<Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance" speed="fast"
- reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT,S508C_SET_COMP_COLOR,S508C_NON_TRANSLATABLE_STRING" />
+ reports="S508C_NULL_LAYOUT,S508C_NO_SETLABELFOR,S508C_NO_SETSIZE,S508C_NON_ACCESSIBLE_JCOMPONENT,S508C_SET_COMP_COLOR,S508C_NON_TRANSLATABLE_STRING,S508C_APPENDED_STRING" />
<Detector class="com.mebigfatguy.fbcontrib.detect.UseEnumCollections" speed="fast" reports="UEC_USE_ENUM_COLLECTIONS" />
@@ -282,6 +282,7 @@
<BugPattern abbrev="S508C" type="S508C_NON_ACCESSIBLE_JCOMPONENT" category="CORRECTNESS" />
<BugPattern abbrev="S508C" type="S508C_SET_COMP_COLOR" category="CORRECTNESS" />
<BugPattern abbrev="S508C" type="S508C_NON_TRANSLATABLE_STRING" category="CORRECTNESS" />
+ <BugPattern abbrev="S508C" type="S508C_APPENDED_STRING" category="CORRECTNESS" />
<BugPattern abbrev="UEC" type="UEC_USE_ENUM_COLLECTIONS" category="PERFORMANCE" />
<BugPattern abbrev="SIL" type="SIL_SQL_IN_LOOP" category="PERFORMANCE" />
<BugPattern abbrev="NMCS" type="NMCS_NEEDLESS_MEMBER_COLLECTION_SYNCHRONIZATION" category="PERFORMANCE" />
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2011-07-04 23:47:34 UTC (rev 1698)
+++ trunk/fb-contrib/etc/messages.xml 2011-07-05 00:44:27 UTC (rev 1699)
@@ -1975,6 +1975,18 @@
]]>
</Details>
</BugPattern>
+
+ <BugPattern type="S508C_APPENDED_STRING">
+ <ShortDescription>Method passes appended string to title/label of component</ShortDescription>
+ <LongDescription>Method {1} passes appended string to title/label of component</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method creates a component and passes a string that was build up from a number of
+ strings through appending multiple strings together. As foreign languages may order phrases
+ differently, this will make translations difficult.</p>
+ ]]>
+ </Details>
+ </BugPattern>
<BugPattern type="UEC_USE_ENUM_COLLECTIONS">
<ShortDescription>Class uses an ordinary set or map with an enum class as the key</ShortDescription>
Modified: trunk/fb-contrib/samples/S508C_Sample.java
===================================================================
--- trunk/fb-contrib/samples/S508C_Sample.java 2011-07-04 23:47:34 UTC (rev 1698)
+++ trunk/fb-contrib/samples/S508C_Sample.java 2011-07-05 00:44:27 UTC (rev 1699)
@@ -35,6 +35,11 @@
JLabel l = new JLabel("Hello");
JFrame f = new JFrame("foo");
}
+
+ public void testAppending(String greeting, String user)
+ {
+ JLabel l = new JLabel(greeting + " " + user);
+ }
}
class MyComponent extends JComponent
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-07-04 23:47:34 UTC (rev 1698)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-07-05 00:44:27 UTC (rev 1699)
@@ -49,6 +49,7 @@
{
private static final String SAW_TEXT_LABEL = "SAW_TEXT_LABEL";
private static final String FROM_UIMANAGER = "FROM_UIMANAGER";
+ private static final String APPENDED_STRING = "APPENDED_STRING";
private static JavaClass windowClass;
private static JavaClass componentClass;
@@ -204,6 +205,7 @@
public void sawOpcode(int seen) {
boolean sawTextLabel = false;
boolean sawUIManager = false;
+ boolean sawAppend = false;
try {
stack.mergeJumps(this);
if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) {
@@ -252,6 +254,17 @@
}
}
}
+ } else if ("java/lang/StringBuffer".equals(className) || "java/lang/StringBuilder".equals(className)) {
+ if ("append".equals(methodName)) {
+ sawAppend = true;
+ } else if ("toString".equals(methodName)) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ if (APPENDED_STRING.equals(item.getUserValue())) {
+ sawAppend = true;
+ }
+ }
+ }
}
processSetSizeOps(methodName);
@@ -264,7 +277,7 @@
}
if ((seen == INVOKEVIRTUAL) || (seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE)) {
- processUntranslatableStrings();
+ processFaultyGuiStrings();
}
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
@@ -280,14 +293,21 @@
OpcodeStack.Item item = stack.getStackItem(0);
item.setUserValue(FROM_UIMANAGER);
}
+ } else if (sawAppend) {
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ item.setUserValue(APPENDED_STRING);
+ }
}
}
}
/**
- * looks for calls to set a readable string that is generated from a static constant.
+ * looks for calls to set a readable string that is generated from a static constant, as these strings
+ * are not translatable. also looks for setting readable strings that are appended together. This is
+ * likely not to be internationalizable.
*/
- private void processUntranslatableStrings() {
+ private void processFaultyGuiStrings() {
StringBuilder methodInfo = new StringBuilder();
methodInfo.append(getClassConstantOperand());
methodInfo.append("#");
@@ -304,6 +324,12 @@
.addClass(this)
.addMethod(this)
.addSourceLine(this));
+ } else if (APPENDED_STRING.equals(item.getUserValue())) {
+ bugReporter.reportBug(new BugInstance(this, "S508C_APPENDED_STRING", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-07-07 04:25:50
|
Revision: 1700
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1700&view=rev
Author: dbrosius
Date: 2011-07-07 04:25:40 +0000 (Thu, 07 Jul 2011)
Log Message:
-----------
allow for appended strings passed to a component, if the appended string looks like an html fragment
Modified Paths:
--------------
trunk/fb-contrib/samples/S508C_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
Modified: trunk/fb-contrib/samples/S508C_Sample.java
===================================================================
--- trunk/fb-contrib/samples/S508C_Sample.java 2011-07-05 00:44:27 UTC (rev 1699)
+++ trunk/fb-contrib/samples/S508C_Sample.java 2011-07-07 04:25:40 UTC (rev 1700)
@@ -40,6 +40,11 @@
{
JLabel l = new JLabel(greeting + " " + user);
}
+
+ public void fpAppending(String greeting)
+ {
+ JLabel l = new JLabel("<html><body>" + greeting + "</body></html>");
+ }
}
class MyComponent extends JComponent
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-07-05 00:44:27 UTC (rev 1699)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2011-07-07 04:25:40 UTC (rev 1700)
@@ -25,6 +25,7 @@
import org.apache.bcel.Repository;
import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.ConstantString;
import org.apache.bcel.classfile.Field;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.generic.Type;
@@ -256,7 +257,16 @@
}
} else if ("java/lang/StringBuffer".equals(className) || "java/lang/StringBuilder".equals(className)) {
if ("append".equals(methodName)) {
- sawAppend = true;
+ if (stack.getStackDepth() > 0) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ Object con = item.getConstant();
+ if (con instanceof String) {
+ String literal = (String)con;
+ sawAppend = !literal.startsWith("<");
+ } else {
+ sawAppend = true;
+ }
+ }
} else if ("toString".equals(methodName)) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-11-23 00:17:07
|
Revision: 1706
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1706&view=rev
Author: dbrosius
Date: 2011-11-23 00:17:01 +0000 (Wed, 23 Nov 2011)
Log Message:
-----------
changes from git repository
Modified Paths:
--------------
trunk/fb-contrib/samples/WOC_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
Modified: trunk/fb-contrib/samples/WOC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/WOC_Sample.java 2011-10-14 05:34:15 UTC (rev 1705)
+++ trunk/fb-contrib/samples/WOC_Sample.java 2011-11-23 00:17:01 UTC (rev 1706)
@@ -17,10 +17,7 @@
private final Set<String> memberSet = new HashSet<String>();
private Set<String> fpSet;
private final List<String> fpList = new ArrayList<String>();
- private final Set<String> fpMergeSet = new HashSet<String>(fpSet);
- private boolean abug = true;
-
public void testWOCSimple()
{
Set<String> s = new HashSet<String>();
@@ -104,13 +101,4 @@
{
return ws.fpList;
}
-
- public void fpMergeListWOC()
- {
- caller(fpMergeSet, !abug);
- }
-
- private void caller(Set<String> set, boolean b)
- {
- }
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2011-10-14 05:34:15 UTC (rev 1705)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2011-11-23 00:17:01 UTC (rev 1706)
@@ -314,6 +314,15 @@
ScopeBlock sb = findScopeBlock(rootScopeBlock, getPC());
if (sb != null)
{
+ ScopeBlock parentSB = sb.getParent();
+ while (parentSB != null) {
+ if (parentSB.getStart() >= target) {
+ sb = parentSB;
+ parentSB = parentSB.getParent();
+ } else {
+ break;
+ }
+ }
sb.setLoop();
}
}
@@ -651,7 +660,7 @@
if (children != null) {
for (ScopeBlock child : children) {
- if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation < child.finishLocation)) {
+ if ((newChild.startLocation > child.startLocation) && (newChild.finishLocation <= child.finishLocation)) {
child.addChild(newChild);
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2012-01-16 02:50:29
|
Revision: 1709
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1709&view=rev
Author: dbrosius
Date: 2012-01-16 02:50:18 +0000 (Mon, 16 Jan 2012)
Log Message:
-----------
update from github
Modified Paths:
--------------
trunk/fb-contrib/.classpath
trunk/fb-contrib/build.xml
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FinalParameters.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ImproperPropertiesUse.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonCollectionMethodUse.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonFunctionalField.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ParallelLists.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossibleUnsuspectedSerialization.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SQLInLoop.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SluggishGui.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SpuriousThreadStates.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TailRecursion.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/TristateBooleanPattern.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseAddAll.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseSplit.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseToArray.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/MapEntry.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/VersionTransition.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/XClassUtils.java
Modified: trunk/fb-contrib/.classpath
===================================================================
--- trunk/fb-contrib/.classpath 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/.classpath 2012-01-16 02:50:18 UTC (rev 1709)
@@ -5,18 +5,15 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="lib" path="lib/annotations.jar"/>
- <classpathentry kind="lib" path="lib/asm-3.1.jar"/>
- <classpathentry kind="lib" path="lib/asm-tree-3.1.jar"/>
- <classpathentry kind="lib" path="lib/bcel.jar"/>
- <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
- <classpathentry kind="lib" path="lib/findbugs-ant.jar"/>
- <classpathentry kind="lib" path="lib/findbugs.jar" sourcepath="/findbugs"/>
- <classpathentry kind="lib" path="lib/jsr305.jar"/>
<classpathentry kind="lib" path="samples/lib/jsp-api.jar"/>
<classpathentry kind="lib" path="samples/lib/junit.jar"/>
<classpathentry kind="lib" path="samples/lib/log4j.jar" sourcepath="/home/dave/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15-sources.jar"/>
<classpathentry kind="lib" path="samples/lib/servlet-api.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/findbugs"/>
+ <classpathentry kind="lib" path="lib/bcel-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/findbugs-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/jsr305-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/annotations-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/build.xml 2012-01-16 02:50:18 UTC (rev 1709)
@@ -21,6 +21,16 @@
<property name="javac.debug" value="on"/>
<property name="fb-contrib.version" value="4.7.0"/>
+
+ <property name="findbugs.version" value="2.0.0"/>
+ <property name="findbugs-bcel.version" value="2.0.0"/>
+ <property name="annotations.version" value="2.0.0"/>
+ <property name="asm-tree.version" value="3.3.1"/>
+
+ <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar"/>
+ <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar"/>
+ <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar"/>
+ <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar"/>
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
@@ -37,11 +47,14 @@
</target>
<target name="-init" description="prepares repository for a build">
+ <mkdir dir="${lib.dir}"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${javadoc.dir}"/>
<path id="fb-contrib.classpath">
- <pathelement location="${lib.dir}/findbugs.jar"/>
- <pathelement location="${lib.dir}/bcel.jar"/>
+ <pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar"/>
+ <pathelement location="${lib.dir}/bcel-${findbugs-bcel.version}.jar"/>
+ <pathelement location="${lib.dir}/annotations-${annotations.version}.jar"/>
+ <pathelement location="${lib.dir}/asm-tree-${asm-tree.version}.jar"/>
</path>
<path id="fb-contrib.samples.classpath">
<pathelement location="${sampleslib.dir}/jsp-api.jar"/>
@@ -55,7 +68,41 @@
<mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib/detect"/>
<echo message="*.class" file="${classes.dir}/com/mebigfatguy/fbcontrib/detect/.cvsignore"/>
</target>
+
+ <target name="findbugs-check">
+ <available file="${basedir}/lib/findbugs-${findbugs.version}.jar" property="findbugs-exists"/>
+ </target>
+ <target name="findbugs-bcel-check">
+ <available file="${basedir}/lib/bcel-${findbugs-bcel.version}.jar" property="findbugs-bcel-exists"/>
+ </target>
+
+ <target name="annotations-check">
+ <available file="${basedir}/lib/annotations-${annotations.version}.jar" property="annotations-exists"/>
+ </target>
+
+ <target name="asm-tree-check">
+ <available file="${basedir}/lib/asm-tree-${asm-tree.version}.jar" property="asm-tree-exists"/>
+ </target>
+
+ <target name="install-findbugs" depends="findbugs-check" unless="findbugs-exists" description="installs findbugs.jar into lib">
+ <get src="${findbugs-url}" dest="${basedir}/lib/findbugs-${findbugs.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="install-findbugs-bcel" depends="findbugs-bcel-check" unless="findbugs-bcel-exists" description="installs findbugs-bcel.jar into lib">
+ <get src="${findbugs-bcel-url}" dest="${basedir}/lib/bcel-${findbugs-bcel.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="install-annotations" depends="annotations-check" unless="annotations-exists" description="installs annotations.jar into lib">
+ <get src="${annotations-url}" dest="${basedir}/lib/annotations-${annotations.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="install-asm-tree" depends="asm-tree-check" unless="asm-tree-exists" description="installs asm-tree.jar into lib">
+ <get src="${asm-tree-url}" dest="${basedir}/lib/asm-tree-${asm-tree.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="pull" depends="install-findbugs, install-findbugs-bcel, install-annotations, install-asm-tree" description="pull 3rdparty jars to the lib directory"/>
+
<target name="validate_xml" depends="-init" description="validates the xml files">
<xmlvalidate lenient="false" failonerror="yes">
<attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
@@ -64,7 +111,7 @@
</xmlvalidate>
</target>
- <target name="compile" depends="-init" description="compiles java files">
+ <target name="compile" depends="-init, pull" description="compiles java files">
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
source="${javac.source}"
@@ -159,7 +206,7 @@
destdir="${javadoc.dir}"
windowtitle="fb-contrib api">
<doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle>
- <bottom><![CDATA[<i>Copyright © 2005-2011 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
+ <bottom><![CDATA[<i>Copyright © 2005-2012 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/FBContrib.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/Statistics.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2011 Bhaskar Maddala
+ * Copyright (C) 2012 Bhaskar Maddala
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java 2012-01-16 02:45:44 UTC (rev 1708)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DateComparison.java 2012-01-16 02:50:18 UTC (rev 1709)
@@ -1,6 +1,6 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
- * Copyright (C) 2005-2011 Dave Brosius
+ * Copyright (C) 2005-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeclaredRuntimeException.java
=========================================...
[truncated message content] |
|
From: <dbr...@us...> - 2012-01-21 03:02:15
|
Revision: 1710
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1710&view=rev
Author: dbrosius
Date: 2012-01-21 03:02:07 +0000 (Sat, 21 Jan 2012)
Log Message:
-----------
pull in changes from github
Modified Paths:
--------------
trunk/fb-contrib/.classpath
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/bugrank.txt
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
Added Paths:
-----------
trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java
trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java
Modified: trunk/fb-contrib/.classpath
===================================================================
--- trunk/fb-contrib/.classpath 2012-01-16 02:50:18 UTC (rev 1709)
+++ trunk/fb-contrib/.classpath 2012-01-21 03:02:07 UTC (rev 1710)
@@ -1,19 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="samples"/>
<classpathentry excluding="**/*.*" kind="src" path="etc"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="samples"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="lib" path="samples/lib/jsp-api.jar"/>
- <classpathentry kind="lib" path="samples/lib/junit.jar"/>
- <classpathentry kind="lib" path="samples/lib/log4j.jar" sourcepath="/home/dave/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15-sources.jar"/>
- <classpathentry kind="lib" path="samples/lib/servlet-api.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/>
- <classpathentry kind="lib" path="lib/bcel-2.0.0.jar"/>
- <classpathentry kind="lib" path="lib/findbugs-2.0.0.jar"/>
- <classpathentry kind="lib" path="lib/jsr305-2.0.0.jar"/>
<classpathentry kind="lib" path="lib/annotations-2.0.0.jar"/>
<classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/>
+ <classpathentry kind="lib" path="lib/bcel-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/findbugs-2.0.0.jar"/>
+ <classpathentry kind="lib" path="samples/lib/commons-lang3-3.1.jar"/>
+ <classpathentry kind="lib" path="samples/lib/jsp-api-2.2.1.jar"/>
+ <classpathentry kind="lib" path="samples/lib/junit-4.10.jar"/>
+ <classpathentry kind="lib" path="samples/lib/log4j-1.2.16.jar"/>
+ <classpathentry kind="lib" path="samples/lib/servlet-api-3.0.1.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2012-01-16 02:50:18 UTC (rev 1709)
+++ trunk/fb-contrib/build.xml 2012-01-21 03:02:07 UTC (rev 1710)
@@ -27,11 +27,24 @@
<property name="annotations.version" value="2.0.0"/>
<property name="asm-tree.version" value="3.3.1"/>
- <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar"/>
- <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar"/>
- <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar"/>
- <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar"/>
+ <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar"/>
+ <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar"/>
+ <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar"/>
+ <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar"/>
+ <!-- properties for samples lib dependencies -->
+ <property name="commons-lang3.version" value="3.1"/>
+ <property name="jsp-api.version" value="2.2.1" />
+ <property name="junit.version" value="4.10" />
+ <property name="log4j.version" value="1.2.16" />
+ <property name="servlet-api.version" value="3.0.1" />
+
+ <property name="commons-lang3-url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.jar"/>
+ <property name="jsp-api-url" value="http://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/${jsp-api.version}/javax.servlet.jsp-api-${jsp-api.version}.jar" />
+ <property name="junit-url" value="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar"/>
+ <property name="log4j-url" value="http://repo1.maven.org/maven2/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar"/>
+ <property name="servlet-api-url" value="http://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/${servlet-api.version}/javax.servlet-api-${servlet-api.version}.jar"/>
+
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
<delete dir="${javadoc.dir}"/>
@@ -48,6 +61,7 @@
<target name="-init" description="prepares repository for a build">
<mkdir dir="${lib.dir}"/>
+ <mkdir dir="${sampleslib.dir}"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${javadoc.dir}"/>
<path id="fb-contrib.classpath">
@@ -57,10 +71,11 @@
<pathelement location="${lib.dir}/asm-tree-${asm-tree.version}.jar"/>
</path>
<path id="fb-contrib.samples.classpath">
- <pathelement location="${sampleslib.dir}/jsp-api.jar"/>
- <pathelement location="${sampleslib.dir}/junit.jar"/>
- <pathelement location="${sampleslib.dir}/servlet-api.jar"/>
- <pathelement location="${sampleslib.dir}/log4j.jar"/>
+ <pathelement location="${sampleslib.dir}/jsp-api-${jsp-api.version}.jar"/>
+ <pathelement location="${sampleslib.dir}/junit-${junit.version}.jar"/>
+ <pathelement location="${sampleslib.dir}/servlet-api-${servlet-api.version}.jar"/>
+ <pathelement location="${sampleslib.dir}/log4j-${log4j.version}.jar"/>
+ <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar"/>
</path>
<mkdir dir="${classes.dir}/com"/>
<mkdir dir="${classes.dir}/com/mebigfatguy"/>
@@ -69,26 +84,46 @@
<echo message="*.class" file="${classes.dir}/com/mebigfatguy/fbcontrib/detect/.cvsignore"/>
</target>
- <target name="findbugs-check">
+ <target name="findbugs-check">
<available file="${basedir}/lib/findbugs-${findbugs.version}.jar" property="findbugs-exists"/>
</target>
- <target name="findbugs-bcel-check">
+ <target name="findbugs-bcel-check">
<available file="${basedir}/lib/bcel-${findbugs-bcel.version}.jar" property="findbugs-bcel-exists"/>
</target>
- <target name="annotations-check">
+ <target name="annotations-check">
<available file="${basedir}/lib/annotations-${annotations.version}.jar" property="annotations-exists"/>
</target>
- <target name="asm-tree-check">
+ <target name="asm-tree-check">
<available file="${basedir}/lib/asm-tree-${asm-tree.version}.jar" property="asm-tree-exists"/>
</target>
- <target name="install-findbugs" depends="findbugs-check" unless="findbugs-exists" description="installs findbugs.jar into lib">
+ <target name="commons-lang3-check">
+ <available file="${basedir}/samples/lib/commons-lang3-${commons-lang3.version}.jar" property="commons-lang3-exists"/>
+ </target>
+
+ <target name="servlet-api-check">
+ <available file="${basedir}/samples/lib/servlet-api-${servlet-api.version}.jar" property="servlet-api-exists"/>
+ </target>
+
+ <target name="jsp-api-check">
+ <available file="${basedir}/samples/lib/jsp-api-${jsp-api.version}.jar" property="jsp-api-exists"/>
+ </target>
+
+ <target name="log4j-check">
+ <available file="${basedir}/samples/lib/log4j-${log4j.version}.jar" property="log4j-exists"/>
+ </target>
+
+ <target name="junit-check">
+ <available file="${basedir}/samples/lib/junit-${junit.version}.jar" property="junit-exists"/>
+ </target>
+
+ <target name="install-findbugs" depends="findbugs-check" unless="findbugs-exists" description="installs findbugs.jar into lib">
<get src="${findbugs-url}" dest="${basedir}/lib/findbugs-${findbugs.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
-
+
<target name="install-findbugs-bcel" depends="findbugs-bcel-check" unless="findbugs-bcel-exists" description="installs findbugs-bcel.jar into lib">
<get src="${findbugs-bcel-url}" dest="${basedir}/lib/bcel-${findbugs-bcel.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
@@ -101,8 +136,28 @@
<get src="${asm-tree-url}" dest="${basedir}/lib/asm-tree-${asm-tree.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
- <target name="pull" depends="install-findbugs, install-findbugs-bcel, install-annotations, install-asm-tree" description="pull 3rdparty jars to the lib directory"/>
+ <target name="install-commons-lang3" depends="commons-lang3-check" unless="commons-lang3-exists" description="installs commons-lang3 into samples/lib">
+ <get src="${commons-lang3-url}" dest="${basedir}/samples/lib/commons-lang3-${commons-lang3.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+ <target name="install-servlet-api" depends="servlet-api-check" unless="servlet-api-exists" description="installs servlet-api into samples/lib">
+ <get src="${servlet-api-url}" dest="${basedir}/samples/lib/servlet-api-${servlet-api.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="install-jsp-api" depends="jsp-api-check" unless="jsp-api-exists" description="installs jsp-api into samples/lib">
+ <get src="${jsp-api-url}" dest="${basedir}/samples/lib/jsp-api-${jsp-api.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="install-log4j" depends="log4j-check" unless="log4j-exists" description="installs log4j into samples/lib">
+ <get src="${log4j-url}" dest="${basedir}/samples/lib/log4j-${log4j.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="install-junit" depends="junit-check" unless="junit-exists" description="installs junit into samples/lib">
+ <get src="${junit-url}" dest="${basedir}/samples/lib/junit-${junit.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="pull" depends="install-findbugs, install-findbugs-bcel, install-annotations, install-asm-tree, install-commons-lang3, install-servlet-api, install-jsp-api, install-log4j, install-junit" description="pull 3rdparty jars to the lib directory"/>
+
<target name="validate_xml" depends="-init" description="validates the xml files">
<xmlvalidate lenient="false" failonerror="yes">
<attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
Modified: trunk/fb-contrib/etc/bugrank.txt
===================================================================
--- trunk/fb-contrib/etc/bugrank.txt 2012-01-16 02:50:18 UTC (rev 1709)
+++ trunk/fb-contrib/etc/bugrank.txt 2012-01-21 03:02:07 UTC (rev 1710)
@@ -125,4 +125,5 @@
0 BugPattern PDP_POORLY_DEFINED_PARAMETER
0 BugPattern NSE_NON_SYMMETRIC_EQUALS
0 BugPattern CVAA_CONTRAVARIANT_ARRAY_ASSIGNMENT
-0 BugPattern NFF_NON_FUNCTIONAL_FIELD
\ No newline at end of file
+0 BugPattern NFF_NON_FUNCTIONAL_FIELD
+0 BugPattern CEBE_COMMONS_EQUAL_BUILDER_TOEQUALS
\ No newline at end of file
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2012-01-16 02:50:18 UTC (rev 1709)
+++ trunk/fb-contrib/etc/findbugs.xml 2012-01-21 03:02:07 UTC (rev 1710)
@@ -223,6 +223,10 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.LingeringGraphicsObjects" speed="fast" reports="LGO_LINGERING_GRAPHICS_OBJECT" />
<Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks" speed="fast" reports="STB_STACKED_TRY_BLOCKS" />
+
+ <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" />
<!-- BugPattern -->
@@ -391,4 +395,6 @@
<BugPattern abbrev="SGSU" type="SGSU_SUSPICIOUS_GETTER_SETTER_USE" category="CORRECTNESS" experimental="true" />
<BugPattern abbrev="LGO" type="LGO_LINGERING_GRAPHICS_OBJECT" category="PERFORMANCE" experimental="true" />
<BugPattern abbrev="STB" type="STB_STACKED_TRY_BLOCKS" category="STYLE" experimental="true" />
+ <BugPattern abbrev="CEBE" type="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" category="CORRECTNESS" />
+ <BugPattern abbrev="CHTH" type="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" category="CORRECTNESS" />
</FindbugsPlugin>
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2012-01-16 02:50:18 UTC (rev 1709)
+++ trunk/fb-contrib/etc/messages.xml 2012-01-21 03:02:07 UTC (rev 1710)
@@ -1217,6 +1217,26 @@
</Details>
</Detector>
+ <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsEqualsBuilderToEquals">
+ <Details>
+ <![CDATA[
+ <p>This detector looks for uses for Commons-lang EqualsBuilder where the
+ result of equals() is returned instead of calling the method isEquals().</p>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsHashcodeBuilderToHashcode">
+ <Details>
+ <![CDATA[
+ <p>This detector looks for uses for Commons-lang HashCodeBuilder where the
+ result of hashCode() is returned instead of calling the method toHashCode().</p>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </Detector>
+
<!-- BugPattern -->
<BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING">
@@ -3340,6 +3360,28 @@
</Details>
</BugPattern>
+ <BugPattern type="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS">
+ <ShortDescription>Method returns the result of invoking equals() on EqualsBuilder</ShortDescription>
+ <LongDescription>Method {1} returns the result of invoking equals() in EqualsBuilder</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method returns the result of equals on the EqualsBuilder type
+ instead of calling the method isEqual().</p>
+ ]]>
+ </Details>
+ </BugPattern>
+
+ <BugPattern type="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE">
+ <ShortDescription>Method returns the result of invoking hashCode() on HashCodeBuilder</ShortDescription>
+ <LongDescription>Method {1} returns the result of invoking hashCode() in HashCodeBuilder</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method returns the result of hashCode on the HashCodeBuilder type
+ instead of calling the method toHashCode().</p>
+ ]]>
+ </Details>
+ </BugPattern>
+
<!-- BugCode -->
<BugCode abbrev="ISB">Inefficient String Buffering</BugCode>
@@ -3442,4 +3484,5 @@
<BugCode abbrev="SGSU">Suspicious Getter Setter Use</BugCode>
<BugCode abbrev="LGO">Lingering Graphics Object</BugCode>
<BugCode abbrev="STB">Stacked Try Blocks</BugCode>
+ <BugCode abbrev="CEBE">Commons EqualsBuilder To Equals</BugCode>
</MessageCollection>
Added: trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java
===================================================================
--- trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java (rev 0)
+++ trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java 2012-01-21 03:02:07 UTC (rev 1710)
@@ -0,0 +1,31 @@
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+public class CEBE_EqualsToEqualsSample {
+ public final String name;
+ public final int age;
+
+ CEBE_EqualsToEqualsSample(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(name).append(age).toHashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CEBE_EqualsToEqualsSample other = (CEBE_EqualsToEqualsSample) obj;
+ return new EqualsBuilder().append(this.name, other.name)
+ .append(this.age, other.age).equals(obj);
+ }
+
+}
Property changes on: trunk/fb-contrib/samples/CEBE_EqualsToEqualsSample.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java
===================================================================
--- trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java (rev 0)
+++ trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java 2012-01-21 03:02:07 UTC (rev 1710)
@@ -0,0 +1,30 @@
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+public class CHBH_HashcodeToHashcodeSample {
+ public final String name;
+ public final int age;
+
+ CHBH_HashcodeToHashcodeSample(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(name).append(age).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CHBH_HashcodeToHashcodeSample other = (CHBH_HashcodeToHashcodeSample) obj;
+ return new EqualsBuilder().append(this.name, other.name)
+ .append(this.age, other.age).isEquals();
+ }
+}
Property changes on: trunk/fb-contrib/samples/CHBH_HashcodeToHashcodeSample.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java 2012-01-21 03:02:07 UTC (rev 1710)
@@ -0,0 +1,98 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2012 Bhaskar Maddala
+ * Copyright (C) 2005-2012 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 org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.LocalVariableTable;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.BytecodeScanningDetector;
+import edu.umd.cs.findbugs.OpcodeStack;
+
+/**
+ * Find usage of EqualsBuilder from Apache commons, where the code invoke
+ * equals() on the constructed object rather than isEquals()
+ *
+ * <pre>
+ * new EqualsBuilder().append(this.name, other.name).equals(other);
+ * </pre>
+ */
+public class CommonsEqualsBuilderToEquals extends BytecodeScanningDetector {
+
+ private final OpcodeStack stack;
+ private final BugReporter bugReporter;
+
+ /**
+ * constructs a CEBE detector given the reporter to report bugs on.
+ *
+ * @param bugReporter
+ * the sync of bug reports
+ */
+ public CommonsEqualsBuilderToEquals(final BugReporter bugReporter) {
+ stack = new OpcodeStack();
+ this.bugReporter = bugReporter;
+ }
+
+ /**
+ * implements the visitor to pass through constructors and static
+ * initializers to the byte code scanning code. These methods are not
+ * reported, but are used to build SourceLineAnnotations for fields, if
+ * accessed.
+ *
+ * @param obj
+ * the context object of the currently parsed code attribute
+ */
+ @Override
+ public void visitCode(Code obj) {
+ stack.resetForMethodEntry(this);
+ LocalVariableTable lvt = getMethod().getLocalVariableTable();
+ if (lvt != null) {
+ super.visitCode(obj);
+ }
+ }
+
+ @Override
+ public void sawOpcode(int seen) {
+ try {
+ switch (seen) {
+ case INVOKEVIRTUAL:
+ String methodName = getNameConstantOperand();
+ if ("equals".equals(methodName)
+ && "(Ljava/lang/Object;)Z"
+ .equals(getSigConstantOperand())) {
+ String calledClass = stack.getStackItem(1).getSignature();
+ if ("Lorg/apache/commons/lang3/builder/EqualsBuilder;"
+ .equals(calledClass)
+ || "org/apache/commons/lang/builder/EqualsBuilder"
+ .equals(calledClass)) {
+ bugReporter.reportBug(new BugInstance(this,
+ "CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS",
+ HIGH_PRIORITY).addClass(this).addMethod(this)
+ .addSourceLine(this));
+ }
+ }
+ }
+ } finally {
+ super.sawOpcode(seen);
+ stack.sawOpcode(this, seen);
+ }
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java 2012-01-21 03:02:07 UTC (rev 1710)
@@ -0,0 +1,97 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2012 Bhaskar Maddala
+ * Copyright (C) 2005-2012 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 org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.LocalVariableTable;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.BytecodeScanningDetector;
+import edu.umd.cs.findbugs.OpcodeStack;
+
+/**
+ * Find usage of HashCodeBuilder from Apache commons, where the code invokes
+ * hashCode() on the constructed object rather than toHashCode()
+ *
+ * <pre>
+ * new HashCodeBuilder().append(this.name).hashCode();
+ * </pre>
+ */
+public class CommonsHashcodeBuilderToHashcode extends BytecodeScanningDetector {
+
+ private final OpcodeStack stack;
+ private final BugReporter bugReporter;
+
+ /**
+ * constructs a CHTH detector given the reporter to report bugs on.
+ *
+ * @param bugReporter
+ * the sync of bug reports
+ */
+ public CommonsHashcodeBuilderToHashcode(final BugReporter bugReporter) {
+ stack = new OpcodeStack();
+ this.bugReporter = bugReporter;
+ }
+
+ /**
+ * implements the visitor to pass through constructors and static
+ * initializers to the byte code scanning code. These methods are not
+ * reported, but are used to build SourceLineAnnotations for fields, if
+ * accessed.
+ *
+ * @param obj
+ * the context object of the currently parsed code attribute
+ */
+ @Override
+ public void visitCode(Code obj) {
+ stack.resetForMethodEntry(this);
+ LocalVariableTable lvt = getMethod().getLocalVariableTable();
+ if (lvt != null) {
+ super.visitCode(obj);
+ }
+ }
+
+ @Override
+ public void sawOpcode(int seen) {
+ try {
+ switch (seen) {
+ case INVOKEVIRTUAL:
+ String methodName = getNameConstantOperand();
+ if ("hashCode".equals(methodName)
+ && "()I".equals(getSigConstantOperand())) {
+ String calledClass = stack.getStackItem(0).getSignature();
+ if ("Lorg/apache/commons/lang3/builder/HashCodeBuilder;"
+ .equals(calledClass)
+ || "org/apache/commons/lang/builder/HashCodeBuilder"
+ .equals(calledClass)) {
+ bugReporter.reportBug(new BugInstance(this,
+ "CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE",
+ HIGH_PRIORITY).addClass(this).addMethod(this)
+ .addSourceLine(this));
+ }
+ }
+ }
+ } finally {
+ super.sawOpcode(seen);
+ stack.sawOpcode(this, seen);
+ }
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java 2012-01-21 03:02:07 UTC (rev 1710)
@@ -0,0 +1,93 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2012 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.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.bcel.Constants;
+
+import edu.umd.cs.findbugs.OpcodeStack;
+
+/**
+ * restores OpcodeStack Item's userValues when a ternary is processed. This class is required
+ * because Findbugs has a bug whereby it strips the user value field from all OpcodeStack items when
+ * a GOTO is processed when items are on the stack. Normally this is not the case, but in the case of
+ * ternary handling there may be N items on the stack before what the ternary pushes. Now clearly the uservalue
+ * should be stripped for items pushed on by both branches of the ternary, but items that were on the stack
+ * before the ternary was executed should be left alone. This is currently not happening in findbugs.
+ * So this class saves off user values across a GOTO involved with a ternary and restores them appropriately.
+ */
+public class TernaryPatcher {
+
+ private static List<Object> userValues = new ArrayList<Object>();
+ private static boolean sawGOTO = false;
+
+ private TernaryPatcher() {
+ }
+
+ /**
+ * called before the execution of the parent OpcodeStack.sawOpcode() to save user values if the opcode is a GOTO or GOTO_W.
+ *
+ * @param stack the OpcodeStack with the items containing user values
+ * @param opcode the opcode currently seen
+ */
+ public static void pre(OpcodeStack stack, int opcode) {
+ if (!sawGOTO) {
+ sawGOTO = (opcode == Constants.GOTO) || (opcode == Constants.GOTO_W);
+ if (sawGOTO) {
+ int depth = stack.getStackDepth();
+ if (depth > 0) {
+ userValues.clear();
+ for (int i = 0; i < depth; i++) {
+ OpcodeStack.Item item = stack.getStackItem(i);
+ userValues.add(item.getUserValue());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * called after the execution of the parent OpcodeStack.sawOpcode, to restore the user values after the GOTO or GOTO_W's mergeJumps were processed
+ *
+ * @param stack the OpcodeStack with the items containing user values
+ * @param opcode the opcode currently seen
+ */
+ public static void post(OpcodeStac...
[truncated message content] |
|
From: <dbr...@us...> - 2012-02-02 18:00:48
|
Revision: 1711
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1711&view=rev
Author: dbrosius
Date: 2012-02-02 18:00:41 +0000 (Thu, 02 Feb 2012)
Log Message:
-----------
update from github - thanks Bhaskar Maddala
Modified Paths:
--------------
trunk/fb-contrib/.classpath
trunk/fb-contrib/build.xml
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
Added Paths:
-----------
trunk/fb-contrib/samples/BRPI_Sample.java
trunk/fb-contrib/samples/CCNE_Sample.java
trunk/fb-contrib/samples/CSBTS_StringToStringSample.java
trunk/fb-contrib/samples/samples.fbp
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CompareClassNameEquals.java
Modified: trunk/fb-contrib/.classpath
===================================================================
--- trunk/fb-contrib/.classpath 2012-01-21 03:02:07 UTC (rev 1710)
+++ trunk/fb-contrib/.classpath 2012-02-02 18:00:41 UTC (rev 1711)
@@ -2,17 +2,18 @@
<classpath>
<classpathentry excluding="**/*.*" kind="src" path="etc"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="samples"/>
+ <classpathentry excluding="lib/" kind="src" path="samples"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/annotations-2.0.0.jar"/>
<classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/>
<classpathentry kind="lib" path="lib/bcel-2.0.0.jar"/>
- <classpathentry kind="lib" path="lib/findbugs-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/findbugs-2.0.0.jar" sourcepath="findbugs-2.0.0-source.zip"/>
<classpathentry kind="lib" path="samples/lib/commons-lang3-3.1.jar"/>
<classpathentry kind="lib" path="samples/lib/jsp-api-2.2.1.jar"/>
<classpathentry kind="lib" path="samples/lib/junit-4.10.jar"/>
<classpathentry kind="lib" path="samples/lib/log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="samples/lib/servlet-api-3.0.1.jar"/>
+ <classpathentry kind="lib" path="samples/lib/backport-util-concurrent-3.1.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2012-01-21 03:02:07 UTC (rev 1710)
+++ trunk/fb-contrib/build.xml 2012-02-02 18:00:41 UTC (rev 1711)
@@ -27,23 +27,25 @@
<property name="annotations.version" value="2.0.0"/>
<property name="asm-tree.version" value="3.3.1"/>
- <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar"/>
- <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar"/>
- <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar"/>
- <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar"/>
+ <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar"/>
+ <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar"/>
+ <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar"/>
+ <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar"/>
- <!-- properties for samples lib dependencies -->
- <property name="commons-lang3.version" value="3.1"/>
- <property name="jsp-api.version" value="2.2.1" />
- <property name="junit.version" value="4.10" />
- <property name="log4j.version" value="1.2.16" />
- <property name="servlet-api.version" value="3.0.1" />
+ <!-- properties for samples lib dependencies -->
+ <property name="commons-lang3.version" value="3.1"/>
+ <property name="jsp-api.version" value="2.2.1" />
+ <property name="junit.version" value="4.10" />
+ <property name="log4j.version" value="1.2.16" />
+ <property name="servlet-api.version" value="3.0.1" />
+ <property name="backport-concurrent.version" value="3.1" />
- <property name="commons-lang3-url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.jar"/>
- <property name="jsp-api-url" value="http://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/${jsp-api.version}/javax.servlet.jsp-api-${jsp-api.version}.jar" />
- <property name="junit-url" value="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar"/>
- <property name="log4j-url" value="http://repo1.maven.org/maven2/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar"/>
- <property name="servlet-api-url" value="http://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/${servlet-api.version}/javax.servlet-api-${servlet-api.version}.jar"/>
+ <property name="commons-lang3-url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.jar"/>
+ <property name="jsp-api-url" value="http://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/${jsp-api.version}/javax.servlet.jsp-api-${jsp-api.version}.jar" />
+ <property name="junit-url" value="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar"/>
+ <property name="log4j-url" value="http://repo1.maven.org/maven2/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar"/>
+ <property name="servlet-api-url" value="http://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/${servlet-api.version}/javax.servlet-api-${servlet-api.version}.jar"/>
+ <property name="backport-concurrent-url" value="http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/${backport-concurrent.version}/backport-util-concurrent-${backport-concurrent.version}.jar" />
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
@@ -76,6 +78,8 @@
<pathelement location="${sampleslib.dir}/servlet-api-${servlet-api.version}.jar"/>
<pathelement location="${sampleslib.dir}/log4j-${log4j.version}.jar"/>
<pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar"/>
+ <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar"/>
+ <pathelement location="${sampleslib.dir}/backport-util-concurrent-${backport-concurrent.version}.jar"/>
</path>
<mkdir dir="${classes.dir}/com"/>
<mkdir dir="${classes.dir}/com/mebigfatguy"/>
@@ -107,6 +111,10 @@
<target name="servlet-api-check">
<available file="${basedir}/samples/lib/servlet-api-${servlet-api.version}.jar" property="servlet-api-exists"/>
</target>
+
+ <target name="backport-concurrent-check">
+ <available file="${basedir}/samples/lib/backport-util-concurrent-${backport-concurrent.version}.jar" property="backport-concurrent-exists" />
+ </target>
<target name="jsp-api-check">
<available file="${basedir}/samples/lib/jsp-api-${jsp-api.version}.jar" property="jsp-api-exists"/>
@@ -143,7 +151,11 @@
<target name="install-servlet-api" depends="servlet-api-check" unless="servlet-api-exists" description="installs servlet-api into samples/lib">
<get src="${servlet-api-url}" dest="${basedir}/samples/lib/servlet-api-${servlet-api.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
-
+
+ <target name="install-backport-concurrent" depends="backport-concurrent-check" unless="backport-concurrent-exists" description="installs backport-concurrent into samples/lib">
+ <get src="${backport-concurrent-url}" dest="${basedir}/samples/lib/backport-util-concurrent-${backport-concurrent.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
<target name="install-jsp-api" depends="jsp-api-check" unless="jsp-api-exists" description="installs jsp-api into samples/lib">
<get src="${jsp-api-url}" dest="${basedir}/samples/lib/jsp-api-${jsp-api.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
@@ -156,7 +168,7 @@
<get src="${junit-url}" dest="${basedir}/samples/lib/junit-${junit.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
- <target name="pull" depends="install-findbugs, install-findbugs-bcel, install-annotations, install-asm-tree, install-commons-lang3, install-servlet-api, install-jsp-api, install-log4j, install-junit" description="pull 3rdparty jars to the lib directory"/>
+ <target name="pull" depends="install-findbugs, install-findbugs-bcel, install-annotations, install-asm-tree, install-commons-lang3, install-servlet-api, install-backport-concurrent, install-jsp-api, install-log4j, install-junit" description="pull 3rdparty jars to the lib directory"/>
<target name="validate_xml" depends="-init" description="validates the xml files">
<xmlvalidate lenient="false" failonerror="yes">
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2012-01-21 03:02:07 UTC (rev 1710)
+++ trunk/fb-contrib/etc/findbugs.xml 2012-02-02 18:00:41 UTC (rev 1711)
@@ -227,6 +227,12 @@
<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" />
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsStringBuilderToString" speed="fast" reports="CSBTS_COMMONS_STRING_BUILDER_TOSTRING" />
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.CompareClassNameEquals" speed="fast" reports="CCNE_COMPARE_CLASS_EQUALS_NAME" />
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers" speed="fast" reports="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" />
<!-- BugPattern -->
@@ -397,4 +403,7 @@
<BugPattern abbrev="STB" type="STB_STACKED_TRY_BLOCKS" category="STYLE" experimental="true" />
<BugPattern abbrev="CEBE" type="CEBE_COMMONS_EQUALS_BUILDER_ISEQUALS" category="CORRECTNESS" />
<BugPattern abbrev="CHTH" type="CHTH_COMMONS_HASHCODE_BUILDER_TOHASHCODE" category="CORRECTNESS" />
+ <BugPattern abbrev="CSBTS" type="CSBTS_COMMONS_STRING_BUILDER_TOSTRING" category="CORRECTNESS" />
+ <BugPattern abbrev="CCNE" type="CCNE_COMPARE_CLASS_EQUALS_NAME" category="CORRECTNESS" />
+ <BugPattern abbrev="BRPI" type="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS" category ="PERFORMANCE" />
</FindbugsPlugin>
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2012-01-21 03:02:07 UTC (rev 1710)
+++ trunk/fb-contrib/etc/messages.xml 2012-02-02 18:00:41 UTC (rev 1711)
@@ -1237,6 +1237,40 @@
</Details>
</Detector>
+ <Detector class="com.mebigfatguy.fbcontrib.detect.CommonsStringBuilderToString">
+ <Details>
+ <![CDATA[
+ <p>This detector looks for uses for Commons-lang ToStringBuilder where the
+ result of toString() is returned without an intermediate invocation of toString().</p>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.CompareClassNameEquals">
+ <Details>
+ <![CDATA[
+ <p> In a JVM, Two classes are the same class (and consequently the same type) if
+ they are loaded by the same class loader, and they have the same fully
+ qualified name [JVMSpec 1999].
+
+ Comparing class name ignores the class loader.
+ </p>
+ ]]>
+ </Details>
+ </Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.BackportReusePublicIdentifiers">
+ <Details>
+ <![CDATA[
+ <p> Detects use of Backport Utils concurrent classes. Updated/Efficient version of these
+ classes are available in versions of the JDK 5.0 and higher, and these
+ classes should only be used if you are targeting JDK 1.4 and lower.
+ </p>
+ ]]>
+ </Details>
+ </Detector>
+
<!-- BugPattern -->
<BugPattern type="ISB_INEFFICIENT_STRING_BUFFERING">
@@ -3380,8 +3414,47 @@
instead of calling the method toHashCode().</p>
]]>
</Details>
- </BugPattern>
+ </BugPattern>
+ <BugPattern type="CSBTS_COMMONS_STRING_BUILDER_TOSTRING">
+ <ShortDescription>Method returns the result of invoking toString() without intermediate invocation of append() in ToStringBuilder</ShortDescription>
+ <LongDescription>Method {1} returns the result of invoking toString() without intermediate invocation of append() in ToStringBuilder</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method returns the result of toString() on ToStringBuilder without an
+ intermediate invocation of append()</p>
+ ]]>
+ </Details>
+ </BugPattern>
+
+ <BugPattern type="CCNE_COMPARE_CLASS_EQUALS_NAME">
+ <ShortDescription>Method compares class name instead of comparing class</ShortDescription>
+ <LongDescription>Method {1} compares class name instead of comparing the class</LongDescription>
+ <Details>
+ <![CDATA[
+ <p> In a JVM, Two classes are the same class (and consequently the same type) if
+ they are loaded by the same class loader, and they have the same fully
+ qualified name [JVMSpec 1999].
+
+ Comparing class name ignores the class loader.
+ </p>
+ ]]>
+ </Details>
+ </BugPattern>
+
+ <BugPattern type="BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS">
+ <ShortDescription>Method uses backport concurrency utils</ShortDescription>
+ <LongDescription>Method {1} backport concurrency utils</LongDescription>
+ <Details>
+ <![CDATA[
+ <p> Detects use of Backport Utils concurrent classes. Updated/Efficient version of these
+ classes are available in versions of the JDK 5.0 and higher, and these
+ classes should only be used if you are targeting JDK 1.4 and lower.
+ </p>
+ ]]>
+ </Details>
+ </BugPattern>
+
<!-- BugCode -->
<BugCode abbrev="ISB">Inefficient String Buffering</BugCode>
@@ -3485,4 +3558,8 @@
<BugCode abbrev="LGO">Lingering Graphics Object</BugCode>
<BugCode abbrev="STB">Stacked Try Blocks</BugCode>
<BugCode abbrev="CEBE">Commons EqualsBuilder To Equals</BugCode>
+ <BugCode abbrev="CHTH">Commons HashCodeBuilder To hashCode</BugCode>
+ <BugCode abbrev="CSBTS">Commons ToStringBuilder To String</BugCode>
+ <BugCode abbrev="CCNE">Compare class name equals</BugCode>
+ <BugCode abbrev="BRPI">Backport concurrent reuse of public identifiers</BugCode>
</MessageCollection>
Added: trunk/fb-contrib/samples/BRPI_Sample.java
===================================================================
--- trunk/fb-contrib/samples/BRPI_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/BRPI_Sample.java 2012-02-02 18:00:41 UTC (rev 1711)
@@ -0,0 +1,11 @@
+import edu.emory.mathcs.backport.java.util.Collections;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+import edu.emory.mathcs.backport.java.util.concurrent.Executors;
+
+public class BRPI_Sample {
+ public static void main(String[] arg) {
+ Collections.emptySet();
+ Executors.newCachedThreadPool();
+ new ConcurrentHashMap();
+ }
+}
Property changes on: trunk/fb-contrib/samples/BRPI_Sample.java
___________________________________________________________________
Added: svn-eol-style
+ native
Added: svn:mime-type
+ text/plain
Added: eol-style
+ native
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/samples/CCNE_Sample.java
===================================================================
--- trunk/fb-contrib/samples/CCNE_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/CCNE_Sample.java 2012-02-02 18:00:41 UTC (rev 1711)
@@ -0,0 +1,8 @@
+public class CCNE_Sample {
+ public void compareClassEquals() {
+ Object o = new CCNE_Sample();
+ Object p = new CCNE_Sample();
+ System.out.println(o.getClass().getName()
+ .equals(p.getClass().getName()));
+ }
+}
Property changes on: trunk/fb-contrib/samples/CCNE_Sample.java
___________________________________________________________________
Added: svn-eol-style
+ native
Added: svn:mime-type
+ text/plain
Added: eol-style
+ native
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/samples/CSBTS_StringToStringSample.java
===================================================================
--- trunk/fb-contrib/samples/CSBTS_StringToStringSample.java (rev 0)
+++ trunk/fb-contrib/samples/CSBTS_StringToStringSample.java 2012-02-02 18:00:41 UTC (rev 1711)
@@ -0,0 +1,59 @@
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+public class CSBTS_StringToStringSample {
+ static class Person {
+ String name;
+ int age;
+
+ Person(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ @Override
+ public String toString() {
+ // INCORRECT USAGE : The same as invoking Object.toString()
+ // return new ToStringBuilder(this).toString();
+ // Consider using for non final classes to support a
+ // string representation for derived types
+ // return ToStringBuilder.reflectionToString(this);
+ // Use for final classes most efficient solution
+ return new ToStringBuilder(this).append("name", name)
+ .append("age", age).toString();
+ }
+ }
+
+ private enum SEX {
+ Male, Female;
+ }
+
+ public final static class GenderPerson extends Person {
+ private SEX sex;
+
+ GenderPerson(String name, int age, SEX sex) {
+ super(name, age);
+ this.sex = sex;
+ }
+ }
+
+ public static void main(String[] args) {
+ Person p = new Person("John Doe", 2);
+ ToStringBuilder x = new ToStringBuilder(p);
+ ToStringBuilder y = new ToStringBuilder(p);
+ // INCORRECT USAGE : The same as invoking Object.toString
+ System.out.println("P " + new ToStringBuilder(p).toString());
+ // Consider using for non final classes to support a string
+ // representation for derived types
+ System.out.println("P " + ToStringBuilder.reflectionToString(p));
+ GenderPerson p2 = new GenderPerson("Jane Doe", 2, SEX.Female);
+ System.out
+ .println("GP "
+ + new ToStringBuilder(p2).append("name", p2.name)
+ .append("age", p2.age).append("sex", p2.sex)
+ .toString());
+ // Y now has an append
+ y.append("name", p.name);
+ System.out.println("P - Once Again " + y.toString());
+ System.out.println("P - Again " + x.toString());
+ }
+}
Property changes on: trunk/fb-contrib/samples/CSBTS_StringToStringSample.java
___________________________________________________________________
Added: svn-eol-style
+ native
Added: svn:mime-type
+ text/plain
Added: eol-style
+ native
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/samples/samples.fbp
===================================================================
--- trunk/fb-contrib/samples/samples.fbp (rev 0)
+++ trunk/fb-contrib/samples/samples.fbp 2012-02-02 18:00:41 UTC (rev 1711)
@@ -0,0 +1,12 @@
+<Project projectName="">
+ <Jar>.</Jar>
+ <AuxClasspathEntry>./lib/jsp-api.jar</AuxClasspathEntry>
+ <AuxClasspathEntry>./lib/junit.jar</AuxClasspathEntry>
+ <AuxClasspathEntry>./lib/log4j.jar</AuxClasspathEntry>
+ <AuxClasspathEntry>./lib/servlet-api.jar</AuxClasspathEntry>
+ <SrcDir>.</SrcDir>
+ <SuppressionFilter>
+ <LastVersion value="-1" relOp="NEQ"/>
+ </SuppressionFilter>
+ <Cloud id="1"></Cloud>
+</Project>
Property changes on: trunk/fb-contrib/samples/samples.fbp
___________________________________________________________________
Added: svn-eol-style
+ native
Added: svn:executable
+ *
Added: svn:mime-type
+ text/plain
Added: eol-style
+ native
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java 2012-02-02 18:00:41 UTC (rev 1711)
@@ -0,0 +1,80 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2012 Bhaskar Maddala
+ * Copyright (C) 2005-2012 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 org.apache.bcel.Constants;
+import org.apache.bcel.classfile.JavaClass;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.ba.ClassContext;
+import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
+
+/**
+ * Detects use of Backport concurrent classes. Updated/Efficient version of
+ * these classes are available in versions of the JDK 5.0 and higher, and these
+ * classes should only be used if you are targeting JDK 1.4 and lower.
+ *
+ * Finds usage of classes from backport utils package.
+ */
+public class BackportReusePublicIdentifiers extends OpcodeStackDetector {
+
+ private final BugReporter bugReporter;
+
+ public BackportReusePublicIdentifiers(final BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ @Override
+ public void visitClassContext(ClassContext classContext) {
+ JavaClass cls = classContext.getJavaClass();
+ if (cls.getMajor() >= Constants.MAJOR_1_5) {
+ super.visitClassContext(classContext);
+ }
+ }
+
+ @Override
+ public void sawOpcode(int seen) {
+ switch (seen) {
+ case INVOKESTATIC: {
+ String className = getClassConstantOperand();
+ if (className.startsWith("edu/emory/mathcs/backport/")) {
+ reportBug();
+ }
+ }
+ break;
+ case INVOKESPECIAL: {
+ String className = getClassConstantOperand();
+ String methodName = getNameConstantOperand();
+ if (className.startsWith("edu/emory/mathcs/backport/")
+ && methodName.equals("<init>")) {
+ reportBug();
+ }
+ }
+ break;
+ }
+ }
+
+ private void reportBug() {
+ bugReporter.reportBug(new BugInstance(this,
+ "BRPI_BACKPORT_REUSE_PUBLIC_IDENTIFIERS", NORMAL_PRIORITY)
+ .addClass(this).addMethod(this).addSourceLine(this));
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java
___________________________________________________________________
Added: svn-eol-style
+ native
Added: svn:mime-type
+ text/plain
Added: eol-style
+ native
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java 2012-02-02 18:00:41 UTC (rev 1711)
@@ -0,0 +1,171 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2012 Bhaskar Maddala
+ * Copyright (C) 2005-2012 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.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.LocalVariable;
+import org.apache.bcel.classfile.LocalVariableTable;
+
+import com.mebigfatguy.fbcontrib.utils.RegisterUtils;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.OpcodeStack.Item;
+import edu.umd.cs.findbugs.bcel.OpcodeStackDetector;
+
+/**
+ * Find usage of ToStringBuilder from Apache commons, where the code invokes
+ * toString() on the constructed object without invoking append().
+ *
+ * Usage without invoking append is equivalent of using the Object.toString()
+ * method
+ *
+ * <pre>
+ * new ToStringBuilder(this).toString();
+ * </pre>
+ */
+public class CommonsStringBuilderToString extends OpcodeStackDetector {
+
+ private final BugReporter bugReporter;
+ private Stack<Pair> stackTracker = new Stack<Pair>();
+ private Map<Integer, Boolean> registerTracker = new HashMap<Integer, Boolean>();
+
+ /**
+ * constructs a CSBTS detector given the reporter to report bugs on.
+ *
+ * @param bugReporter
+ * the sync of bug reports
+ */
+ public CommonsStringBuilderToString(final BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ @Override
+ public void visit(Code obj) {
+ registerTracker.clear();
+ stackTracker.clear();
+ super.visit(obj);
+ }
+
+ @Override
+ public boolean shouldVisitCode(Code obj) {
+ LocalVariableTable lvt = getMethod().getLocalVariableTable();
+ return lvt != null;
+ }
+
+ @Override
+ public void sawOpcode(int seen) {
+ switch (seen) {
+ case ALOAD:
+ case ALOAD_0:
+ case ALOAD_1:
+ case ALOAD_2:
+ case ALOAD_3:
+ LocalVariable lv = getMethod().getLocalVariableTable()
+ .getLocalVariable(RegisterUtils.getALoadReg(this, seen),
+ getNextPC());
+ if (lv != null) {
+ String signature = lv.getSignature();
+ if (isToStringBuilder(signature)) {
+ Integer loadReg = Integer.valueOf(getRegisterOperand());
+ Boolean appendInvoked = registerTracker.get(loadReg);
+ if (appendInvoked != null) {
+ stackTracker.add(new Pair(loadReg.intValue(),
+ appendInvoked.booleanValue()));
+ }
+ }
+ }
+ break;
+ case ASTORE:
+ case ASTORE_0:
+ case ASTORE_1:
+ case ASTORE_2:
+ case ASTORE_3:
+ Item si = stack.getStackItem(0);
+ String signature = si.getSignature();
+ if (isToStringBuilder(signature)) {
+ int storeReg = getRegisterOperand();
+ Pair p = stackTracker.pop();
+ registerTracker.put(
+ Integer.valueOf(storeReg),
+ p.register == -1 ? Boolean.FALSE : registerTracker
+ .get(Integer.valueOf(p.register)));
+ }
+ break;
+ case POP:
+ si = stack.getStackItem(0);
+ signature = si.getSignature();
+ if (isToStringBuilder(signature)) {
+ Pair p = stackTracker.pop();
+ registerTracker.put(Integer.valueOf(p.register),
+ Boolean.valueOf(p.appendInvoked));
+ }
+ break;
+ case INVOKESPECIAL:
+ case INVOKEVIRTUAL:
+ String loadClassName = getClassConstantOperand();
+ String calledMethodName = getNameConstantOperand();
+ String calledMeth...
[truncated message content] |
|
From: <dbr...@us...> - 2012-02-03 23:16:32
|
Revision: 1714
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1714&view=rev
Author: dbrosius
Date: 2012-02-03 23:16:26 +0000 (Fri, 03 Feb 2012)
Log Message:
-----------
update from github
Modified Paths:
--------------
trunk/fb-contrib/samples/STB_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
Modified: trunk/fb-contrib/samples/STB_Sample.java
===================================================================
--- trunk/fb-contrib/samples/STB_Sample.java 2012-02-02 18:31:49 UTC (rev 1713)
+++ trunk/fb-contrib/samples/STB_Sample.java 2012-02-03 23:16:26 UTC (rev 1714)
@@ -31,7 +31,42 @@
throw new STBException();
}
}
+
+ public void fpTestDiffMessages(File f1, File f2) throws STBException {
+ try {
+ InputStream is = new FileInputStream(f1);
+ } catch (IOException ioe) {
+ throw new STBException("Couldn't open file 1");
+ }
+ try {
+ InputStream is = new FileInputStream(f2);
+ } catch (IOException ioe) {
+ throw new STBException("Couldn't open file 2");
+ }
+ }
+
+ public void fpTestDiffMessagesByAppending(File f1, File f2) throws STBException {
+ try {
+ InputStream is = new FileInputStream(f1);
+ } catch (IOException ioe) {
+ throw new STBException("Couldn't open file: " + f1);
+ }
+
+ try {
+ InputStream is = new FileInputStream(f2);
+ } catch (IOException ioe) {
+ throw new STBException("Couldn't open file: " + f2);
+ }
+ }
+
static class STBException extends Exception {
+
+ public STBException() {
+ }
+
+ public STBException(String message) {
+ super(message);
+ }
}
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2012-02-02 18:31:49 UTC (rev 1713)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2012-02-03 23:16:26 UTC (rev 1714)
@@ -9,10 +9,13 @@
import java.util.Set;
import org.apache.bcel.Constants;
+import org.apache.bcel.Repository;
import org.apache.bcel.classfile.Code;
import org.apache.bcel.classfile.CodeException;
import org.apache.bcel.classfile.ConstantClass;
import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.generic.Type;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugReporter;
@@ -29,6 +32,15 @@
public class StackedTryBlocks extends BytecodeScanningDetector {
+ private static JavaClass THROWABLE_CLASS;
+
+ static {
+ try {
+ THROWABLE_CLASS = Repository.lookupClass("java.lang.Throwable");
+ } catch (ClassNotFoundException cnfe) {
+ THROWABLE_CLASS = null;
+ }
+ }
private final BugReporter bugReporter;
private List<TryBlock> blocks;
private List<TryBlock> inBlocks;
@@ -41,8 +53,10 @@
@Override
public void visitClassContext(ClassContext classContext) {
try {
- stack = new OpcodeStack();
- super.visitClassContext(classContext);
+ if (THROWABLE_CLASS != null) {
+ stack = new OpcodeStack();
+ super.visitClassContext(classContext);
+ }
} finally {
stack = null;
}
@@ -54,8 +68,7 @@
try {
XMethod xMethod = getXMethod();
String[] tes = xMethod.getThrownExceptions();
- Set<String> thrownExceptions = new HashSet<String>(Arrays.<String> asList((tes == null) ? new String[0]
- : tes));
+ Set<String> thrownExceptions = new HashSet<String>(Arrays.<String> asList((tes == null) ? new String[0] : tes));
blocks = new ArrayList<TryBlock>();
inBlocks = new ArrayList<TryBlock>();
@@ -91,7 +104,9 @@
TryBlock secondBlock = blocks.get(i);
if ((firstBlock.getCatchType() == secondBlock.getCatchType())
- && (firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature()))) {
+ && (firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature())
+ && (firstBlock.getMessage().equals(secondBlock.getMessage())
+ && (firstBlock.getExceptionSignature().equals(secondBlock.getExceptionSignature()))))) {
bugReporter.reportBug(new BugInstance(this, "STB_STACKED_TRY_BLOCKS", NORMAL_PRIORITY)
.addClass(this).addMethod(this)
.addSourceLineRange(this, firstBlock.getStartPC(), firstBlock.getEndHandlerPC())
@@ -112,6 +127,7 @@
@Override
public void sawOpcode(int seen) {
+ String message = null;
try {
int pc = getPC();
TryBlock block = findBlockWithStart(pc);
@@ -146,16 +162,44 @@
} else if (seen == ATHROW) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
- innerBlock.setThrowSignature(item.getSignature());
+ XMethod xm = item.getReturnValueOf();
+ if (xm != null) {
+ innerBlock.setThrowSignature(xm.getSignature());
+ }
+ innerBlock.setExceptionSignature(item.getSignature());
+ innerBlock.setMessage((String) item.getUserValue());
} else {
inBlocks.remove(inBlocks.size() - 1);
innerBlock.setState(TryBlock.State.AFTER);
}
+ } else if ((seen == INVOKESPECIAL) && "<init>".equals(getNameConstantOperand())) {
+ String cls = getClassConstantOperand();
+ JavaClass exCls = Repository.lookupClass(cls);
+ if (exCls.instanceOf(THROWABLE_CLASS)) {
+ String signature = getSigConstantOperand();
+ Type[] types = Type.getArgumentTypes(signature);
+ if ((types.length > 0) && "Ljava/lang/String;".equals(types[0].getSignature())) {
+ if (stack.getStackDepth() >= types.length) {
+ OpcodeStack.Item item = stack.getStackItem(types.length - 1);
+ message = (String)item.getConstant();
+ if (message == null) {
+ message = "____UNKNOWN____" + System.currentTimeMillis();
+ }
+ }
+ }
+
+ }
}
}
}
+ } catch (ClassNotFoundException cnfe) {
+ bugReporter.reportMissingClass(cnfe);
} finally {
stack.sawOpcode(this, seen);
+ if ((message != null) && (stack.getStackDepth() > 0)) {
+ OpcodeStack.Item item = stack.getStackItem(0);
+ item.setUserValue(message);
+ }
}
}
@@ -181,7 +225,9 @@
int handlerPC;
int endHandlerPC;
BitSet catchTypes;
+ String exSig;
String throwSig;
+ String message;
State state;
public TryBlock(CodeException ce) {
@@ -228,13 +274,29 @@
endHandlerPC = end;
}
+ public void setExceptionSignature(String sig) {
+ exSig = sig;
+ }
+
public void setThrowSignature(String sig) {
throwSig = sig;
}
+
+ public void setMessage(String m) {
+ message = m;
+ }
+ public String getExceptionSignature() {
+ return (exSig == null) ? String.valueOf(System.identityHashCode(this)) : exSig;
+ }
+
public String getThrowSignature() {
return (throwSig == null) ? String.valueOf(System.identityHashCode(this)) : throwSig;
}
+
+ public String getMessage() {
+ return (message == null) ? String.valueOf(System.identityHashCode(this)) : message;
+ }
public int getStartPC() {
return startPC;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2012-07-04 23:24:34
|
Revision: 1715
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1715&view=rev
Author: dbrosius
Date: 2012-07-04 23:24:26 +0000 (Wed, 04 Jul 2012)
Log Message:
-----------
update from github
Modified Paths:
--------------
trunk/fb-contrib/.classpath
trunk/fb-contrib/build.xml
trunk/fb-contrib/samples/PCAIL_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
Modified: trunk/fb-contrib/.classpath
===================================================================
--- trunk/fb-contrib/.classpath 2012-02-03 23:16:26 UTC (rev 1714)
+++ trunk/fb-contrib/.classpath 2012-07-04 23:24:26 UTC (rev 1715)
@@ -5,15 +5,23 @@
<classpathentry excluding="lib/" kind="src" path="samples"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="lib" path="lib/annotations-2.0.0.jar"/>
- <classpathentry kind="lib" path="lib/asm-tree-3.3.1.jar"/>
- <classpathentry kind="lib" path="lib/bcel-2.0.0.jar"/>
- <classpathentry kind="lib" path="lib/findbugs-2.0.0.jar" sourcepath="findbugs-2.0.0-source.zip"/>
- <classpathentry kind="lib" path="samples/lib/commons-lang3-3.1.jar"/>
<classpathentry kind="lib" path="samples/lib/jsp-api-2.2.1.jar"/>
<classpathentry kind="lib" path="samples/lib/junit-4.10.jar"/>
<classpathentry kind="lib" path="samples/lib/log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="samples/lib/servlet-api-3.0.1.jar"/>
- <classpathentry kind="lib" path="samples/lib/backport-util-concurrent-3.1.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/asm-3.3.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/asm-analysis-3.3.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/asm-commons-3.3.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/asm-tree-3.3.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/asm-util-3.3.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/bcel.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/dom4j-1.6.1.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/findbugs.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/jaxen-1.1.1.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/jFormatString.jar"/>
+ <classpathentry kind="lib" path="/home/dave/dev/avondale/3rdparty/findbugs/lib/jsr305.jar"/>
+ <classpathentry kind="lib" path="samples/lib/commons-lang3-3.1.jar"/>
+ <classpathentry kind="lib" path="samples/lib/backport-concurrent-3.1.jar"/>
+ <classpathentry kind="lib" path="samples/lib/commons-collection-${commons-collection.version}.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/fb-contrib/build.xml
===================================================================
--- trunk/fb-contrib/build.xml 2012-02-03 23:16:26 UTC (rev 1714)
+++ trunk/fb-contrib/build.xml 2012-07-04 23:24:26 UTC (rev 1715)
@@ -1,294 +1,224 @@
-<!--
- fb-contrib Ant build script.
- Dave Brosius
--->
+<!-- fb-contrib Ant build script. Dave Brosius -->
<project name="fb-contrib" default="install">
- <property file="build.properties"/>
+ <property file="build.properties" />
- <property name="src.dir" value="${basedir}/src"/>
- <property name="classes.dir" value="${basedir}/classes"/>
- <property name="lib.dir" value="${basedir}/lib"/>
- <property name="etc.dir" value="${basedir}/etc"/>
- <property name="samples.dir" value="${basedir}/samples"/>
- <property name="sampleslib.dir" value="${samples.dir}/lib"/>
- <property name="javadoc.dir" value="${basedir}/javadoc"/>
- <property name="htdocs.dir" value="${basedir}/htdocs"/>
- <property name="javac.source" value="1.5"/>
- <property name="javac.target" value="1.5"/>
- <property name="javac.deprecation" value="on"/>
- <property name="javac.debug" value="on"/>
+ <property name="src.dir" value="${basedir}/src" />
+ <property name="classes.dir" value="${basedir}/classes" />
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="etc.dir" value="${basedir}/etc" />
+ <property name="samples.dir" value="${basedir}/samples" />
+ <property name="sampleslib.dir" value="${samples.dir}/lib" />
+ <property name="javadoc.dir" value="${basedir}/javadoc" />
+ <property name="htdocs.dir" value="${basedir}/htdocs" />
+ <property name="javac.source" value="1.5" />
+ <property name="javac.target" value="1.5" />
+ <property name="javac.deprecation" value="on" />
+ <property name="javac.debug" value="on" />
- <property name="fb-contrib.version" value="4.7.0"/>
-
- <property name="findbugs.version" value="2.0.0"/>
- <property name="findbugs-bcel.version" value="2.0.0"/>
- <property name="annotations.version" value="2.0.0"/>
- <property name="asm-tree.version" value="3.3.1"/>
-
- <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar"/>
- <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar"/>
- <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar"/>
- <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar"/>
+ <property name="fb-contrib.version" value="4.7.0" />
- <!-- properties for samples lib dependencies -->
- <property name="commons-lang3.version" value="3.1"/>
- <property name="jsp-api.version" value="2.2.1" />
- <property name="junit.version" value="4.10" />
- <property name="log4j.version" value="1.2.16" />
- <property name="servlet-api.version" value="3.0.1" />
+ <property name="findbugs.version" value="2.0.0" />
+ <property name="findbugs-bcel.version" value="2.0.0" />
+ <property name="annotations.version" value="2.0.0" />
+ <property name="asm-tree.version" value="3.3.1" />
+
+ <property name="findbugs-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.jar" />
+ <property name="findbugs-bcel-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/bcel/${findbugs-bcel.version}/bcel-${findbugs-bcel.version}.jar" />
+ <property name="annotations-url" value="http://repo1.maven.org/maven2/com/google/code/findbugs/annotations/${annotations.version}/annotations-${annotations.version}.jar" />
+ <property name="asm-tree-url" value="http://repo1.maven.org/maven2/asm/asm-tree/${asm-tree.version}/asm-tree-${asm-tree.version}.jar" />
+
+ <!-- properties for samples lib dependencies -->
+ <property name="commons-lang3.version" value="3.1" />
+ <property name="jsp-api.version" value="2.2.1" />
+ <property name="junit.version" value="4.10" />
+ <property name="log4j.version" value="1.2.16" />
+ <property name="servlet-api.version" value="3.0.1" />
<property name="backport-concurrent.version" value="3.1" />
+ <property name="commons-collections.version" value="3.2.1" />
- <property name="commons-lang3-url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.jar"/>
- <property name="jsp-api-url" value="http://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/${jsp-api.version}/javax.servlet.jsp-api-${jsp-api.version}.jar" />
- <property name="junit-url" value="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar"/>
- <property name="log4j-url" value="http://repo1.maven.org/maven2/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar"/>
- <property name="servlet-api-url" value="http://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/${servlet-api.version}/javax.servlet-api-${servlet-api.version}.jar"/>
- <property name="backport-concurrent-url" value="http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/${backport-concurrent.version}/backport-util-concurrent-${backport-concurrent.version}.jar" />
+ <property name="commons-lang3-url" value="http://repo1.maven.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.jar" />
+ <property name="jsp-api-url" value="http://repo1.maven.org/maven2/javax/servlet/jsp/javax.servlet.jsp-api/${jsp-api.version}/javax.servlet.jsp-api-${jsp-api.version}.jar" />
+ <property name="junit-url" value="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar" />
+ <property name="log4j-url" value="http://repo1.maven.org/maven2/log4j/log4j/${log4j.version}/log4j-${log4j.version}.jar" />
+ <property name="servlet-api-url" value="http://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/${servlet-api.version}/javax.servlet-api-${servlet-api.version}.jar" />
+ <property name="backport-concurrent-url" value="http://repo1.maven.org/maven2/backport-util-concurrent/backport-util-concurrent/${backport-concurrent.version}/backport-util-concurrent-${backport-concurrent.version}.jar" />
+ <property name="commons-collection-url" value="http://repo1.maven.org/maven2/commons-collections/commons-collections/${commons-collections.version}/commons-collections-${commons-collections.version}.jar" />
+ <target name="check">
+ <available file="${dest}/${name}-${version}.jar" property="jar-exists" />
+ </target>
+
+ <target name="_pull" depends="check" unless="jar-exists">
+ <get src="${url}" dest="${dest}/${name}-${version}.jar" verbose="true" ignoreerrors="true" />
+ </target>
+
+ <macrodef name="pull">
+ <attribute name="url" />
+ <attribute name="dest" />
+ <attribute name="name" />
+ <attribute name="version" />
+
+ <sequential>
+ <antcall target="_pull">
+ <param name="url" value="@{url}" />
+ <param name="dest" value="@{dest}" />
+ <param name="name" value="@{name}" />
+ <param name="version" value="@{version}" />
+ </antcall>
+ </sequential>
+ </macrodef>
+
+ <target name="pullall">
+ <pull url="${findbugs-url}" dest="${lib.dir}" name="findbugs" version="${findbugs.version}" />
+ <pull url="${findbugs-bcel-url}" dest="${lib.dir}" name="findbugs-bcel" version="${findbugs-bcel.version}" />
+ <pull url="${annotations-url}" dest="${lib.dir}" name="annotations" version="${annotations.version}" />
+ <pull url="${asm-tree-url}" dest="${lib.dir}" name="asm-tree" version="${asm-tree.version}" />
+ <pull url="${commons-lang3-url}" dest="${sampleslib.dir}" name="commons-lang3" version="${commons-lang3.version}" />
+ <pull url="${jsp-api-url}" dest="${sampleslib.dir}" name="jsp-api" version="${jsp-api.version}" />
+ <pull url="${junit-url}" dest="${sampleslib.dir}" name="junit" version="${junit.version}" />
+ <pull url="${log4j-url}" dest="${sampleslib.dir}" name="log4j" version="${log4j.version}" />
+ <pull url="${servlet-api-url}" dest="${sampleslib.dir}" name="servlet-api" version="${servlet-api.version}" />
+ <pull url="${backport-concurrent-url}" dest="${sampleslib.dir}" name="backport-concurrent" version="${backport-concurrent.version}" />
+ <pull url="${commons-collection-url}" dest="${sampleslib.dir}" name="commons-collection" version="${commons-collection.version}" />
+ </target>
+
<target name="clean" description="removes all generated collateral">
- <delete dir="${classes.dir}"/>
- <delete dir="${javadoc.dir}"/>
- <delete file="${htdocs.dir}/bugdescriptions.html"/>
- <delete file="${basedir}/fb-contrib-${fb-contrib.version}.jar"/>
- <delete file="${basedir}/fb-contrib-src-${fb-contrib.version}.zip"/>
+ <delete dir="${classes.dir}" />
+ <delete dir="${javadoc.dir}" />
+ <delete file="${htdocs.dir}/bugdescriptions.html" />
+ <delete file="${basedir}/fb-contrib-${fb-contrib.version}.jar" />
+ <delete file="${basedir}/fb-contrib-src-${fb-contrib.version}.zip" />
<delete>
<fileset dir="${samples.dir}">
- <include name="**/*.class"/>
+ <include name="**/*.class" />
</fileset>
</delete>
- <delete dir="${basedir}/plugin"/>
+ <delete dir="${basedir}/plugin" />
</target>
<target name="-init" description="prepares repository for a build">
- <mkdir dir="${lib.dir}"/>
- <mkdir dir="${sampleslib.dir}"/>
- <mkdir dir="${classes.dir}"/>
- <mkdir dir="${javadoc.dir}"/>
+ <mkdir dir="${lib.dir}" />
+ <mkdir dir="${sampleslib.dir}" />
+ <mkdir dir="${classes.dir}" />
+ <mkdir dir="${javadoc.dir}" />
<path id="fb-contrib.classpath">
- <pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar"/>
- <pathelement location="${lib.dir}/bcel-${findbugs-bcel.version}.jar"/>
- <pathelement location="${lib.dir}/annotations-${annotations.version}.jar"/>
- <pathelement location="${lib.dir}/asm-tree-${asm-tree.version}.jar"/>
+ <pathelement location="${lib.dir}/findbugs-${findbugs.version}.jar" />
+ <pathelement location="${lib.dir}/bcel-${findbugs-bcel.version}.jar" />
+ <pathelement location="${lib.dir}/annotations-${annotations.version}.jar" />
+ <pathelement location="${lib.dir}/asm-tree-${asm-tree.version}.jar" />
</path>
<path id="fb-contrib.samples.classpath">
- <pathelement location="${sampleslib.dir}/jsp-api-${jsp-api.version}.jar"/>
- <pathelement location="${sampleslib.dir}/junit-${junit.version}.jar"/>
- <pathelement location="${sampleslib.dir}/servlet-api-${servlet-api.version}.jar"/>
- <pathelement location="${sampleslib.dir}/log4j-${log4j.version}.jar"/>
- <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar"/>
- <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar"/>
- <pathelement location="${sampleslib.dir}/backport-util-concurrent-${backport-concurrent.version}.jar"/>
+ <pathelement location="${sampleslib.dir}/jsp-api-${jsp-api.version}.jar" />
+ <pathelement location="${sampleslib.dir}/junit-${junit.version}.jar" />
+ <pathelement location="${sampleslib.dir}/servlet-api-${servlet-api.version}.jar" />
+ <pathelement location="${sampleslib.dir}/log4j-${log4j.version}.jar" />
+ <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar" />
+ <pathelement location="${sampleslib.dir}/commons-lang3-${commons-lang3.version}.jar" />
+ <pathelement location="${sampleslib.dir}/backport-util-concurrent-${backport-concurrent.version}.jar" />
</path>
- <mkdir dir="${classes.dir}/com"/>
- <mkdir dir="${classes.dir}/com/mebigfatguy"/>
- <mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib"/>
- <mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib/detect"/>
- <echo message="*.class" file="${classes.dir}/com/mebigfatguy/fbcontrib/detect/.cvsignore"/>
+ <mkdir dir="${classes.dir}/com" />
+ <mkdir dir="${classes.dir}/com/mebigfatguy" />
+ <mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib" />
+ <mkdir dir="${classes.dir}/com/mebigfatguy/fbcontrib/detect" />
+ <echo message="*.class" file="${classes.dir}/com/mebigfatguy/fbcontrib/detect/.cvsignore" />
</target>
-
- <target name="findbugs-check">
- <available file="${basedir}/lib/findbugs-${findbugs.version}.jar" property="findbugs-exists"/>
- </target>
- <target name="findbugs-bcel-check">
- <available file="${basedir}/lib/bcel-${findbugs-bcel.version}.jar" property="findbugs-bcel-exists"/>
- </target>
-
- <target name="annotations-check">
- <available file="${basedir}/lib/annotations-${annotations.version}.jar" property="annotations-exists"/>
- </target>
-
- <target name="asm-tree-check">
- <available file="${basedir}/lib/asm-tree-${asm-tree.version}.jar" property="asm-tree-exists"/>
- </target>
-
- <target name="commons-lang3-check">
- <available file="${basedir}/samples/lib/commons-lang3-${commons-lang3.version}.jar" property="commons-lang3-exists"/>
- </target>
-
- <target name="servlet-api-check">
- <available file="${basedir}/samples/lib/servlet-api-${servlet-api.version}.jar" property="servlet-api-exists"/>
- </target>
-
- <target name="backport-concurrent-check">
- <available file="${basedir}/samples/lib/backport-util-concurrent-${backport-concurrent.version}.jar" property="backport-concurrent-exists" />
- </target>
-
- <target name="jsp-api-check">
- <available file="${basedir}/samples/lib/jsp-api-${jsp-api.version}.jar" property="jsp-api-exists"/>
- </target>
-
- <target name="log4j-check">
- <available file="${basedir}/samples/lib/log4j-${log4j.version}.jar" property="log4j-exists"/>
- </target>
-
- <target name="junit-check">
- <available file="${basedir}/samples/lib/junit-${junit.version}.jar" property="junit-exists"/>
- </target>
-
- <target name="install-findbugs" depends="findbugs-check" unless="findbugs-exists" description="installs findbugs.jar into lib">
- <get src="${findbugs-url}" dest="${basedir}/lib/findbugs-${findbugs.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-findbugs-bcel" depends="findbugs-bcel-check" unless="findbugs-bcel-exists" description="installs findbugs-bcel.jar into lib">
- <get src="${findbugs-bcel-url}" dest="${basedir}/lib/bcel-${findbugs-bcel.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-annotations" depends="annotations-check" unless="annotations-exists" description="installs annotations.jar into lib">
- <get src="${annotations-url}" dest="${basedir}/lib/annotations-${annotations.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-asm-tree" depends="asm-tree-check" unless="asm-tree-exists" description="installs asm-tree.jar into lib">
- <get src="${asm-tree-url}" dest="${basedir}/lib/asm-tree-${asm-tree.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-commons-lang3" depends="commons-lang3-check" unless="commons-lang3-exists" description="installs commons-lang3 into samples/lib">
- <get src="${commons-lang3-url}" dest="${basedir}/samples/lib/commons-lang3-${commons-lang3.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-servlet-api" depends="servlet-api-check" unless="servlet-api-exists" description="installs servlet-api into samples/lib">
- <get src="${servlet-api-url}" dest="${basedir}/samples/lib/servlet-api-${servlet-api.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-backport-concurrent" depends="backport-concurrent-check" unless="backport-concurrent-exists" description="installs backport-concurrent into samples/lib">
- <get src="${backport-concurrent-url}" dest="${basedir}/samples/lib/backport-util-concurrent-${backport-concurrent.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-jsp-api" depends="jsp-api-check" unless="jsp-api-exists" description="installs jsp-api into samples/lib">
- <get src="${jsp-api-url}" dest="${basedir}/samples/lib/jsp-api-${jsp-api.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-log4j" depends="log4j-check" unless="log4j-exists" description="installs log4j into samples/lib">
- <get src="${log4j-url}" dest="${basedir}/samples/lib/log4j-${log4j.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="install-junit" depends="junit-check" unless="junit-exists" description="installs junit into samples/lib">
- <get src="${junit-url}" dest="${basedir}/samples/lib/junit-${junit.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
- <target name="pull" depends="install-findbugs, install-findbugs-bcel, install-annotations, install-asm-tree, install-commons-lang3, install-servlet-api, install-backport-concurrent, install-jsp-api, install-log4j, install-junit" description="pull 3rdparty jars to the lib directory"/>
-
<target name="validate_xml" depends="-init" description="validates the xml files">
<xmlvalidate lenient="false" failonerror="yes">
- <attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
- <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
- <fileset dir="${etc.dir}" includes="*.xml"/>
+ <attribute name="http://apache.org/xml/features/validation/schema" value="true" />
+ <attribute name="http://xml.org/sax/features/namespaces" value="true" />
+ <fileset dir="${etc.dir}" includes="*.xml" />
</xmlvalidate>
</target>
- <target name="compile" depends="-init, pull" description="compiles java files">
- <javac srcdir="${src.dir}"
- destdir="${classes.dir}"
- source="${javac.source}"
- target="${javac.target}"
- deprecation="${javac.deprecation}"
- debug="${javac.debug}"
- includeantruntime="false">
- <classpath refid="fb-contrib.classpath"/>
+ <target name="compile" depends="-init, pullall" description="compiles java files">
+ <javac srcdir="${src.dir}" destdir="${classes.dir}" source="${javac.source}" target="${javac.target}" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false">
+ <classpath refid="fb-contrib.classpath" />
</javac>
</target>
<target name="compile_samples" depends="-init" description="compiles sample problem files">
- <javac srcdir="${samples.dir}"
- destdir="${samples.dir}"
- source="1.5"
- target="1.5"
- deprecation="${javac.deprecation}"
- debug="${javac.debug}"
- includeantruntime="false">
- <classpath refid="fb-contrib.classpath"/>
- <classpath refid="fb-contrib.samples.classpath"/>
+ <javac srcdir="${samples.dir}" destdir="${samples.dir}" source="1.5" target="1.5" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false">
+ <classpath refid="fb-contrib.classpath" />
+ <classpath refid="fb-contrib.samples.classpath" />
</javac>
- <delete file="${samples.dir}/SJVU_Sample.class"/>
- <javac srcdir="${samples.dir}"
- destdir="${samples.dir}"
- source="1.4"
- target="1.4"
- deprecation="${javac.deprecation}"
- debug="${javac.debug}"
- includeantruntime="false">
- <include name="SJVU_Sample.java"/>
- <classpath refid="fb-contrib.classpath"/>
- <classpath refid="fb-contrib.samples.classpath"/>
+ <delete file="${samples.dir}/SJVU_Sample.class" />
+ <javac srcdir="${samples.dir}" destdir="${samples.dir}" source="1.4" target="1.4" deprecation="${javac.deprecation}" debug="${javac.debug}" includeantruntime="false">
+ <include name="SJVU_Sample.java" />
+ <classpath refid="fb-contrib.classpath" />
+ <classpath refid="fb-contrib.samples.classpath" />
</javac>
</target>
<target name="jar" depends="compile" description="produces the fb-contrib jar file">
<jar destfile="${basedir}/fb-contrib-${fb-contrib.version}.jar">
<fileset dir="etc">
- <include name="findbugs.xml"/>
- <include name="messages*.xml"/>
- <include name="bugrank.txt"/>
- <include name="*.license"/>
+ <include name="findbugs.xml" />
+ <include name="messages*.xml" />
+ <include name="bugrank.txt" />
+ <include name="*.license" />
</fileset>
<fileset dir="${classes.dir}">
- <include name="**/*.class"/>
+ <include name="**/*.class" />
</fileset>
<fileset dir="${basedir}">
- <include name="plugin.xml"/>
- <include name="license.txt"/>
+ <include name="plugin.xml" />
+ <include name="license.txt" />
</fileset>
<manifest>
- <attribute name="fb-contrib-version" value="${fb-contrib.version}"/>
- <attribute name="Main-Class" value="com.mebigfatguy.fbcontrib.FBContrib"/>
- <attribute name="Eclipse-RegisterBuddy" value="edu.umd.cs.findbugs.plugin.eclipse"/>
- <attribute name="Bundle-ManifestVersion" value="2"/>
- <attribute name="Bundle-Name" value="fb-contrib plugin"/>
- <attribute name="Bundle-SymbolicName" value="fb-contrib; singleton:=true"/>
- <attribute name="Bundle-Version" value="${fb-contrib.version}"/>
- <attribute name="Bundle-ClassPath" value="."/>
- <attribute name="Bundle-Vendor" value="FB-Contrib Project"/>
- <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse"/>
- <attribute name="Bundle-ActivationPolicy" value="lazy"/>
+ <attribute name="fb-contrib-version" value="${fb-contrib.version}" />
+ <attribute name="Main-Class" value="com.mebigfatguy.fbcontrib.FBContrib" />
+ <attribute name="Eclipse-RegisterBuddy" value="edu.umd.cs.findbugs.plugin.eclipse" />
+ <attribute name="Bundle-ManifestVersion" value="2" />
+ <attribute name="Bundle-Name" value="fb-contrib plugin" />
+ <attribute name="Bundle-SymbolicName" value="fb-contrib; singleton:=true" />
+ <attribute name="Bundle-Version" value="${fb-contrib.version}" />
+ <attribute name="Bundle-ClassPath" value="." />
+ <attribute name="Bundle-Vendor" value="FB-Contrib Project" />
+ <attribute name="Require-Bundle" value="edu.umd.cs.findbugs.plugin.eclipse" />
+ <attribute name="Bundle-ActivationPolicy" value="lazy" />
</manifest>
</jar>
</target>
<target name="html" depends="-init" description="generates dynamic html">
- <xslt basedir="${etc.dir}"
- destdir="${htdocs.dir}"
- style="${etc.dir}/bugdescriptions.xsl"
- in="${etc.dir}/messages.xml" out="${htdocs.dir}/bugdescriptions.html"/>
+ <xslt basedir="${etc.dir}" destdir="${htdocs.dir}" style="${etc.dir}/bugdescriptions.xsl" in="${etc.dir}/messages.xml" out="${htdocs.dir}/bugdescriptions.html" />
</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}">
- <include name="**/*.java"/>
- <include name="**/*.xml"/>
- <include name="**/*.xsd"/>
- <include name="**/*.license"/>
- <include name="**/*.txt"/>
- <include name="lib/*.jar"/>
+ <include name="**/*.java" />
+ <include name="**/*.xml" />
+ <include name="**/*.xsd" />
+ <include name="**/*.license" />
+ <include name="**/*.txt" />
+ <include name="lib/*.jar" />
</fileset>
</zip>
</target>
<target name="javadoc" depends="-init" description="build the javadoc for the project">
- <javadoc packagenames="com.mebigfatguy.*"
- sourcepath="${src.dir}"
- classpathref="fb-contrib.classpath"
- destdir="${javadoc.dir}"
- windowtitle="fb-contrib api">
- <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle>
- <bottom><![CDATA[<i>Copyright © 2005-2012 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
+ <javadoc packagenames="com.mebigfatguy.*" sourcepath="${src.dir}" classpathref="fb-contrib.classpath" destdir="${javadoc.dir}" windowtitle="fb-contrib api">
+ <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle>
+ <bottom><![CDATA[<i>Copyright © 2005-2012 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
<target name="build" depends="clean, -init, validate_xml, compile, compile_samples, jar" description="builds the plugin jar">
</target>
- <target name="install" depends="build" description="installs the plugin into FindBugs">
- <property environment="env"/>
+ <target name="install" depends="build" description="installs the plugin into FindBugs">
+ <property environment="env" />
<copy todir="${env.FINDBUGS_HOME}/plugin">
<fileset dir="${basedir}">
- <include name="fb-contrib-${fb-contrib.version}.jar"/>
+ <include name="fb-contrib-${fb-contrib.version}.jar" />
</fileset>
</copy>
</target>
- <target name="release" depends="build, srczip, html, javadoc" description="prepares everything for a release"/>
+ <target name="release" depends="build, srczip, html, javadoc" description="prepares everything for a release" />
</project>
Modified: trunk/fb-contrib/samples/PCAIL_Sample.java
===================================================================
--- trunk/fb-contrib/samples/PCAIL_Sample.java 2012-02-03 23:16:26 UTC (rev 1714)
+++ trunk/fb-contrib/samples/PCAIL_Sample.java 2012-07-04 23:24:26 UTC (rev 1715)
@@ -65,6 +65,28 @@
}
}
+ public List<PCAIL_Sample> fpAnonymousMethodParm()
+ {
+ List<PCAIL_Sample> col = new ArrayList<PCAIL_Sample>();
+ for (int i = 0; i < 10; i++)
+ {
+ col.add(new PCAIL_Sample());
+ }
+
+ return col;
+ }
+
+ public List<PCAIL_Sample> fpAnonymousBuilder()
+ {
+ List<PCAIL_Sample> col = new ArrayList<PCAIL_Sample>();
+ for (int i = 0; i < 10; i++)
+ {
+ col.add(new PCAIL_Sample().builder());
+ }
+
+ return col;
+ }
+
public void fpArrayStore()
{
PCAIL_Sample[] samples = new PCAIL_Sample[3];
@@ -105,6 +127,11 @@
}
}
+ private PCAIL_Sample builder()
+ {
+ return this;
+ }
+
static class Foo
{
public Foo withNumber(int i)
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2012-02-03 23:16:26 UTC (rev 1714)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java 2012-07-04 23:24:26 UTC (rev 1715)
@@ -105,7 +105,7 @@
if ((firstBlock.getCatchType() == secondBlock.getCatchType())
&& (firstBlock.getThrowSignature().equals(secondBlock.getThrowSignature())
- && (firstBlock.getMessage().equals(secondBlock.getMessage())
+ && ((firstBlock.getMessage().length() > 0) && firstBlock.getMessage().equals(secondBlock.getMessage())
&& (firstBlock.getExce...
[truncated message content] |