fb-contrib-commit Mailing List for fb-contrib
Brought to you by:
dbrosius
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(56) |
Oct
(60) |
Nov
(58) |
Dec
(89) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(66) |
Feb
(55) |
Mar
(85) |
Apr
(115) |
May
(35) |
Jun
(28) |
Jul
(3) |
Aug
(48) |
Sep
(37) |
Oct
(22) |
Nov
(14) |
Dec
(66) |
2007 |
Jan
(45) |
Feb
(63) |
Mar
(10) |
Apr
(1) |
May
(1) |
Jun
(12) |
Jul
|
Aug
|
Sep
(25) |
Oct
(21) |
Nov
(39) |
Dec
|
2008 |
Jan
(7) |
Feb
|
Mar
(26) |
Apr
(5) |
May
(2) |
Jun
(32) |
Jul
(9) |
Aug
(10) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
|
2009 |
Jan
(10) |
Feb
(31) |
Mar
(32) |
Apr
(35) |
May
(25) |
Jun
|
Jul
(31) |
Aug
(10) |
Sep
(95) |
Oct
(35) |
Nov
(10) |
Dec
(34) |
2010 |
Jan
(90) |
Feb
(4) |
Mar
(7) |
Apr
(20) |
May
(20) |
Jun
(13) |
Jul
(7) |
Aug
(18) |
Sep
(25) |
Oct
(4) |
Nov
(16) |
Dec
(2) |
2011 |
Jan
(1) |
Feb
|
Mar
(11) |
Apr
(3) |
May
(2) |
Jun
(26) |
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(14) |
Nov
(3) |
Dec
(4) |
2013 |
Jan
(3) |
Feb
(2) |
Mar
(1) |
Apr
(4) |
May
|
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(3) |
2014 |
Jan
(4) |
Feb
(2) |
Mar
(4) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
(2) |
Nov
(7) |
Dec
|
2017 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(3) |
2018 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
(5) |
Jun
(2) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dbr...@us...> - 2018-07-21 17:45:36
|
Revision: 1842 http://sourceforge.net/p/fb-contrib/code/1842 Author: dbrosius Date: 2018-07-21 17:45:34 +0000 (Sat, 21 Jul 2018) Log Message: ----------- Version 7.4.3 Added Paths: ----------- tags/v7_4_3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-07-21 17:43:54
|
Revision: 1841 http://sourceforge.net/p/fb-contrib/code/1841 Author: dbrosius Date: 2018-07-21 17:43:49 +0000 (Sat, 21 Jul 2018) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java trunk/fb-contrib/src/samples/java/ex/AI_Sample.java trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java Added Paths: ----------- trunk/fb-contrib/yank.csv Removed Paths: ------------- trunk/fb-contrib/yank.xls Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/build.xml 2018-07-21 17:43:49 UTC (rev 1841) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.4.2" /> + <property name="fb-contrib.version" value="7.4.3" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -42,7 +42,7 @@ <target name="infra_jars" description="pull jars needed to build fb-contrib to ${user.dir}/.ant/lib"> <mkdir dir="${user.home}/.ant/lib" /> - <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/2.0.0/yank-2.0.0.jar" dest="${user.home}/.ant/lib"/> + <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/2.0.1/yank-2.0.1.jar" dest="${user.home}/.ant/lib"/> <get src="https://bitbucket.org/kjlubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.4.0/vcsversion-0.4.0.jar" dest="${user.home}/.ant/lib"/> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/fb-delta/fb-delta/0.6.0/fb-delta-0.6.0.jar" dest="${user.home}/.ant/lib" ignoreerrors="true"/> @@ -151,7 +151,7 @@ </path> </target> - <target name="validate_xml" depends="-init" description="validates the xml files"> + <target name="validate_xml" depends="-init" unless="skip-validate" description="validates the xml files"> <taskdef name="bug-rank-check-style" classname="text.style.check.BugRankCheckStyleTask"/> <xmlvalidate lenient="false" failonerror="yes"> <attribute name="http://apache.org/xml/features/validation/schema" value="true" /> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/etc/messages.xml 2018-07-21 17:43:49 UTC (rev 1841) @@ -6190,6 +6190,9 @@ produces a far simpler instance of List. Since both of these arrays are immutable (from the List's point of view) they are equivalent from a usage standpoint. </p> + <p>There is one difference between Array.asList and Collections.singletonList that you should be mindful of. The rarely used set(index, value) method is + allowed to be used with a List created by Array.asList, but not with Collections.singletonList. So if you do use the set(index, value) method + continue using Arrays.asList. ]]> </Details> </BugPattern> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/htdocs/index.shtml 2018-07-21 17:43:49 UTC (rev 1841) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.4.2 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.4.3 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/htdocs/repository.html 2018-07-21 17:43:49 UTC (rev 1841) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.4.2 or 7.4.2.sb</td></tr> + <tr><td><b>Version:</b></td><td>7.4.3 or 7.4.3.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/pom.xml 2018-07-21 17:43:49 UTC (rev 1841) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.4.2</version> + <version>7.4.3</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> @@ -90,6 +90,9 @@ <contributor> <name>David Burström</name> </contributor> + <contributor> + <name>Venkata Gajavalli</name> + </contributor> </contributors> <licenses> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2018-07-21 17:43:49 UTC (rev 1841) @@ -138,7 +138,8 @@ String clsName = getClassName(); Method method = getMethod(); int accessFlags = method.getAccessFlags(); - MethodInfo mi = Statistics.getStatistics().addMethodStatistics(clsName, getMethodName(), getMethodSig(), accessFlags, obj.getLength(), numMethodCalls); + MethodInfo mi = Statistics.getStatistics().addMethodStatistics(clsName, getMethodName(), getMethodSig(), accessFlags, code.length, + numMethodCalls); if ((clsName.indexOf(Values.INNER_CLASS_SEPARATOR) >= 0) || ((accessFlags & (ACC_ABSTRACT | ACC_INTERFACE | ACC_ANNOTATION)) != 0)) { mi.addCallingAccess(Constants.ACC_PUBLIC); } else if ((accessFlags & Constants.ACC_PRIVATE) == 0) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java 2018-07-21 17:43:49 UTC (rev 1841) @@ -18,11 +18,11 @@ */ package com.mebigfatguy.fbcontrib.collect; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import com.mebigfatguy.fbcontrib.utils.FQMethod; import com.mebigfatguy.fbcontrib.utils.ToString; @@ -38,7 +38,7 @@ private static Statistics statistics = new Statistics(); private static final MethodInfo NOT_FOUND_METHOD_INFO = new MethodInfo(); - private final Map<FQMethod, MethodInfo> methodStatistics = new HashMap<>(); + private final Map<FQMethod, MethodInfo> methodStatistics = new ConcurrentHashMap<>(); private final Set<String> autowiredBeans = new HashSet<>(); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2018-07-21 17:43:49 UTC (rev 1841) @@ -79,7 +79,7 @@ NULLABLE_ANNOTATIONS.add("Lcom/sun/istack/Nullable;"); NULLABLE_ANNOTATIONS.add("Ledu/umd/cs/findbugs/annotations/Nullable;"); NULLABLE_ANNOTATIONS.add("Lorg/springframework/lang/Nullable;"); - NULLABLE_ANNOTATIONS.add("Landroid/support/annotations/Nullable"); + NULLABLE_ANNOTATIONS.add("Landroid/support/annotation/Nullable"); String userAnnotations = System.getProperty(USER_NULLABLE_ANNOTATIONS); if ((userAnnotations != null) && !userAnnotations.isEmpty()) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2018-07-21 17:43:49 UTC (rev 1841) @@ -64,6 +64,8 @@ public static final String PRMC_HIGH_METHODCALLS = "fbcontrib.PRMC.highmethodcalls"; public static final String PRMC_NORMAL_BYTECOUNT = "fbcontrib.PRMC.normalbytecount"; public static final String PRMC_NORMAL_METHODCALLS = "fbcontrib.PRMC.normalmethodcalls"; + public static final String PRMC_LOW_BYTECOUNT = "fbcontrib.PRMC.lowbytecount"; + public static final String PRMC_LOW_METHODCALLS = "fbcontrib.PRMC.lowmethodcalls"; /** * a collection of names that are to be checked against a currently parsed method, to see if that method is risky to be called redundant. The contents are @@ -76,8 +78,10 @@ private static Set<String> riskyMethodNameContents = new HashSet<>(); private static int highByteCountLimit = 200; private static int highMethodCallLimit = 10; - private static int normalByteCountLimit = 50; + private static int normalByteCountLimit = 75; private static int normalMethodCallLimit = 4; + private static int lowByteCountLimit = 10; + private static int lowMethodCallLimit = 1; static { riskyMethodNameContents.add("next"); @@ -130,6 +134,14 @@ if (prop != null) { normalMethodCallLimit = prop.intValue(); } + prop = Integer.getInteger(PRMC_LOW_BYTECOUNT); + if (prop != null) { + lowByteCountLimit = prop.intValue(); + } + prop = Integer.getInteger(PRMC_LOW_METHODCALLS); + if (prop != null) { + lowMethodCallLimit = prop.intValue(); + } } private static Set<String> riskyClassNames = new HashSet<>(); @@ -372,8 +384,7 @@ if (mc != null) { if (!signature.endsWith(Values.SIG_VOID) && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) - && !isRiskyName(className, methodName) - && !commonMethods.contains(new FQMethod(getClassConstantOperand(), methodName, signature))) { + && !isRiskyName(className, methodName) && !commonMethods.contains(new FQMethod(className, methodName, signature))) { Object[] parms = mc.getParms(); if (Arrays.equals(parms, parmConstants)) { int ln = getLineNumber(pc); @@ -380,7 +391,7 @@ if ((ln != mc.getLineNumber()) || (Math.abs(pc - mc.getPC()) < 10)) { Statistics statistics = Statistics.getStatistics(); - MethodInfo mi = statistics.getMethodStatistics(getClassConstantOperand(), methodName, signature); + MethodInfo mi = statistics.getMethodStatistics(className, methodName, signature); bugReporter.reportBug( new BugInstance(this, BugType.PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS.name(), getBugPriority(methodName, mi)) @@ -461,7 +472,7 @@ return NORMAL_PRIORITY; } - if ((mi.getNumBytes() == 0) || (mi.getNumMethodCalls() == 0)) { + if ((mi.getNumBytes() >= lowByteCountLimit) || (mi.getNumMethodCalls() >= lowMethodCallLimit)) { return LOW_PRIORITY; } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java 2018-07-21 17:43:49 UTC (rev 1841) @@ -37,7 +37,7 @@ private static final QMethod SETACCESSIBLE = new QMethod("setAccessible", SignatureBuilder.SIG_BOOLEAN_TO_VOID); private static final FQMethod SETACCESSIBLE_ARRAY = new FQMethod("java/lang/reflect/AccessibleObject", "setAccessible", - new SignatureBuilder().withParamTypes(AccessibleObject.class).build()); + new SignatureBuilder().withParamTypes(AccessibleObject[].class, boolean.class).build()); private static final JavaClass ACCESSIBLE_OBJECT_CLASS; static { Modified: trunk/fb-contrib/src/samples/java/ex/AI_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/AI_Sample.java 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/src/samples/java/ex/AI_Sample.java 2018-07-21 17:43:49 UTC (rev 1841) @@ -97,6 +97,23 @@ return ss; } + public String fpGetProperty296(final String key, final String defaultValue) { + String strResult = getProperty(key); + if (strResult != null) { + return strResult; + } else { + putDefault(key, defaultValue); + return defaultValue; + } + } + + public String getProperty(final String key) { + return Math.random() > 0.5 ? null : ""; + } + + private void putDefault(String key, String value) { + } + interface Stringer { String get(); } Modified: trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java 2018-06-01 00:39:50 UTC (rev 1840) +++ trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java 2018-07-21 17:43:49 UTC (rev 1841) @@ -106,6 +106,15 @@ List p = Collections.emptyList(); } + public void fpSimpleGetter() { + getData(); + getData(); + } + + public String getData() { + return data; + } + enum FPEnum { fee, fi, fo, fum }; Added: trunk/fb-contrib/yank.csv =================================================================== --- trunk/fb-contrib/yank.csv (rev 0) +++ trunk/fb-contrib/yank.csv 2018-07-21 17:43:49 UTC (rev 1841) @@ -0,0 +1,73 @@ +"GroupId","ArtifactId","Version","Digest" +,,, +"com.google.code.findbugs","findbugs","3.0.1","7ae69957c437fd71628d3904572170cf80c01551" +,"bcel-findbugs","6.0","7a7563ba41dceff3da4af4927b7c09908bd5132c" +,"findbugs-annotations","3.0.1","0bf2342edabc0fc37fc0b1de0b03f071bef935c3" +,"findbugs-ant","3.0.0","56f704b2769296de1b86102caefb6e8bd8b979af" +,"jsr305","3.0.2","25ea2e8b0c338a877313bd4672d3fe056ea78f0d" +,,, +"jaxen","jaxen","1.1.6","3f8c36d9a0578e8e98f030c662b69888b1430ac0" +,,, +"dom4j","dom4j","1.6.1","5d3ccc056b6f056dbf0dddfdf43894b9065a8f94" +,,, +"org.ow2.asm","asm-debug-all","5.0.2","5742eaa4eb2f0583b642eb2a2a7597c996139103" +,,, +"org.testng","testng","6.9.10","6feb3e964aeb7097aff30c372aac3ec0f8d87ede" +,,, +"com.beust","jcommander","1.48","bfcb96281ea3b59d626704f74bc6d625ff51cbce" +,,, +"org.beanshell","bsh","2.0b4","a05f0a0feefa8d8467ac80e16e7de071489f0d9c" +,,, +"com.google.inject","guice","4.1.0","eeb69005da379a10071aa4948c48d89250febb07" +,,, +"----- Jars for Samples ----",,, +,,, +"org.apache.commons","commons-lang3","3.4","5fe28b9518e58819180a43a850fbc0dd24b7c050" +,,, +"javax.servlet.jsp","javax.servlet.jsp-api","2.3.1","95c630902565feda8155eb32d46064ef348435fc" +,,, +"junit","junit","4.12","2973d150c0dc1fefe998f834810d68f278ea58ec" +,,, +"log4j","log4j","1.2.17","5af35056b4d257e4b64b9e8069c0746e8b08629f" +,,, +"org.apache.logging.log4j","log4j-api","2.9.1","7a2999229464e7a324aa503c0a52ec0f05efe7bd" +,,, +"javax.servlet","javax.servlet-api","3.1.0","3cd63d075497751784b2fa84be59432f4905bf7c" +,,, +"backport-util-concurrent","backport-util-concurrent","3.1","682f7ac17fed79e92f8e87d8455192b63376347b" +,,, +"org.threeten","threetenbp","1.3.2","6ef0f1feae9c5b5cce4b3478e8f1541d1c86ec2a" +,,, +"commons-collections","commons-collections","3.2.2","8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5" +,,, +"org.slf4j","slf4j-api","1.7.21","139535a69a4239db087de9bab0bee568bf8e0b70" +,,, +"com.google.guava","guava","19.0","6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9" +,,, +"org.apache.httpcomponents","httpclient","4.5.2","733db77aa8d9b2d68015189df76ab06304406e50" +,"httpcore","4.4.5","e7501a1b34325abb00d17dde96150604a0658b54" +,"httpclient-cache","4.5.2","bd50ea83908dbf2f387a333216e66d2f0c5079bd" +,,, +"commons-codec","commons-codec","1.10","4b95f4897fa13f2cd904aee711aeafc0c5295cd8" +,,, +"javax.ws.rs","javax.ws.rs-api","2.0.1","104e9c2b5583cfcfeac0402316221648d6d8ea6b" +,,, +"org.glassfish.jersey.media","jersey-media-multipart","2.25.1","1d2db0078ee1b740c4e7ec7413d328a8a7e1c480" +,,, +"org.springframework","spring-tx","4.3.3.RELEASE","15fe147d2725b9b85bfe79817dc10b4246d0364d" +,"spring-beans",,"8e446175b4c8f9bf42abfa11e8194cb729171675" +,"spring-context",,"cfcd94c9b28d71e81bdfc058fd386c1aa4a61aea" +,,, +"org.eclipse.persistence","javax.persistence","2.1.1","4954fdf995d5083a1bdbf171ea3b240b88c85bac" +,,, +"commons-io","commons-io","2.4","b1b6ea3b7e4aa4f492509a4952029cd8e48019ad" +,,, +"org.mockito","mockito-core","2.8.47","48840cfced22ec0c07203a0201c5ae7bc12557b5" +,,, +"net.bytebuddy","byte-buddy","1.6.14","871c3e49dc6183d0d361601c2f1d11abb1a6b48c" +,,, +"org.objenesis","objenesis","2.5","612ecb799912ccf77cba9b3ed8c813da086076e9" +,,, +"org.hamcrest","hamcrest-core","1.3","42a25dc3219429f0e5d060061f71acb49bf010a0" +,,, +"org.apache.jena","jena-shaded-guava","3.1.0","6e2400a81e3d6d50a894daa07db0501fc900c659" Property changes on: trunk/fb-contrib/yank.csv ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Deleted: trunk/fb-contrib/yank.xls =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-06-01 00:39:54
|
Revision: 1840 http://sourceforge.net/p/fb-contrib/code/1840 Author: dbrosius Date: 2018-06-01 00:39:50 +0000 (Fri, 01 Jun 2018) Log Message: ----------- Version 7.4.2 Added Paths: ----------- tags/v7_4_2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-06-01 00:35:53
|
Revision: 1839 http://sourceforge.net/p/fb-contrib/code/1839 Author: dbrosius Date: 2018-06-01 00:34:34 +0000 (Fri, 01 Jun 2018) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/.classpath trunk/fb-contrib/build.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java trunk/fb-contrib/src/samples/java/ex/ACEM_Sample.java trunk/fb-contrib/src/samples/java/ex/AI_Sample.java trunk/fb-contrib/src/samples/java/ex/LEST_Sample.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/.classpath 2018-06-01 00:34:34 UTC (rev 1839) @@ -25,7 +25,7 @@ </classpathentry> <classpathentry kind="lib" path="lib/threetenbp-1.3.2.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/> - <classpathentry kind="lib" path="lib/commons-collections-3.2.2.jar"/> + <classpathentry kind="lib" path="lib/commons-collections-3.2.2.jar" sourcepath="/home/dave/.m2/repository/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2-sources.jar"/> <classpathentry kind="lib" path="lib/commons-lang3-3.4.jar"/> <classpathentry kind="lib" path="lib/findbugs-ant-3.0.0.jar"/> <classpathentry kind="lib" path="lib/guava-19.0.jar" sourcepath="lib/sources/guava-19.0-sources.jar"/> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/build.xml 2018-06-01 00:34:34 UTC (rev 1839) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.4.1" /> + <property name="fb-contrib.version" value="7.4.2" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -51,7 +51,7 @@ <target name="yank" xmlns:yank="antlib:com.mebigfatguy.yank" unless="no.yank"> <mkdir dir="${lib.dir}" /> - <yank:yank yankFile="${basedir}/yank.xls" destination="${lib.dir}" proxyServer="${proxy.server}" source="true" separateClassifierTypes="true" checkSHADigests="true"> + <yank:yank yankFile="${basedir}/yank.csv" destination="${lib.dir}" proxyServer="${proxy.server}" source="true" separateClassifierTypes="true" checkSHADigests="true"> <server url="http://repo1.maven.org/maven2" /> <generateVersions propertyFileName="${basedir}/version.properties" /> </yank:yank> @@ -126,8 +126,10 @@ <pathelement location="${lib.dir}/javax.servlet-api-${javax.servlet-api.version}.jar" /> <pathelement location="${lib.dir}/log4j-${log4j.version}.jar" /> <pathelement location="${lib.dir}/log4j-api-${log4j-api.version}.jar" /> - <pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" /> - <pathelement location="${lib.dir}/commons-io-${commons-io.version}.jar" /> + <pathelement location="${lib.dir}/commons-collections-${commons-collections.version}.jar" /> + <pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" /> + <pathelement location="${lib.dir}/commons-io-${commons-io.version}.jar" /> + <pathelement location="${lib.dir}/dom4j-${dom4j.version}.jar" /> <pathelement location="${lib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> <pathelement location="${lib.dir}/threetenbp-${threetenbp.version}.jar" /> <pathelement location="${lib.dir}/slf4j-api-${slf4j-api.version}.jar" /> @@ -139,7 +141,8 @@ <pathelement location="${lib.dir}/spring-beans-${spring-beans.version}.jar" /> <pathelement location="${lib.dir}/spring-context-${spring-context.version}.jar" /> <pathelement location="${lib.dir}/spring-tx-${spring-tx.version}.jar" /> - <pathelement location="${lib.dir}/javax.persistence-${javax.persistence.version}.jar" /> + <pathelement location="${lib.dir}/javax.persistence-${javax.persistence.version}.jar" /> + <pathelement location="${lib.dir}/jaxen-${jaxen.version}.jar" /> <pathelement location="${lib.dir}/mockito-core-${mockito-core.version}.jar" /> <pathelement location="${lib.dir}/hamcrest-core-${hamcrest-core.version}.jar" /> <pathelement location="${lib.dir}/jena-shaded-guava-${jena-shaded-guava.version}.jar" /> @@ -248,7 +251,7 @@ <include name="**/*.license" /> <include name="**/*.txt" /> <include name="**/*.md" /> - <include name="**/*.xls" /> + <include name="**/*.csv" /> <include name="**/*.example" /> <include name="**/*.fbp" /> </fileset> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/htdocs/index.shtml 2018-06-01 00:34:34 UTC (rev 1839) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.4.1 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.4.2 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/htdocs/repository.html 2018-06-01 00:34:34 UTC (rev 1839) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.4.1 or 7.4.1.sb</td></tr> + <tr><td><b>Version:</b></td><td>7.4.2 or 7.4.2.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/pom.xml 2018-06-01 00:34:34 UTC (rev 1839) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.4.1</version> + <version>7.4.2</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -112,7 +112,12 @@ return; } - if (!interfaceMethods.contains(new QMethod(methodName, getMethod().getSignature()))) { + Method m = getMethod(); + if (m.isSynthetic()) { + return; + } + + if (!interfaceMethods.contains(new QMethod(methodName, m.getSignature()))) { super.visitCode(obj); } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -18,9 +18,13 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; @@ -33,9 +37,12 @@ import com.mebigfatguy.fbcontrib.collect.MethodInfo; import com.mebigfatguy.fbcontrib.collect.Statistics; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.CodeByteUtils; import com.mebigfatguy.fbcontrib.utils.FQMethod; +import com.mebigfatguy.fbcontrib.utils.OpcodeUtils; import com.mebigfatguy.fbcontrib.utils.SignatureBuilder; import com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException; +import com.mebigfatguy.fbcontrib.utils.ToString; import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import com.mebigfatguy.fbcontrib.utils.Values; @@ -56,6 +63,13 @@ private static final String USER_NULLABLE_ANNOTATIONS = "fb-contrib.ai.annotations"; + private static final Set<String> IS_EMPTY_SIGNATURES = UnmodifiableSet.create( + // @formatter:off + new SignatureBuilder().withParamTypes(Collection.class).withReturnType(boolean.class).build(), + new SignatureBuilder().withParamTypes(Map.class).withReturnType(boolean.class).build() + // @formatter:on + ); + private static final Set<String> NULLABLE_ANNOTATIONS = new HashSet<>(); static { @@ -82,8 +96,18 @@ // @formatter:on ); - public enum NULLABLE { - TRUE + public static class AIUserValue { + + int reg; + + public AIUserValue(int reg) { + this.reg = reg; + } + + @Override + public String toString() { + return ToString.build(this); + } }; private BugReporter bugReporter; @@ -90,6 +114,7 @@ private Map<Integer, Integer> assumedNullTill; private Map<Integer, Integer> assumedNonNullTill; private Set<Integer> noAssumptionsPossible; + private List<Integer> branchTargets; private OpcodeStack stack; private boolean methodIsNullable; @@ -117,6 +142,7 @@ assumedNullTill = new HashMap<>(); assumedNonNullTill = new HashMap<>(); noAssumptionsPossible = new HashSet<>(); + branchTargets = new ArrayList<>(); super.visitClassContext(classContext); } } @@ -125,6 +151,7 @@ assumedNullTill = null; assumedNonNullTill = null; noAssumptionsPossible = null; + branchTargets = null; } } @@ -171,6 +198,7 @@ assumedNullTill.clear(); assumedNonNullTill.clear(); noAssumptionsPossible.clear(); + branchTargets.clear(); try { super.visitCode(obj); @@ -190,11 +218,23 @@ @Override public void sawOpcode(int seen) { - boolean resultIsNullable = false; + AIUserValue userValue = null; + if (OpcodeUtils.isBranch(seen) && (getBranchOffset() > 0)) { + branchTargets.add(getBranchTarget()); + Collections.sort(branchTargets); + } + + clearBranchTargets(getPC()); + convertNullToNonNull(getPC()); clearAssumptions(assumedNullTill, getPC()); clearAssumptions(assumedNonNullTill, getPC()); + if (OpcodeUtils.isBranch(seen) && (getBranchOffset() > 0)) { + branchTargets.add(getBranchTarget()); + Collections.sort(branchTargets); + } + try { switch (seen) { case ARETURN: { @@ -201,8 +241,8 @@ if (!methodIsNullable && (stack.getStackDepth() > 0)) { OpcodeStack.Item itm = stack.getStackItem(0); Integer reg = Integer.valueOf(itm.getRegisterNumber()); - methodIsNullable = !noAssumptionsPossible.contains(reg) && ((assumedNullTill.containsKey(reg) && !assumedNonNullTill.containsKey(reg)) - || isStackElementNullable(getClassName(), getMethod(), itm)); + methodIsNullable = !assumedNonNullTill.containsKey(reg) && (!noAssumptionsPossible.contains(reg) + && ((assumedNullTill.containsKey(reg)) || isStackElementNullable(getClassName(), getMethod(), itm))); if (methodIsNullable) { throw new StopOpcodeParsingException(); } @@ -234,10 +274,39 @@ } break; + case IFEQ: + if ((getBranchOffset() > 0) && (stack.getStackDepth() > 0)) { + OpcodeStack.Item itm = stack.getStackItem(0); + AIUserValue uv = (AIUserValue) itm.getUserValue(); + if ((uv != null) && (uv.reg >= 0)) { + assumedNullTill.put(uv.reg, getBranchTarget()); + } + } + break; + case INVOKESTATIC: + if (stack.getStackDepth() > 0) { + String signature = getSigConstantOperand(); + if (IS_EMPTY_SIGNATURES.contains(signature)) { + String methodName = getNameConstantOperand(); + if (methodName.equals("isEmpty")) { + OpcodeStack.Item item = stack.getStackItem(0); + int reg = item.getRegisterNumber(); + if (reg >= 0) { + userValue = new AIUserValue(reg); + break; + } + } + } + } + + // $FALL-THROUGH$ case INVOKEINTERFACE: case INVOKEVIRTUAL: { - resultIsNullable = (isMethodNullable(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand())); + boolean resultIsNullable = (isMethodNullable(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand())); + if (resultIsNullable) { + userValue = new AIUserValue(-1); + } break; } @@ -250,9 +319,9 @@ } } finally { stack.sawOpcode(this, seen); - if ((resultIsNullable) && (stack.getStackDepth() > 0)) { + if ((userValue != null) && (stack.getStackDepth() > 0)) { OpcodeStack.Item itm = stack.getStackItem(0); - itm.setUserValue(NULLABLE.TRUE); + itm.setUserValue(userValue); } } } @@ -269,7 +338,7 @@ } public static boolean isStackElementNullable(String className, Method method, OpcodeStack.Item itm) { - if (itm.isNull() || (itm.getUserValue() instanceof NULLABLE)) { + if (itm.isNull() || (itm.getUserValue() != null)) { MethodInfo mi = Statistics.getStatistics().getMethodStatistics(className, method.getName(), method.getSignature()); if (mi != null) { mi.setCanReturnNull(true); @@ -321,6 +390,47 @@ } } + public void convertNullToNonNull(int pc) { + for (Map.Entry<Integer, Integer> entry : assumedNullTill.entrySet()) { + if (entry.getValue().intValue() == pc) { + int lastOp = getPrevOpcode(1); + if ((lastOp == ARETURN) || (lastOp == ATHROW)) { + int nonNullTill = getNextBranchTarget(); + assumedNonNullTill.put(entry.getKey(), nonNullTill); + } else if (OpcodeUtils.isBranch(lastOp)) { + int branchOffset = CodeByteUtils.getshort(getCode().getCode(), getPC() - 2); + if (branchOffset > 0) { + assumedNonNullTill.put(entry.getKey(), getPC() + branchOffset); + } + } + } + } + } + + /** + * remove branch targets that have been passed + * + * @param pc + * the current pc + */ + public void clearBranchTargets(int pc) { + Iterator<Integer> it = branchTargets.iterator(); + while (it.hasNext()) { + int target = it.next().intValue(); + if (target <= pc) { + it.remove(); + } + } + } + + public int getNextBranchTarget() { + if (branchTargets.isEmpty()) { + return Integer.MAX_VALUE; + } + + return branchTargets.get(0); + } + public void removeAssumptions(Map<Integer, Integer> assumptionsTill) { noAssumptionsPossible.addAll(assumptionsTill.keySet()); } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -347,7 +347,7 @@ private void addLineNumber(BitSet lineNumbers) { LineNumberTable lnt = getCode().getLineNumberTable(); if (lnt == null) { - lineNumbers.set(-lineNumbers.size()); + lineNumbers.set(0); } else { int line = lnt.getSourceLine(getPC()); if (line < 0) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -44,6 +44,7 @@ import com.mebigfatguy.fbcontrib.utils.FQMethod; import com.mebigfatguy.fbcontrib.utils.OpcodeUtils; import com.mebigfatguy.fbcontrib.utils.QMethod; +import com.mebigfatguy.fbcontrib.utils.SignatureBuilder; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException; import com.mebigfatguy.fbcontrib.utils.ToString; @@ -65,14 +66,14 @@ private static final int REF_invokeStatic = 6; - private static final QMethod CONTAINS = new QMethod("contains", "(Ljava/lang/Object;)Z"); - private static final QMethod SIZE = new QMethod("size", "()I"); + private static final QMethod CONTAINS = new QMethod("contains", SignatureBuilder.SIG_OBJECT_TO_BOOLEAN); + private static final QMethod SIZE = new QMethod("size", SignatureBuilder.SIG_VOID_TO_INT); private static final FQMethod COLLECT = new FQMethod("java/util/stream/Stream", "collect", "(Ljava/util/stream/Collector;)Ljava/lang/Object;"); private static final FQMethod FILTER = new FQMethod("java/util/stream/Stream", "filter", "(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;"); private static final FQMethod FINDFIRST = new FQMethod("java/util/stream/Stream", "findFirst", "()Ljava/util/Optional;"); - private static final FQMethod ISPRESENT = new FQMethod("java/util/Optional", "isPresent", "()Z"); - private static final FQMethod GET = new FQMethod("java/util/List", "get", "(I)Ljava/lang/Object;"); + private static final FQMethod ISPRESENT = new FQMethod("java/util/Optional", "isPresent", SignatureBuilder.SIG_VOID_TO_BOOLEAN); + private static final FQMethod GET = new FQMethod("java/util/List", "get", SignatureBuilder.SIG_INT_TO_OBJECT); enum ParseState { NORMAL, LAMBDA; @@ -367,7 +368,7 @@ @Nullable private String getAnonymousName(ConstantMethodHandle cmh) { - if (cmh.getReferenceKind() != REF_invokeStatic) { + if ((cmh == null) || (cmh.getReferenceKind() != REF_invokeStatic)) { return null; } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -268,10 +268,10 @@ /** * parses the current class for spring-tx and jpa annotations, as well as hashCode and equals methods. * - * @param cls + * @param clz * the currently parsed class */ - private void catalogClass(JavaClass cls) { + private void catalogClass(JavaClass clz) { transactionalMethods = new HashMap<>(); isEntity = false; hasId = false; @@ -279,7 +279,7 @@ hasEagerOneToMany = false; hasHCEquals = false; - for (AnnotationEntry entry : cls.getAnnotationEntries()) { + for (AnnotationEntry entry : clz.getAnnotationEntries()) { if ("Ljavax/persistence/Entity;".equals(entry.getAnnotationType())) { isEntity = true; break; @@ -286,7 +286,7 @@ } } - for (Method m : cls.getMethods()) { + for (Method m : clz.getMethods()) { catalogFieldOrMethod(m); if (("equals".equals(m.getName()) && SignatureBuilder.SIG_OBJECT_TO_BOOLEAN.equals(m.getSignature())) @@ -295,7 +295,7 @@ } } - for (Field f : cls.getFields()) { + for (Field f : clz.getFields()) { catalogFieldOrMethod(f); } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -241,8 +241,9 @@ markAsValid = true; // Fixes javac generated code } } - } else if (("getTargetException".equals(methodName) || "getCause".equals(methodName)) - && "java/lang/reflect/InvocationTargetException".equals(getClassConstantOperand())) { + } else if ((("getTargetException".equals(methodName) || "getCause".equals(methodName)) + && "java/lang/reflect/InvocationTargetException".equals(getClassConstantOperand())) + || "java/io/UncheckedIOException".equals(getClassConstantOperand())) { markAsValid = true; } else if (isPossibleExBuilder(catchInfo.getRegister())) { markAsValid = true; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -55,7 +55,7 @@ private static Set<String> BOXED_OPTIONAL_TYPES = UnmodifiableSet.create("Ljava/lang/Integer;", "Ljava/lang/Long;", "Ljava/lang/Double;"); - private static final FQMethod OPTIONAL_OR_ELSE_METHOD = new FQMethod("java/util/Optional", "orElse", "(Ljava/lang/Object;)Ljava/lang/Object;"); + private static final FQMethod OPTIONAL_OR_ELSE_METHOD = new FQMethod("java/util/Optional", "orElse", SignatureBuilder.SIG_OBJECT_TO_OBJECT); private static final FQMethod OPTIONAL_OR_ELSE_GET_METHOD = new FQMethod("java/util/Optional", "orElseGet", "(Ljava/util/function/Supplier;)Ljava/lang/Object;"); private static final FQMethod OPTIONAL_GET_METHOD = new FQMethod("java/util/Optional", "get", SignatureBuilder.SIG_VOID_TO_OBJECT); @@ -64,8 +64,8 @@ // @formatter:off OPTIONAL_OR_ELSE_METHOD, new FQMethod("java/util/OptionalDouble", "orElse", "(D)D"), - new FQMethod("java/util/OptionalInt", "orElse", "(I)I"), - new FQMethod("java/util/OptionalLong", "orElse", "(J)J") + new FQMethod("java/util/OptionalInt", "orElse", SignatureBuilder.SIG_INT_TO_INT), + new FQMethod("java/util/OptionalLong", "orElse", SignatureBuilder.SIG_LONG_TO_LONG) // @formatter:on ); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -460,7 +460,7 @@ return true; } - if ((seen != IFNE) || (stack.getStackDepth() == 0)) { + if (((seen != IFNE) && (seen != IFEQ)) || (stack.getStackDepth() == 0)) { return false; } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -18,6 +18,8 @@ */ package com.mebigfatguy.fbcontrib.detect; +import java.lang.reflect.AccessibleObject; + import org.apache.bcel.Repository; import org.apache.bcel.classfile.JavaClass; @@ -24,6 +26,7 @@ import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.FQMethod; import com.mebigfatguy.fbcontrib.utils.QMethod; +import com.mebigfatguy.fbcontrib.utils.SignatureBuilder; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -32,9 +35,9 @@ public class ReflectionIssues extends BytecodeScanningDetector { - private static final QMethod SETACCESSIBLE = new QMethod("setAccessible", "(Z)V"); + private static final QMethod SETACCESSIBLE = new QMethod("setAccessible", SignatureBuilder.SIG_BOOLEAN_TO_VOID); private static final FQMethod SETACCESSIBLE_ARRAY = new FQMethod("java/lang/reflect/AccessibleObject", "setAccessible", - "([Ljava/lang/reflect/AccessibleObject;Z)V"); + new SignatureBuilder().withParamTypes(AccessibleObject.class).build()); private static final JavaClass ACCESSIBLE_OBJECT_CLASS; static { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -28,6 +28,7 @@ import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.QMethod; +import com.mebigfatguy.fbcontrib.utils.SignatureBuilder; import com.mebigfatguy.fbcontrib.utils.ToString; import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import com.mebigfatguy.fbcontrib.utils.Values; @@ -46,15 +47,15 @@ private static final Set<QMethod> OBJECT_METHODS = UnmodifiableSet.create( // @formatter:off - new QMethod("equals", "(Ljava/lang/Object;)Z"), - new QMethod(Values.HASHCODE, "()I"), - new QMethod(Values.TOSTRING, "()Ljava/lang/String;"), - new QMethod("clone", "()Ljava/lang/Object;"), - new QMethod("notify", "()V"), - new QMethod("notifyAll", "()V"), - new QMethod("wait", "(J)V"), + new QMethod("equals", SignatureBuilder.SIG_OBJECT_TO_BOOLEAN), + new QMethod(Values.HASHCODE, SignatureBuilder.SIG_VOID_TO_INT), + new QMethod(Values.TOSTRING, SignatureBuilder.SIG_VOID_TO_STRING), + new QMethod("clone", SignatureBuilder.SIG_VOID_TO_OBJECT), + new QMethod("notify", SignatureBuilder.SIG_VOID_TO_VOID), + new QMethod("notifyAll", SignatureBuilder.SIG_VOID_TO_VOID), + new QMethod("wait", SignatureBuilder.SIG_LONG_TO_VOID), new QMethod("wait", "(JI)V"), - new QMethod("wait", "()V") + new QMethod("wait", SignatureBuilder.SIG_VOID_TO_VOID) // @formatter:on ); private final BugReporter bugReporter; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -25,6 +25,8 @@ import javax.annotation.Nullable; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.LocalVariable; +import org.apache.bcel.classfile.LocalVariableTable; import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -101,8 +103,9 @@ try { stack.precomputation(this); - Integer pc = Integer.valueOf(getPC()); - nullGuards.remove(pc); + int pc = getPC(); + nullGuards.remove(Integer.valueOf(pc)); + clearEndOfLifeRegisters(); switch (seen) { case IFNULL: { @@ -111,12 +114,21 @@ int reg = itm.getRegisterNumber(); Integer target = Integer.valueOf(getBranchTarget()); if (reg >= 0) { - nullGuards.put(target, new NullGuard(reg, pc.intValue(), itm.getSignature())); + int eol = Integer.MAX_VALUE; + LocalVariableTable lvt = getMethod().getLocalVariableTable(); + if (lvt != null) { + LocalVariable lv = lvt.getLocalVariable(reg, pc); + if (lv != null) { + eol = pc + lv.getLength(); + } + } + + nullGuards.put(target, new NullGuard(reg, pc, eol, itm.getSignature())); } else { XField xf = itm.getXField(); Integer sourceFieldReg = (Integer) itm.getUserValue(); if ((xf != null) && (sourceFieldReg != null)) { - nullGuards.put(target, new NullGuard(xf, sourceFieldReg.intValue(), pc.intValue(), itm.getSignature())); + nullGuards.put(target, new NullGuard(xf, sourceFieldReg.intValue(), pc, itm.getSignature())); } } } @@ -258,17 +270,30 @@ } } + private void clearEndOfLifeRegisters() { + int pc = getPC(); + Iterator<NullGuard> it = nullGuards.values().iterator(); + while (it.hasNext()) { + NullGuard potentialEOL = it.next(); + if (potentialEOL.isEOL(pc)) { + it.remove(); + } + } + } + static class NullGuard { int register; XField field; int fieldSourceReg; int location; + int scopeEnd; String signature; - NullGuard(int reg, int start, String guardSignature) { + NullGuard(int reg, int start, int end, String guardSignature) { register = reg; field = null; location = start; + scopeEnd = end; signature = guardSignature; } @@ -277,6 +302,7 @@ field = xf; fieldSourceReg = fieldSource; location = start; + scopeEnd = Integer.MAX_VALUE; signature = guardSignature; } @@ -296,6 +322,10 @@ return location; } + boolean isEOL(int pc) { + return pc >= scopeEnd; + } + String getSignature() { return signature; } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -41,6 +41,8 @@ public static final String SIG_INT_TO_INT = new SignatureBuilder().withParamTypes(Values.SIG_PRIMITIVE_INT).withReturnType(Values.SIG_PRIMITIVE_INT) .toString(); + public static final String SIG_BOOLEAN_TO_VOID = new SignatureBuilder().withParamTypes(Values.SIG_PRIMITIVE_BOOLEAN).toString(); + public static final String SIG_LONG_TO_VOID = new SignatureBuilder().withParamTypes(Values.SIG_PRIMITIVE_LONG).toString(); public static final String SIG_LONG_TO_LONG = new SignatureBuilder().withParamTypes(Values.SIG_PRIMITIVE_LONG).withReturnType(Values.SIG_PRIMITIVE_LONG) .toString(); Modified: trunk/fb-contrib/src/samples/java/ex/ACEM_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/ACEM_Sample.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/samples/java/ex/ACEM_Sample.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -1,6 +1,10 @@ package ex; public abstract class ACEM_Sample implements Foo { + + public static final Runnable fpNOP283 = () -> { + }; + public void test() { } @@ -7,12 +11,11 @@ public int test1() { throw new UnsupportedOperationException("Not implemented"); } - + @Override public void doFPFoo() { } - - + } interface Foo { Modified: trunk/fb-contrib/src/samples/java/ex/AI_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/AI_Sample.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/samples/java/ex/AI_Sample.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -4,9 +4,13 @@ import java.lang.reflect.Constructor; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Collections; +import java.util.List; import javax.annotation.Nullable; +import org.apache.commons.collections.CollectionUtils; + public class AI_Sample { @Nullable @@ -65,7 +69,47 @@ return AI_Sample.class.newInstance(); } + public Object fpConditionalWithThrow291() { + Object t = create(); + if (t != null) { + return t; + } else { + throw new RuntimeException(); + } + } + + public Object fpConditionalWithElseNotNull() { + Object t = create(); + if (t == null) { + return new Object(); + } else { + return t; + } + } + + public Object fpIsEmpty(String s) { + List<String> ss = maybeGetList(s); + + if (CollectionUtils.isEmpty(ss)) { + return Collections.emptyList(); + } + + return ss; + } + interface Stringer { String get(); } + + @Nullable + private static Object create() { + return Math.random() >= 0.5 ? new Object() : null; + } + + private List<String> maybeGetList(String s) { + if (s == null) { + return null; + } + return Collections.singletonList(s); + } } Modified: trunk/fb-contrib/src/samples/java/ex/LEST_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/LEST_Sample.java 2018-05-20 22:03:10 UTC (rev 1838) +++ trunk/fb-contrib/src/samples/java/ex/LEST_Sample.java 2018-06-01 00:34:34 UTC (rev 1839) @@ -3,6 +3,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UncheckedIOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.DateFormat; @@ -9,6 +10,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; import com.google.common.base.Throwables; @@ -162,6 +165,20 @@ } } + public void testFPUncheckedIOException290(List<String> s) throws IOException { + try { + List<FileInputStream> fis = s.stream().map(ss -> { + try { + return new FileInputStream(ss); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }).collect(Collectors.toList()); + } catch (UncheckedIOException e) { + throw e.getCause(); + } + } + static Class<?> testFP226(final String clazz) { if (clazz != null) { try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-05-20 22:03:12
|
Revision: 1838 http://sourceforge.net/p/fb-contrib/code/1838 Author: dbrosius Date: 2018-05-20 22:03:10 +0000 (Sun, 20 May 2018) Log Message: ----------- Version 7.4.1 Added Paths: ----------- tags/v7_4_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-05-20 21:58:42
|
Revision: 1837 http://sourceforge.net/p/fb-contrib/code/1837 Author: dbrosius Date: 2018-05-20 21:58:38 +0000 (Sun, 20 May 2018) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java trunk/fb-contrib/src/samples/java/ex/AI_Sample.java trunk/fb-contrib/src/samples/java/ex/FII_Sample.java trunk/fb-contrib/yank.xls Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/build.xml 2018-05-20 21:58:38 UTC (rev 1837) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.4.0" /> + <property name="fb-contrib.version" value="7.4.1" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -109,7 +109,9 @@ <path id="fb-contrib.test.classpath"> <pathelement location="${lib.dir}/testng-${testng.version}.jar" /> <pathelement location="${lib.dir}/jcommander-${jcommander.version}.jar" /> - <pathelement location="${lib.dir}/mockito-core-${mockito-core.version}.jar" /> + <pathelement location="${lib.dir}/mockito-core-${mockito-core.version}.jar" /> + <pathelement location="${lib.dir}/byte-buddy-${byte-buddy.version}.jar" /> + <pathelement location="${lib.dir}/objenesis-${objenesis.version}.jar" /> <pathelement location="${lib.dir}/hamcrest-core-${hamcrest-core.version}.jar" /> <pathelement location="${findbugs.dir}/lib/dom4j-1.6.1.jar" /> <pathelement location="${findbugs.dir}/lib/jaxen-1.1.6.jar" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/etc/findbugs.xml 2018-05-20 21:58:38 UTC (rev 1837) @@ -31,7 +31,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/htdocs/index.shtml 2018-05-20 21:58:38 UTC (rev 1837) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.4.0 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.4.1 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/htdocs/repository.html 2018-05-20 21:58:38 UTC (rev 1837) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.4.0 or 7.4.0.sb</td></tr> + <tr><td><b>Version:</b></td><td>7.4.1 or 7.4.1.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/pom.xml 2018-05-20 21:58:38 UTC (rev 1837) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.4.0</version> + <version>7.4.1</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2018-05-20 21:58:38 UTC (rev 1837) @@ -33,7 +33,10 @@ import com.mebigfatguy.fbcontrib.collect.MethodInfo; import com.mebigfatguy.fbcontrib.collect.Statistics; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.FQMethod; +import com.mebigfatguy.fbcontrib.utils.SignatureBuilder; import com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import com.mebigfatguy.fbcontrib.utils.Values; import edu.umd.cs.findbugs.BugInstance; @@ -73,6 +76,12 @@ } } + private static final Set<FQMethod> NOTABLE_EXCEPTIONS = UnmodifiableSet.create( + // @formatter:off + new FQMethod(Values.SLASHED_JAVA_LANG_CLASS, "newInstance", SignatureBuilder.SIG_VOID_TO_OBJECT) + // @formatter:on + ); + public enum NULLABLE { TRUE }; @@ -138,6 +147,12 @@ return; } + if (NOTABLE_EXCEPTIONS.contains(new FQMethod(getClassName(), method.getName(), sig))) { + MethodInfo methodInfo = Statistics.getStatistics().getMethodStatistics(getClassName(), method.getName(), method.getSignature()); + methodInfo.setCanReturnNull(false); + return; + } + if (methodHasNullableAnnotation(method)) { if (isCollecting()) { MethodInfo methodInfo = Statistics.getStatistics().getMethodStatistics(getClassName(), method.getName(), method.getSignature()); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java 2018-05-20 21:58:38 UTC (rev 1837) @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -43,6 +44,7 @@ import com.mebigfatguy.fbcontrib.utils.FQMethod; import com.mebigfatguy.fbcontrib.utils.OpcodeUtils; import com.mebigfatguy.fbcontrib.utils.QMethod; +import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import com.mebigfatguy.fbcontrib.utils.StopOpcodeParsingException; import com.mebigfatguy.fbcontrib.utils.ToString; import com.mebigfatguy.fbcontrib.utils.Values; @@ -140,10 +142,14 @@ if ((m.getAccessFlags() & ACC_SYNTHETIC) != 0) { List<FIInfo> fiis = functionalInterfaceInfo.get(m.getName()); if (fiis != null) { - try { - anonState = AnonState.SEEN_NOTHING; - super.visitCode(obj); - } catch (StopOpcodeParsingException e) { + if (SignatureUtils.getNumParameters(m.getSignature()) != 1) { + functionalInterfaceInfo.remove(m.getName()); + } else { + try { + anonState = AnonState.SEEN_NOTHING; + super.visitCode(obj); + } catch (StopOpcodeParsingException e) { + } } } } @@ -183,6 +189,20 @@ throw new StopOpcodeParsingException(); } } else if ((seen == ARETURN) && (getPC() == 1)) { + List<FIInfo> infos = functionalInterfaceInfo.get(getMethod().getName()); + if (infos != null) { + Iterator<FIInfo> it = infos.iterator(); + while (it.hasNext()) { + FIInfo info = it.next(); + if (info.wasPrecededByExplicitStackOp()) { + it.remove(); + } + } + if (infos.isEmpty()) { + functionalInterfaceInfo.remove(getMethod().getName()); + } + } + anonymousBugType.put(getMethod().getName(), BugType.FII_USE_FUNCTION_IDENTITY); throw new StopOpcodeParsingException(); } else { @@ -195,6 +215,13 @@ if (!OpcodeUtils.isReturn(seen)) { functionalInterfaceInfo.remove(getMethod().getName()); } + + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + if (!itm.getSignature().equals(SignatureUtils.getReturnSignature(getMethod().getSignature()))) { + functionalInterfaceInfo.remove(getMethod().getName()); + } + } anonymousBugType.put(getMethod().getName(), BugType.FII_USE_METHOD_REFERENCE); throw new StopOpcodeParsingException(); @@ -217,7 +244,9 @@ functionalInterfaceInfo.put(anonName, fiis); } - FIInfo fii = new FIInfo(getMethod(), SourceLineAnnotation.fromVisitedInstruction(this)); + int lastOp = getPrevOpcode(1); + FIInfo fii = new FIInfo(getMethod(), SourceLineAnnotation.fromVisitedInstruction(this), + OpcodeUtils.isALoad(lastOp) || (lastOp == GETFIELD) || (lastOp == GETSTATIC)); fiis.add(fii); } break; @@ -377,10 +406,12 @@ static class FIInfo { private Method method; private SourceLineAnnotation srcLine; + private boolean precededByExplicitStackOp; - public FIInfo(Method method, SourceLineAnnotation srcLine) { + public FIInfo(Method method, SourceLineAnnotation srcLine, boolean precededByExplicitStackOp) { this.method = method; this.srcLine = srcLine; + this.precededByExplicitStackOp = precededByExplicitStackOp; } public Method getMethod() { @@ -391,6 +422,10 @@ return srcLine; } + public boolean wasPrecededByExplicitStackOp() { + return precededByExplicitStackOp; + } + @Override public String toString() { return ToString.build(this); Modified: trunk/fb-contrib/src/samples/java/ex/AI_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/AI_Sample.java 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/src/samples/java/ex/AI_Sample.java 2018-05-20 21:58:38 UTC (rev 1837) @@ -61,6 +61,10 @@ }); } + public AI_Sample fpNotableExceptions284() throws Exception { + return AI_Sample.class.newInstance(); + } + interface Stringer { String get(); } Modified: trunk/fb-contrib/src/samples/java/ex/FII_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/FII_Sample.java 2018-05-12 02:22:28 UTC (rev 1836) +++ trunk/fb-contrib/src/samples/java/ex/FII_Sample.java 2018-05-20 21:58:38 UTC (rev 1837) @@ -1,10 +1,15 @@ package ex; +import java.math.BigDecimal; import java.util.EnumSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; public class FII_Sample { @@ -57,6 +62,29 @@ return baubles.stream().filter(b -> b.getName().equals(name)).collect(Collectors.toSet()).size(); } + public void fpUnrelatedLambdaValue282(Map<String, Bauble> map, BaubleFactory factory) { + map.computeIfAbsent("pixie dust", _unused -> factory.getBauble()); + } + + public BigDecimal fpCastEliminatesMethodReference282(List<Bauble> baubles) { + return baubles.stream().filter(b -> b.getName().equals("special")).map(b -> (BigDecimal) b.getCost()).findFirst().get(); + } + + public static <T> Stream<T> fpIiteratorToFiniteStream283(Iterator<T> iterator, boolean parallel) { + Iterable<T> iterable = () -> iterator; + return StreamSupport.stream(iterable.spliterator(), parallel); + } + + public void fpUseIdentity283() { + put(m -> { + m.putAll(m); + return m; + }); + } + + public void put(Function<Map<String, Object>, Map<String, Object>> updateFunction) { + } + public static class Bauble { public String getName() { @@ -66,8 +94,25 @@ public boolean isFree() { return true; } + + public Number getCost() { + return 0.0; + } } + public static class SpecialBauble extends Bauble { + @Override + public BigDecimal getCost() { + return new BigDecimal("0.0"); + } + } + + public static class BaubleFactory { + public Bauble getBauble() { + return new Bauble(); + } + } + public enum GiantSpeak { FEE, FI, FO, FUM, BLUB; Modified: trunk/fb-contrib/yank.xls =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-05-12 02:22:31
|
Revision: 1836 http://sourceforge.net/p/fb-contrib/code/1836 Author: dbrosius Date: 2018-05-12 02:22:28 +0000 (Sat, 12 May 2018) Log Message: ----------- Version 7.4.0 Added Paths: ----------- tags/v7_4_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-05-12 02:20:45
|
Revision: 1835 http://sourceforge.net/p/fb-contrib/code/1835 Author: dbrosius Date: 2018-05-12 02:20:43 +0000 (Sat, 12 May 2018) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2018-05-11 03:29:38 UTC (rev 1834) +++ trunk/fb-contrib/build.xml 2018-05-12 02:20:43 UTC (rev 1835) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.2.2-SNAPSHOT" /> + <property name="fb-contrib.version" value="7.4.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2018-05-11 03:29:38 UTC (rev 1834) +++ trunk/fb-contrib/etc/findbugs.xml 2018-05-12 02:20:43 UTC (rev 1835) @@ -23,7 +23,7 @@ <!-- Detectors --> - <!-- COMMENT OUT FOR RELEASE --> + <!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -31,7 +31,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - <!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -324,9 +324,6 @@ <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus" speed="fast" reports="" hidden="true" /> - - <!-- COMMENT OUT FOR POINT RELEASE --> - <Detector class="com.mebigfatguy.fbcontrib.detect.ListUsageIssues" speed="fast" reports="LUI_USE_SINGLETON_LIST,LUI_USE_COLLECTION_ADD,LUI_USE_GET0"/> <Detector class="com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues" speed="fast" reports="FII_USE_METHOD_REFERENCE,FII_AVOID_CONTAINS_ON_COLLECTED_STREAM,FII_USE_ANY_MATCH,FII_USE_FIND_FIRST,FII_COMBINE_FILTERS,FII_USE_FUNCTION_IDENTITY,FII_AVOID_SIZE_ON_COLLECTED_STREAM" /> @@ -336,6 +333,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="slow" reports="CE_CLASS_ENVY" /> <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2018-05-11 03:29:38 UTC (rev 1834) +++ trunk/fb-contrib/htdocs/index.shtml 2018-05-12 02:20:43 UTC (rev 1835) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.2.1 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.4.0 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -75,11 +75,17 @@ github. If this site seems behind, please <a href="http://github.com/mebigfatguy/fb-contrib">check there</a>. I will try to keep this site up to date, but I'd appreciate a poke if you see something missing.</p> </div> - + <hr/> + <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> + Detectors added in git<br/> + <div id="git" style="display:none;"> + <ul> + </ul> + </div> <hr/> - <img id="git_image" src="flip2.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> - Detectors added in git<br/> - <div id="git" style="display:block;"> + <img id="v7_4_0_image" src="flip2.gif" onClick="toggleBlock('v7_4_0', 'v7_4_0_image');" align="top"/> + Detectors added in v7.4.0<br/> + <div id="v7_4_0" style="display:block;"> <ul> <li><b>[LUI] List Usage Issues</b><br/> Looks for odd usage patterns when using Lists Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2018-05-11 03:29:38 UTC (rev 1834) +++ trunk/fb-contrib/htdocs/repository.html 2018-05-12 02:20:43 UTC (rev 1835) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.2.1 or 7.2.1.sb</td></tr> + <tr><td><b>Version:</b></td><td>7.4.0 or 7.4.0.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2018-05-11 03:29:38 UTC (rev 1834) +++ trunk/fb-contrib/pom.xml 2018-05-12 02:20:43 UTC (rev 1835) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.2.2-SNAPSHOT</version> + <version>7.4.0</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-05-11 03:30:50
|
Revision: 1834 http://sourceforge.net/p/fb-contrib/code/1834 Author: dbrosius Date: 2018-05-11 03:29:38 +0000 (Fri, 11 May 2018) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/bugrank.txt trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousMapCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListUsageIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MapUsageIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WiringIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/samples/java/ex/AI_Sample.java trunk/fb-contrib/src/samples/java/ex/LO_Sample.java trunk/fb-contrib/src/samples/java/ex/MRC_Sample.java trunk/fb-contrib/src/samples/java/ex/OCP_Sample.java trunk/fb-contrib/src/samples/java/ex/PMB_Sample.java trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java trunk/fb-contrib/src/samples/java/ex/PSC_Sample.java trunk/fb-contrib/src/samples/java/ex/SEO_Sample.java trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java Added Paths: ----------- trunk/fb-contrib/etc/pmd-rules.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FunctionalInterfaceIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SetUsageIssues.java trunk/fb-contrib/src/samples/java/ex/FII_Sample.java trunk/fb-contrib/src/samples/java/ex/SUI_Sample.java trunk/fb-contrib/src/samples/java/ex/ce/ trunk/fb-contrib/src/samples/java/ex/ce/CE_Sample.java trunk/fb-contrib/src/samples/java/ex/ce/Envy.java Removed Paths: ------------- trunk/fb-contrib/src/samples/java/ex/CE_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/build.xml 2018-05-11 03:29:38 UTC (rev 1834) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.2.1" /> + <property name="fb-contrib.version" value="7.2.2-SNAPSHOT" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/etc/bugrank.txt 2018-05-11 03:29:38 UTC (rev 1834) @@ -53,6 +53,13 @@ +0 BugPattern EXS_EXCEPTION_SOFTENING_RETURN_FALSE +0 BugPattern FCBL_FIELD_COULD_BE_LOCAL +2 BugPattern FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY ++0 BugPattern FII_AVOID_CONTAINS_ON_COLLECTED_STREAM ++0 BugPattern FII_AVOID_SIZE_ON_COLLECTED_STREAM ++0 BugPattern FII_COMBINE_FILTERS ++1 BugPattern FII_USE_ANY_MATCH ++0 BugPattern FII_USE_FIND_FIRST ++0 BugPattern FII_USE_FUNCTION_IDENTITY ++0 BugPattern FII_USE_METHOD_REFERENCE +0 BugPattern FPL_FLOATING_POINT_LOOPS +6 BugPattern FP_FINAL_PARAMETERS +0 BugPattern HCP_HTTP_REQUEST_RESOURCES_NOT_FREED_FIELD @@ -218,7 +225,6 @@ +0 BugPattern SPP_NON_USEFUL_TOSTRING +0 BugPattern SPP_NO_CHAR_SB_CTOR +0 BugPattern SPP_NULL_BEFORE_INSTANCEOF -+0 BugPattern SPP_NULL_CHECK_ON_OPTIONAL +0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE +0 BugPattern SPP_STATIC_FORMAT_STRING +0 BugPattern SPP_STRINGBUFFER_WITH_EMPTY_STRING @@ -237,6 +243,7 @@ +0 BugPattern SPP_USE_ISNAN +0 BugPattern SPP_USE_MATH_CONSTANT +0 BugPattern SPP_USE_STRINGBUILDER_LENGTH ++0 BugPattern SPP_USE_ZERO_WITH_COMPARATOR +0 BugPattern SPP_WRONG_COMMONS_TO_STRING_OBJECT +0 BugPattern SSCU_SUSPICIOUS_SHADED_CLASS_USE +0 BugPattern STB_STACKED_TRY_BLOCKS @@ -245,6 +252,8 @@ +0 BugPattern STT_TOSTRING_MAP_KEYING +0 BugPattern STT_TOSTRING_STORED_IN_FIELD +0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY ++0 BugPattern SUI_CONTAINS_BEFORE_ADD ++0 BugPattern SUI_CONTAINS_BEFORE_REMOVE +0 BugPattern SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT +0 BugPattern TBP_TRISTATE_BOOLEAN_PATTERN +0 BugPattern TR_TAIL_RECURSION Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/etc/findbugs.xml 2018-05-11 03:29:38 UTC (rev 1834) @@ -23,17 +23,15 @@ <!-- Detectors --> - <!-- COMMENT OUT FOR RELEASE + <!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> - <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="fast" reports="CE_CLASS_ENVY" disabled="true" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedSynchronizedBlock" speed="fast" reports="BSB_BLOATED_SYNCHRONIZED_BLOCK" hidden="true" /> <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + <!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -148,7 +146,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SCRV_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_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_SERIALVER_SHOULD_BE_PRIVATE,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING,SPP_NULL_CHECK_ON_OPTIONAL,SPP_WRONG_COMMONS_TO_STRING_OBJECT" /> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_SERIALVER_SHOULD_BE_PRIVATE,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING,SPP_WRONG_COMMONS_TO_STRING_OBJECT,SPP_USE_ZERO_WITH_COMPARATOR" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -327,12 +325,18 @@ <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus" speed="fast" reports="" hidden="true" /> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.ListUsageIssues" speed="fast" reports="LUI_USE_SINGLETON_LIST,LUI_USE_COLLECTION_ADD,LUI_USE_GET0"/> - COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues" speed="fast" reports="FII_USE_METHOD_REFERENCE,FII_AVOID_CONTAINS_ON_COLLECTED_STREAM,FII_USE_ANY_MATCH,FII_USE_FIND_FIRST,FII_COMBINE_FILTERS,FII_USE_FUNCTION_IDENTITY,FII_AVOID_SIZE_ON_COLLECTED_STREAM" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.SetUsageIssues" speed="fast" reports="SUI_CONTAINS_BEFORE_ADD,SUI_CONTAINS_BEFORE_REMOVE"/> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy" speed="slow" reports="CE_CLASS_ENVY" /> + + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -441,8 +445,8 @@ <BugPattern abbrev="SPP" type="SPP_EQUALS_ON_STRING_BUILDER" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_CONVERSION_OF_STRING_LITERAL" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_STATIC_FORMAT_STRING" category="CORRECTNESS" /> - <BugPattern abbrev="SPP" type="SPP_NULL_CHECK_ON_OPTIONAL" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_WRONG_COMMONS_TO_STRING_OBJECT" category="CORRECTNESS" /> + <BugPattern abbrev="SPP" type="SPP_USE_ZERO_WITH_COMPARATOR" category="CORRECTNESS" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -618,14 +622,23 @@ <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL" category="CORRECTNESS" /> <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT" category="CORRECTNESS"/> <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" category="CORRECTNESS"/> - <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="AI" type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="MUI" type="MUI_CONTAINSKEY_BEFORE_GET" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS"/> + <BugPattern abbrev="AI" type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" category="CORRECTNESS"/> + <BugPattern abbrev="MUI" type="MUI_CONTAINSKEY_BEFORE_GET" category="CORRECTNESS"/> <BugPattern abbrev="MUI" type="MUI_GET_BEFORE_REMOVE" category="CORRECTNESS"/> <BugPattern abbrev="MUI" type="MUI_CALLING_SIZE_ON_SUBCONTAINER" category="CORRECTNESS" /> <BugPattern abbrev="MUI" type="MUI_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR" category="CORRECTNESS" /> <BugPattern abbrev="MUI" type="MUI_USE_CONTAINSKEY" category="CORRECTNESS" /> - <BugPattern abbrev="LUI" type="LUI_USE_SINGLETON_LIST" category="CORRECTNESS" /> - <BugPattern abbrev="LUI" type="LUI_USE_COLLECTION_ADD" category="CORRECTNESS" /> - <BugPattern abbrev="LUI" type="LUI_USE_GET0" category="CORRECTNESS" /> + <BugPattern abbrev="LUI" type="LUI_USE_SINGLETON_LIST" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="LUI" type="LUI_USE_COLLECTION_ADD" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="LUI" type="LUI_USE_GET0" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_USE_METHOD_REFERENCE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_AVOID_CONTAINS_ON_COLLECTED_STREAM" category="CORRECTNESS" experimental="true "/> + <BugPattern abbrev="FII" type="FII_USE_ANY_MATCH" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_USE_FIND_FIRST" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_COMBINE_FILTERS" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_USE_FUNCTION_IDENTITY" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="FII" type="FII_AVOID_SIZE_ON_COLLECTED_STREAM" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SUI" type="SUI_CONTAINS_BEFORE_ADD" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="SUI" type="SUI_CONTAINS_BEFORE_REMOVE" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2018-03-04 05:49:10 UTC (rev 1833) +++ trunk/fb-contrib/etc/messages.xml 2018-05-11 03:29:38 UTC (rev 1834) @@ -22,7 +22,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections"> <Details> <![CDATA[ @@ -30,7 +30,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus"> <Details> <![CDATA[ @@ -62,7 +62,7 @@ <![CDATA[ <p>Looks for use of iterators on synchronized collections built from the java.util.Collections class.</p> <p>As the collection in question was built through Collections.synchronizedXXX, an assumption - is made that this collection must be multithreaded safe. However, iterator access is used, + is made that this collection must be multithreading safe. However, iterator access is used, which is explicitly unsafe. When iterators are to be used, synchronization should be done manually.</p> <p>It is a slow detector.</p> ]]> @@ -82,7 +82,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyConcreteParameter"> <Details> <![CDATA[ - <p>Looks for parameters that are defined by classes, but where the method only use methods defined by an + <p>Looks for parameters that are defined by classes, but where the method only uses methods defined by an implemented interface or superclass of that class. Relying on concrete classes in public signatures causes cohesion, and makes low impact changes more difficult.</p> <p>It is a slow detector.</p> @@ -108,7 +108,7 @@ interface inheritance other than java.lang.Object. Doing so makes for brittle code, relying either on positional correspondence for type, or a reliance on instanceof to determine type. A better design usually can be had by creating a separate class, - which defines the different types required, and add an instance of that class to the + which defines the different types required, and adding an instance of that class to the collection, or array.</p> <p>It is a fast detector.</p> ]]> @@ -129,7 +129,7 @@ } </code> But what does that tell you? Is this method very very likely to throw NullPointerExceptions? - If it is, why isn't this method handling them so that exceptions aren't thrown. So don't do this. + If it is, why isn't this method handling them so that exceptions aren't thrown? So don't do this. If an NPE is very likely, then check for it, and handle the situation. </p> ]]> @@ -139,12 +139,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ClassEnvy"> <Details> <![CDATA[ - <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> - <p>Looks for methods that use a high percentage of methods from another class over its own + <p>Looks for methods that use a high percentage of methods from another class over their class' own methods. When this is the case, it is often better to implement this method in that other class, by refactoring the class to accept parameters it needs from the source class. The reporting percentage can be set with system property 'fb-contrib.ce.percent'.</p> - <p>It is a fast detector.</p> + <p>It is a slow detector.</p> ]]> </Details> </Detector> @@ -189,7 +188,7 @@ <![CDATA[ <p>Looks for classes that maintain two or more lists or arrays associated one-for-one through the same index to hold two or more pieces of related information. It would be better to create a new class that holds - all of these pieces of information, and place instances of this class in one list. Or if the two list are + all of these pieces of information, and place instances of this class in one list. Or if the two lists are related in key/value fashion, then use a map instead.</p> <p>It is a fast detector.</p> ]]> @@ -199,7 +198,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.FinalParameters"> <Details> <![CDATA[ - <p>Looks for methods that correctly do not write to a parameter. To help document this you should consider + <p>Looks for methods that correctly do not write to a parameter. To help document this, you should consider defining these parameters as final.</p> <p>It is a slow detector.</p> ]]> @@ -210,7 +209,7 @@ <Details> <![CDATA[ <p>Looks for abstract classes that define empty methods or methods that simply throw an - exception. Since this is an abstract class, it may be cleaner to simple define this method + exception. Since this is an abstract class, it may be cleaner to simply define this method as abstract, so that correct subclass behavior is enforced.</p> <p>It is a fast detector.</p> ]]> @@ -232,7 +231,7 @@ <![CDATA[ <p>Looks for methods that use floating point indexes for loops. Since floating point math is imprecise, rounding errors will occur each time through the loop causing - hard to find problems. It is usually better to use integer indexing, and calculating + hard-to-find problems. It is usually better to use integer indexing, and calculate the correct floating point value from the index.</p> <p>It is a fast detector.</p> ]]> @@ -276,7 +275,7 @@ <pre><code> public void test(Character c) </code></pre> - but instead maps to one that takes an int, long, float or double, such as + but it instead maps to one that takes an int, long, float or double, such as <pre><code> public void test(int i) </code></pre> @@ -384,7 +383,7 @@ <Details> <![CDATA[ <p>Looks for methods that create DOM nodes but do not add them to any DOM Document. - Either the node was needed to be added to the tree, or the node likely was created in error.</p> + Either the node needed to be added to the tree, or the node likely was created in error.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -404,7 +403,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.CustomBuiltXML"> <Details> <![CDATA[ - <p>Looks for methods that build XML based strings by concatenation strings + <p>Looks for methods that build XML based strings by concatenating strings and custom values together. Doing so makes brittle code, that is difficult to modify, validate and understand. It is cleaner to create external XML files that are transformed at runtime, using parameters set through Transformer.setParameter.</p> @@ -430,7 +429,7 @@ <p>Looks for methods that access arrays or classes that implement java.util.List using a constant integer for the index. This is often a typo intended to be a loop variable, but if specific indices mean certain things, perhaps a first class object - would be a better choice for a container, on even a map with informative key names + would be a better choice for a container, or even a map with informative key names would be better.</p> <p>It is a fast detector.</p> ]]> @@ -540,7 +539,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.FieldCouldBeLocal"> <Details> <![CDATA[ - <p>Looks for classes that define fields that are used in a locals only fashion, + <p>Looks for classes that define fields that are used in a local-only fashion, specifically private fields that are accessed first in each method with a store vs. a load.</p> <p>It is a slow detector.</p> @@ -574,7 +573,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.Section508Compliance"> <Details> <![CDATA[ - <p>Looks for violation of Section 508, Accessibility for People with disabilities Act.</p> + <p>Looks for violation of Section 508, Accessibility for People with Disabilities Act.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -679,7 +678,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.TailRecursion"> <Details> <![CDATA[ - <p>Looks for methods that make a recursive call to itself as the last statement in the + <p>Looks for methods that make recursive calls to themselves as the last statement in the method. This tail recursion could be converted into a simple loop which would improve the performance and stack requirements.</p> <p>It is a fast detector.</p> @@ -704,7 +703,7 @@ <![CDATA[ <p>Looks for classes that don't handle serialization of parent class member fields when the class in question is serializable but is derived from a non serializable - classes.</p> + class.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -714,7 +713,7 @@ <Details> <![CDATA[ <p>Looks for classes that implement Comparator or Comparable, and whose compare or compareTo - methods return constant values only, but that don't represent the three possible choice + methods return constant values only, but that don't represent the three possible choices (a negative number, 0, and a positive number).</p> <p>It is a fast detector.</p> ]]> @@ -734,7 +733,7 @@ <Details> <![CDATA[ <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> - <p>Looks for assignments to variables in a scope larger than its use. As long as the evaluation of the assignment + <p>Looks for assignments to variables in a scope larger than their use. As long as the evaluation of the assignment does not have side effects, the assignment can be moved into the inner scope where it is used.</p> <p>It is a fast detector.</p> ]]> @@ -868,7 +867,7 @@ <Details> <![CDATA[ <p>Looks for JUnit or TestNG test case methods that use assertions with odd parameters. - Including in this is: + Included in this is: <ul> <li>Passing a constant as the second (actual) parameter in a JUnit test</li> <li>Not using the three parameter version of asserts for doubles</li> @@ -1105,7 +1104,7 @@ <Details> <![CDATA[ <p>Looks for code that checks to see if a field or local variable is not null, - before entering a code block either an if, or while statement, and then reassigns that + before entering a code block - either an if, or while statement - and then reassigns that field or local variable. It is likely that guard should have been to see if that field or local variable is null, not, not null.</p> <p>It is a fast detector.</p> @@ -1195,7 +1194,7 @@ <![CDATA[ <p>This detector looks for object creation where the object isn't assigned to any variable or field. This implies that the class operates through side effects in the constructor, which makes - for difficult to maintain code.</p> + for difficult-to-maintain code.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -1205,7 +1204,7 @@ <Details> <![CDATA[ <p>This detector looks for Java bean getter-setter use where the value of a property is set - with the value retrieved from the same bean's correllary getter, like this:</p> + with the value retrieved from the same bean's corollary getter, like this:</p> <pre><code> person.setAge(person.getAge()); </code></pre> @@ -1218,7 +1217,7 @@ <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 + <p>This detector looks for creation of java.awt.Graphics objects that do not have the <code>.dispose()</code> method called on them when finished. These objects will be cleaned up by the Garbage collector, bug given the likelihood 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> @@ -1230,7 +1229,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.StackedTryBlocks"> <Details> <![CDATA[ - <p>This detector looks for two or more try catch blocks that are consecutive + <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> @@ -1263,7 +1262,7 @@ <Details> <![CDATA[ <p>This detector looks for uses for commons-lang <code>ToStringBuilder</code> where the - result of <code>toString()</code> is returned without an intermediate invocation of toString().</p> + result of <code>toString()</code> is returned without an intermediate invocation of append().</p> <p>It is a fast detector.</p> ]]> </Details> @@ -1378,7 +1377,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.CollectionNamingConfusion"> <Details> <![CDATA[ @@ -1390,11 +1389,11 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.PoorMansEnum"> <Details> <![CDATA[ - <p>Looks for fields defined with simple types, (int, String, etc) that are used like an enum. Specifically fields that are + <p>Looks for fields defined with simple types, (int, String, etc) that are used like enums. Specifically fields that are only assigned a set of constant values. This variable probably should be redefined as an enum. </p> <p>It is a fast detector.</p> @@ -1401,26 +1400,26 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.UnusedParameter"> <Details> <![CDATA[ <p>Looks for private or static methods that have parameters that aren't used. These parameters can be removed, assuming the method isn't used through reflection.</p> - <p>It is fast detector.</p> + <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.FindClassCircularDependencies"> <Details> <![CDATA[ - <p>This detector looks circular dependencies among classes. </p> + <p>This detector looks for circular dependencies among classes. </p> <p>It is a moderately fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection"> <Details> <![CDATA[ @@ -1440,7 +1439,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.HttpClientProblems"> <Details> <![CDATA[ @@ -1450,7 +1449,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.Unjitable"> <Details> <![CDATA[ @@ -1461,76 +1460,76 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ConflictingTimeUnits"> <Details> <![CDATA[ <p>Looks for methods that perform arithmetic operations on values representing time - where the time unit is incompatible, i.e. adding a millisecond value to a nanosecond value. + where the time unit is incompatible, e.g. adding a millisecond value to a nanosecond value. </p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.CharsetIssues"> - <Details> - <![CDATA[ + + <Detector class="com.mebigfatguy.fbcontrib.detect.CharsetIssues"> + <Details> + <![CDATA[ <p>Looks for manual specification of String encoding using String constants where either - a StandardCharset could be used (JDK7) or where the encoding is not recognized with the - current JDK.</p> - <p>It is a fast detector.</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.ContainsBasedConditional"> - <Details> - <![CDATA[ - <p>Looks for complex if expressions made up of multiple conditions joined by OR, where the same - local variable is compared to a static value. When the number of conditions grow it is much cleaner - to build a static set of the possible values, and use the contains method on that set. This will - shorten the code, and make it more self documenting.</p> + a StandardCharset could be used (JDK7) or where the encoding is not recognized with the + current JDK.</p> <p>It is a fast detector.</p> - ]]> - </Details> - </Detector> - - <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod"> - <Details> - <![CDATA[ + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.ContainsBasedConditional"> + <Details> + <![CDATA[ + <p>Looks for complex <code>if</code> expressions made up of multiple conditions joined by OR, where the same + local variable is compared to a static value. When the number of conditions grows it is much cleaner + to build a static set of the possible values, and use the <code>contains</code> method on that set. This will + shorten the code, and make it more self documenting.</p> + <p>It is a fast detector.</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod"> + <Details> + <![CDATA[ <p>Looks for methods that are declared more permissively than the code is using. For instance, declaring - a method public, when it could just be declared private. Having methods have more permissive access than they - need to have limits your ability to make observations about these methods, like parameter usage, - refactorability, and derivability. This detector will not report on methods that are never called in - the case this method is an API like method intended to be called by client code. If this method is - also called through reflection, this detector may erroneous report it.</p> + a method public, when it could just be declared private. Giving methods more permissive access than they + need to have limits your ability to make observations about these methods, like parameter usage, + refactorability, and derivability. This detector will not report on methods that are never called, in + case this method is an API-like method intended to be called by client code. If this method is + also called through reflection, this detector may erroneously report it.</p> <p>It is a moderately fast detector.</p> - ]]> - </Details> - </Detector> - + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes"> <Details> <![CDATA[ <p>Looks for classes that store fields that are Strings that impersonate instances of classes, or collections that are - fields that hold Strings that impersonate a class. Examples of String impersonating are storing: + fields that hold Strings that impersonate a class. Examples of String impersonation are storing: <ul> <li>The result of a toString call</li> - <li>Strings build from parsing or building strings from other objects, such as "1,2,3,4" or "Project:3"</li> + <li>Strings built from parsing or building strings from other objects, such as "1,2,3,4" or "Project:3"</li> </ul> By using Strings you are throwing away type-safety, and making it difficult to reason about what the values of variables - in use are. If a String has multiple parts to it, it probably belongs as a first class Class. + in use are. If a String has multiple parts to it, it probably belongs as a first-class Class. </p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousLoopSearch"> <Details> <![CDATA[ - <p>Looks for methods that assign a value to a variable in an if equals conditional in a loop, but does not break after doing so. + <p>Looks for methods that assign a value to a variable in an "if equals" conditional in a loop, but do not break after doing so. Since equality would seem to be a one time event, continuing with the loop seems pointless, and a break statement in the if statement seems like it should be added.</p> <p>It is a fast detector.</p> @@ -1537,7 +1536,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles"> <Details> <![CDATA[ @@ -1548,12 +1547,12 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass"> <Details> <![CDATA[ - <p>Looks for classes that are not fully complete from a usability point of view. Making them more difficult to use - than it should be. Things such as + <p>Looks for classes that are not fully complete from a usability point of view, making them more difficult to use + than they should be. Things such as <ul> <li>Using the default package</li> <li>Missing hashCode/equals</li> @@ -1565,7 +1564,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues"> <Details> <![CDATA[ @@ -1574,22 +1573,22 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.JPAIssues"> <Details> <![CDATA[ - <p>Looks for problems with the use of the JPA specification, including spring's + <p>Looks for problems with the use of the JPA specification, including Spring's support of JPA</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SuboptimalExpressionOrder"> <Details> <![CDATA[ <p>Looks for conditional expressions that are a combination of simple local variable (in)equalities - and tests on the results of method calls where the method calls are done first. By placing the simple + and tests on the results of method calls, where the method calls are done first. By placing the simple conditions first you may eliminate costly calls in certain cases. This assumes that the method calls do not have side effects that should happen always.</p> <p>It is a fast detector.</p> @@ -1596,7 +1595,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.IOIssues"> <Details> <![CDATA[ @@ -1605,30 +1604,30 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.DubiousMapCollection"> <Details> <![CDATA[ - <p>Looks for use of maps that are private fields in a List only way, that is, maps that are created in constructors + <p>Looks for use of maps that are private fields in a List-only way, that is, maps that are created in constructors or static initializers, and are only iterated over. Often this is done because the Map allows for two values, as opposed - to a List. The Fix is to just create a List of some object that holds all the values.</p> + to a List. The fix is to just create a List of some object that holds all the values.</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.BuryingLogic"> <Details> <![CDATA[ <p>Looks for methods that needlessly push a large chunk of code to the right through indenting with braces. - The code is basically an if/else-then-return structure. The if true test does the bulk of the logic, and the else - just returns. It is more readable if the bulk of the logic is move as far to the left in the method as is possible. + The code is basically an if/else-then-return structure. The "if true" test does the bulk of the logic, and the else + just returns. It is more readable if the bulk of the logic is moved as far to the left in the method as is possible. </p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.WiringIssues"> <Details> <![CDATA[ @@ -1637,36 +1636,36 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ConcurrentCollectionIssues"> <Details> <![CDATA[ - <p>Looks for problems with using concurrent collections + <p>Looks for problems with using concurrent collections. <ul> - <li>Adding a collection as a value of Concurrent map, without the use of putIfAbsent</li> + <li>Adding a collection as a value of a Concurrent map, without the use of putIfAbsent</li> </ul> </p> <p>It is a fast detector.</p> - ]]> + ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources"> <Details> <![CDATA[ <p>Looks for use of auto-closeable resources in JDK 7 or later that are not using - the try-with-resources paradigm. To avoid problems, and ease the reader, use of try-with-resources + the try-with-resources paradigm. To avoid problems, and ease the reader, use of try-with-resources is recommended</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousShadedClassUse"> <Details> <![CDATA[ - <p>Looks for use of shaded methods from 3rdparty jars, created by tools such as the maven shade plugin. - These methods are from classes that have been included in a jar, for internal use, and are copies of real 3rdparty jars. + <p>Looks for use of shaded methods from 3rd-party jars, created by tools such as the Maven shade plugin. + These methods are from classes that have been included in a jar, for internal use, and are copies of real 3rd-party jars. It is likely you meant to use the real class from the real jar, but your IDE picked the wrong import to use. </p> <p>It is a fast detector.</p> @@ -1677,13 +1676,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnsynchronizedSingletonFieldWrites"> <Details> <![CDATA[ - <p>Looks for writes to fields of classes that are believed to be classes used only as Singletons. These + <p>Looks for writes to fields of classes that are believed to be classes used only as Singletons. These classes include Enums, as well as spring beans that are Singleton scoped.</p> <p>It is a fast detector.</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.OptionalIssues"> <Details> <![CDATA[ @@ -1692,11 +1691,11 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion"> <Details> <![CDATA[ - <p>Looks for code that appears to be using two forms of similar apis, an older one, and a new one. + <p>Looks for code that appears to be using two forms of similar apis: an older one, and a new one. It finds code that creates newer api objects by first instantiating older api objects, and converting them into the new form. It is simpler just to create the new object directly.</p> <p>It is a fast detector</p> @@ -1703,7 +1702,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionIssues"> <Details> <![CDATA[ @@ -1712,16 +1711,16 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.AnnotationIssues"> <Details> <![CDATA[ - <p>Looks for issues around use of standard anntations</p> + <p>Looks for issues around use of standard annotations</p> <p>It is a fast detector</p> ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.MapUsageIssues"> <Details> <![CDATA[ @@ -1730,7 +1729,7 @@ ]]> </Details> </Detector> - + <Detector class="com.mebigfatguy.fbcontrib.detect.ListUsageIssues"> <Details> <![CDATA[ @@ -1740,7 +1739,24 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.FunctionalInterfaceIssues"> + <Details> + <![CDATA[ + <p>Looks for various issues around the use of @FunctionalInterfaces.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.SetUsageIssues"> + <Details> + <![CDATA[ + <p>Looks for various issues around the use of the Set interface</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> </Detector> @@ -1755,7 +1771,7 @@ <p>This method uses <code>StringBuffer</code> or <code>StringBuilder</code>'s append method to concatenate strings. However, it passes the result of doing a simple String concatenation to one of these append calls, thus removing any performance gains of using the <code>StringBuffer</code> or <code>StringBuilder</code> class.</p> - + <p> Java will implicitly use StringBuilders, which can make this hard to detect or fix. For example, <br/> <pre><code> @@ -1764,7 +1780,7 @@ sb.append(e.getKey() + e.getValue()); //bug detected here } </code></pre><br/> - + gets automatically turned into something like: <br/> <pre><code> StringBuilder sb = new StringBuilder(); @@ -1775,9 +1791,9 @@ <b>sb.append(tempBuilder.toString());</b> //this isn't too efficient } </code></pre><br/> - + which involves a temporary <code>StringBuilder</code>, which is completely unnecessary. To prevent this from happening, simply do:<br/> - + <pre><code> StringBuilder sb = new StringBuilder(); for (Map.Entry<Integer, String> e : map.entrySet()) { @@ -1811,12 +1827,12 @@ <p>This method concatenates the output of a <code>toString()</code> call into a <code>StringBuffer</code> or <code>StringBuilder</code>. It is simpler just to pass the object you want to append to the append call, as that form does not suffer the potential for <code>NullPointerException</code>s, and is easier to read.</p> - + <p> - Keep in mind that Java compiles simple <code>String</code> concatenation to use <code>StringBuilder</code>s, + Keep in mind that Java compiles simple <code>String</code> concatenation to use <code>StringBuilder</code>s, so you may see this bug even when you don't use <code>StringBuilder</code>s explicitly. </p> - + <p> Instead of: <br/> <pre><code> @@ -1846,7 +1862,7 @@ <Details> <![CDATA[ <p>This method uses a synchronized collection, built from Collections.synchronizedXXXX, but accesses it - through an iterator. Since an iterator is, by definition, multithreaded unsafe, this is a conflict in + through an iterator. Since an iterator is, by definition, multithreading-unsafe, this is a conflict in concept. When using iterators, you should do the synchronization manually.</p> ]]> </Details> @@ -1857,7 +1873,7 @@ <LongDescription>Method {1} is excessively complex, with a cyclomatic complexity of {3}</LongDescription> <Details> <![CDATA[ - <p>This method has a high cyclomatic complexity figure, which calculates the number of branch + <p>This method has a high cyclomatic complexity figure, which represents the number of branch points. It is likely difficult to test, and is brittle to change. Consider refactoring this method into several to reduce the risk.</p> ]]> @@ -1882,7 +1898,7 @@ } </code></pre> - The parameter list is currently defined as an <code>ArrayList</code>, which is a concrete implementation of the <code>List</code> interface. + The parameter list is currently defined as an <code>ArrayList</code>, which is a concrete implementation of the <code>List</code> interface. Specifying <code>ArrayList</code> is unnecessary here, because we aren't using any <code>ArrayList</code>-specific methods (like <code>ensureCapacity()</code> or <code>trimToSize()</code>). Instead of using the concrete definition, it is better to do something like:<br/> <pre><code> @@ -1903,7 +1919,7 @@ <LongDescription>Method {1} uses integer based for loops to iterate over a List</LongDescription> <Details> <![CDATA[ - <p>This method uses an integer based for loop to iterate over a java.util.List, by calling + <p>This method uses an integer-based <code>for</code> loop to iterate over a java.util.List, by calling List.get(i) each time through the loop. The integer is not used for other reasons. It is better to use an Iterator instead, as depending on List implementation, iterators can perform better, and they also allow for exchanging of other collection types without issue.</p> @@ -1917,7 +1933,7 @@ <Details> <![CDATA[ <p>This method adds unrelated objects to a collection or array, requiring careful and brittle - data access to that collection. Create a separate class with properties needed, and add + data access to that collection. Create a separate class with the properties needed, and add an instance of this class to the collection or array, if possible.</p> ]]> </Details> @@ -1941,7 +1957,6 @@ <LongDescription>Method {1} excessively uses methods of another class</LongDescription> <Details> <![CDATA[ - <p><em>THIS DETECTOR IS HIGHLY EXPERIMENTAL AND IS LIKELY TO CREATE A LOT OF FUD</em></p> <p>This method makes extensive use of methods from another class over methods of its own class. Typically this means that the functionality that is accomplished by this method most likely belongs with the class that is being used so liberally. Consider refactoring this @@ -1966,8 +1981,8 @@ "someOtherString".equals(str); //or "someOtherString".compareTo(str);</code></pre><br/> - that is, call <code>equals()</code> or <code>compareTo()</code> on the string literal, passing the - variable as an argument, this exception could never happen as both <code>equals()</code> and + that is, call <code>equals()</code> or <code>compareTo()</code> on the string literal, passing the + variable as an argument, then this exception could never happen as both <code>equals()</code> and <code>compareTo()</code> check for <code>null</code>.</p> ]]> </Details> @@ -1978,7 +1993,7 @@ <LongDescription>Constructor {1} makes call to non-final method</LongDescription> <Details> <![CDATA[ - <p>This constructor makes a call to a non-final method. Since this method can be overridden, a subclasses + <p>This constructor makes a call to a non-final method. Since this method can be overridden, a subclass' implementation will be executing against an object that has not been initialized at the subclass level. You should mark all methods called from the constructor as final to avoid this problem.</p> ]]> @@ -1992,7 +2007,7 @@ <![CDATA[ <p>This class defines a field based on java.util.List, but uses it to some extent like a Set. Since lookup type operations are performed using a linear search for Lists, the performance for large - Lists will be poor. If the list is known to only contain a small number of items, (3, 4, etc) then it + Lists will be poor. If the list is known to only contain a small number of items (3, 4, etc), then it doesn't matter. Otherwise, consider changing this field's implementation to a set-based one. If order of iteration is important to maintain insert order, perhaps consider a LinkedHashSet.</p> ]]> @@ -2022,7 +2037,7 @@ //or, for just two elements Map<String,Integer> wordCounts = new HashMap<String,Integer>(); </code></pre> - + </p> ]]> </Details> @@ -2036,10 +2051,10 @@ <p>This method does not write to a parameter. To help document this, and to perhaps help the JVM optimize the invocation of this method, you should consider defining these parameters as final.</p> - - <p>Performance gains are debatable as "the final keyword does not appear in the class file for - local variables and parameters, thus it cannot impact the runtime performance. Its only use - is to clarify the coders intent that the variable not be changed (which many consider dubious + + <p>Performance gains are debatable as "the final keyword does not appear in the class file for + local variables and parameters, thus it cannot impact the runtime performance. Its only use + is to clarify the coder's intent that the variable not be changed (which many consider dubious reason for its usage), and dealing with anonymous inner classes." - http://stackoverflow.com/a/266981/1447621 </p> ]]> </Details> @@ -2130,7 +2145,7 @@ <Details> <![CDATA[ <p>This method makes a static method call on an instance reference. For - reading comprehension of the code is better to call the method on the class, + reading comprehension of the code it is better to call the method on the class, rather than an instance. Perhaps this method's static nature has changed since this code was written, and should be revisited.</p> ]]> @@ -2142,9 +2157,9 @@ <LongDescription>Method {1} calls wait, notify or notifyAll on a Thread instance</LongDescription> <Details> <![CDATA[ - <p>This method invokes the methods wait, notify or notifyAll on a Thread instance. - Doing so will confuse the internal thread state behavior causing spurious thread - wakeups/sleeps because the internal mechanism also uses the thread instance for its + <p>This method invokes the methods <code>wait</code>, <code>notify</code> or <code>notifyAll</code> on a Thread instance. + Doing so will confuse the internal thread state behavior, causing spurious thread + wakeups/sleeps, because the internal mechanism also uses the thread instance for its notifications.</p> ]]> </Details> @@ -2168,7 +2183,7 @@ <Details> <![CDATA[ <p>This method passes a primitive value retrieved from a <code>BoxedPrimitive.parseBoxedPrimitive("1")</code> call to - the same class's constructor. It is simpler to just pass the string to the BoxedPrimitives constructor or, better yet, use the static valueOf.</p> + the same class's constructor. It is simpler to just pass the string to the BoxedPrimitive constructor or, better yet, use the static valueOf.</p> <p>Instead of something like:<br/> <pre><code> Boolean bo = new Boolean(Boolean.parseBoolean("true")); @@ -2194,7 +2209,7 @@ <LongDescription>Method {1} passes primitive wrapper to Wrapper class valueOf method</LongDescription> <Details> <![CDATA[ - <p>This method passes a wrapped primitive object to the same class's .valueOf method. + <p>This method passes a wrapped primitive object to the same class' <code>valueOf</code> method. Since wrapper classes are immutable, you can just use the original object, rather than calling valueOf to create a new one. This code works because of an abuse of autoboxing.</p> ]]> @@ -2210,7 +2225,7 @@ the boxedValue() method to convert to a primitive. When it is desired to convert from a String to a primitive value, it is simpler to use the BoxedPrimitive.parseBoxedPrimitive(String) method. </p> - + <p>Instead of something like:<br/> <pre><code> public int someMethod(String data) { @@ -2228,7 +2243,7 @@ } </code></pre> </p> - + ]]> </Details> </BugPattern> @@ -2239,9 +2254,9 @@ <Details> <![CDATA[ <p>This method passes a String to a wrapped primitive object's parse method, which in turn calls - the valueOf() method to convert to a boxed primitive. When it is desired to convert from a String + the <code>valueOf</code> method to convert to a boxed primitive. When it is desired to convert from a String to a boxed primitive object, it is simpler to use the BoxedPrimitive.valueOf(String) method.</p> - + <p>Instead of something like:<br/> <pre><code> Boolean bo = Boolean.valueOf(Boolean.parseBoolean("true")); @@ -2275,7 +2290,7 @@ float f = 1.234f; </code></pre> </p> - + ]]> </Details> </BugPattern> @@ -2325,7 +2340,7 @@ Boolean b = Boolean.FALSE; </code></pre> </p> - + <p>Be aware that this boxing happens automatically when you might not expect it. For example, <br/> <pre><code> Map<String, Boolean> statusMap = ... @@ -2335,9 +2350,9 @@ return false; //the "false" here is boxed } </code></pre> - has two cases of this needless autoboxing. This can be made more efficient by simply substituting + has two cases of this needless autoboxing. This can be made more efficient by simply substituting in the constant values: <br/> - + <pre><code> Map<String, Boolean> statusMap = ... @@ -2390,8 +2405,8 @@ </BugPattern> <BugPattern type="COM_COPIED_OVERRIDDEN_METHOD"> - <ShortDescription>Method is implemented with an exact copy of its superclass's method</ShortDescription> - <LongDescription>Method {1} is implemented with an exact copy of its superclass's method</LongDescription> + <ShortDescription>Method is implemented with an exact copy of its superclass' method</ShortDescription> + <LongDescription>Method {1} is implemented with an exact copy of its superclass' method</LongDescription> <Details> <![CDATA[ <p>This method is implemented using an exact copy of its superclass method's @@ -2399,7 +2414,7 @@ ]]> </Details> </BugPattern> - + <BugPattern type="COM_PARENT_DELEGATED_CALL"> <ShortDescription>Method merely delegates to its superclass's version</ShortDescription> <LongDescription>Method {1} merely delegates to its superclass's version</LongDescription> @@ -2417,7 +2432,7 @@ <Details> <![CDATA[ <p>This method passes an array as the key to a Map, element in a Set, or item in a List when - the contains method is used on the List. Since arrays do not and cannot override the equals + the contains method is used on the List. Since arrays do not and cannot override the <code>equals</code> method, collection inclusion is based on the reference's address, which is probably not desired. In the case that this is a TreeMap or TreeSet, consider passing a Comparator to the map's constructor.</p> @@ -2453,7 +2468,7 @@ <![CDATA[ <p>This method generates an XML based string by concatenating together various XML fragments, and variable values. Doing so makes the code difficult to read, modify - and validate. It is much more clean to build XML structures in external files that are + and validate. It is much cleaner to build XML structures in external files that are read in and transformed into the final product, through modification by Transformer.setParameter.</p> ]]> </Details> @@ -2465,10 +2480,10 @@ <Details> <![CDATA[ <p>This method implements a synchronized block, but the code found at the beginning - of this block only accesses local variables, and not member variables, or this. - For better performance, move the code that accesses local variables only, above the + of this block only accesses local variables, and not member variables or <code>this</code>. + For better performance, move the code that accesses local variables only above the synchronized block, and leave the synchronized block only for field accesses, or access - to this object.</p> + to <code>this</code>.</p> ]]> </Details> </BugPattern> @@ -2587,8 +2602,8 @@ <LongDescription>Method {1} calls wait when await was probably intended</LongDescription> <Details> <![CDATA[ - <p>This method calls wait() on a on mutex defined in the java.util.concurrent package. - These classes, define await, instead of wait, and it is most likely that await + <p>This method calls wait() on a mutex defined in the java.util.concurrent package. + These classes define <code>await</code>, instead of <code>wait</code>, and it is most likely that <code>await</code> was intended.</p> ]]> </Details> @@ -2599,7 +2614,7 @@ <LongDescription>Method {1} uses JDBC vendor specific classes and methods</LongDescription> <Details> <![CDATA[ - <p>This method uses JDBC vendor specific classes and method to perform database work. + <p>This method uses JDBC vendor-specific classes and methods to perform database work. This makes the code specific to this vendor, and unable to run on other databases.</p> ]]> </Details> @@ -2616,9 +2631,9 @@ {<code>add()</code>, <code>append()</code>, <code>offer()</code>, <code>put()</code>, ...} <br/> with no method calls to removal meth... [truncated message content] |
From: <dbr...@us...> - 2018-03-04 05:49:13
|
Revision: 1833 http://sourceforge.net/p/fb-contrib/code/1833 Author: dbrosius Date: 2018-03-04 05:49:10 +0000 (Sun, 04 Mar 2018) Log Message: ----------- Version 7.2.1 Added Paths: ----------- tags/v7_2_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2018-03-04 05:43:16
|
Revision: 1832 http://sourceforge.net/p/fb-contrib/code/1832 Author: dbrosius Date: 2018-03-04 05:43:03 +0000 (Sun, 04 Mar 2018) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/bugrank.txt trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/FBContrib.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectNullableMethodStatus.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractCollectionScanningDetector.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CharsetIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CommonsEqualsBuilderToEquals.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CommonsStringBuilderToString.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CompareClassNameEquals.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConcurrentCollectionIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConflatingResourcesAndFiles.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConflictingTimeUnits.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingArrayAsList.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingAutoboxedOverloading.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConfusingFunctionSemantics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ConstantListIndex.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ContainsBasedConditional.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ContraVariantArrayAssignment.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CustomBuiltXML.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CyclomaticComplexity.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DateComparison.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousMapCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousSetOfCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FinalParameters.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FloatingPointLoops.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/HttpClientProblems.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImproperPropertiesUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JAXRSIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LingeringGraphicsObjects.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LocalTypeDetector.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MapUsageIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ModifyingUnmodifiableCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessAutoboxing.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessCustomSerialization.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessInstanceRetrieval.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NeedlessMemberCollectionSynchronization.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonCollectionMethodUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonFunctionalField.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonOwnedSynchronization.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonProductiveMethodCall.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ParallelLists.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorMansEnum.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleIncompleteSerialization.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleMemoryBloat.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleUnsuspectedSerialization.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/RuntimeExceptionDeclared.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SQLInLoop.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SloppyClassReflection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SluggishGui.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SpuriousThreadStates.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StringifiedTypes.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuboptimalExpressionOrder.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousCloneAlgorithm.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousComparatorReturnValues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousGetterSetterUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousLoopSearch.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousWaitOnConcurrentObject.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/TailRecursion.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/TristateBooleanPattern.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnitTestAssertionOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/Unjitable.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnnecessaryApiConversion.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnnecessaryStoreBeforeReturn.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnsynchronizedSingletonFieldWrites.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnusedParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseAddAll.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseToArray.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseTryWithResources.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseVarArgs.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WeakExceptionMessaging.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WiringIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WriteOnlyCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/CodeByteUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/CollectionUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/FQField.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/FQMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/OpcodeUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/PublicAPI.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/QMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/StopOpcodeParsingException.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/TernaryPatcher.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/UnmodifiableList.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/UnmodifiableSet.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/XClassUtils.java trunk/fb-contrib/src/samples/java/ex/AI_Sample.java trunk/fb-contrib/src/samples/java/ex/OC_Sample.java trunk/fb-contrib/src/samples/java/ex/PSC_Sample.java trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java trunk/fb-contrib/src/samples/java/ex/UEC_Sample.java trunk/fb-contrib/src/samples/java/ex/UTAO_Sample.java trunk/fb-contrib/src/test/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilderTest.java trunk/fb-contrib/src/test/java/com/mebigfatguy/fbcontrib/utils/SignatureUtilsTest.java Added Paths: ----------- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListUsageIssues.java trunk/fb-contrib/src/samples/java/ex/LUI_Sample.java trunk/fb-contrib/src/samples/java/ex/MUI_Sample.java Removed Paths: ------------- trunk/fb-contrib/src/samples/java/ex/MUP_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/build.xml 2018-03-04 05:43:03 UTC (rev 1832) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.2.0" /> + <property name="fb-contrib.version" value="7.2.1" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -256,7 +256,7 @@ <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" access="private"> <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2005-2017 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <bottom><![CDATA[<i>Copyright © 2005-2018 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/etc/bugrank.txt 2018-03-04 05:43:03 UTC (rev 1832) @@ -112,6 +112,9 @@ +0 BugPattern LO_TOSTRING_PARAMETER +2 BugPattern LSC_LITERAL_STRING_COMPARISON +0 BugPattern LSYC_LOCAL_SYNCHRONIZED_COLLECTION ++0 BugPattern LUI_USE_COLLECTION_ADD ++0 BugPattern LUI_USE_GET0 ++0 BugPattern LUI_USE_SINGLETON_LIST +2 BugPattern MAC_MANUAL_ARRAY_COPY +0 BugPattern MDM_BIGDECIMAL_EQUALS +0 BugPattern MDM_INETADDRESS_GETLOCALHOST @@ -131,7 +134,11 @@ +2 BugPattern MOM_MISLEADING_OVERLOAD_MODEL +0 BugPattern MRC_METHOD_RETURNS_CONSTANT +0 BugPattern MUC_MODIFYING_UNMODIFIABLE_COLLECTION -+0 BugPattern MUP_CONTAINSKEY_BEFORE_GET ++0 BugPattern MUI_CALLING_SIZE_ON_SUBCONTAINER ++0 BugPattern MUI_CONTAINSKEY_BEFORE_GET ++0 BugPattern MUI_GET_BEFORE_REMOVE ++0 BugPattern MUI_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR ++0 BugPattern MUI_USE_CONTAINSKEY +0 BugPattern NAB_NEEDLESS_AUTOBOXING_CTOR +0 BugPattern NAB_NEEDLESS_AUTOBOXING_VALUEOF +0 BugPattern NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION @@ -168,6 +175,7 @@ +0 BugPattern PME_POOR_MANS_ENUM +0 BugPattern PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS +0 BugPattern PSC_PRESIZE_COLLECTIONS ++0 BugPattern PSC_SUBOPTIMAL_COLLECTION_SIZING +0 BugPattern PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION +0 BugPattern RFI_SET_ACCESSIBLE +0 BugPattern ROOM_REFLECTION_ON_OBJECT_METHODS @@ -210,7 +218,6 @@ +0 BugPattern SPP_NON_USEFUL_TOSTRING +0 BugPattern SPP_NO_CHAR_SB_CTOR +0 BugPattern SPP_NULL_BEFORE_INSTANCEOF -+0 BugPattern SPP_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR +0 BugPattern SPP_NULL_CHECK_ON_OPTIONAL +0 BugPattern SPP_SERIALVER_SHOULD_BE_PRIVATE +0 BugPattern SPP_STATIC_FORMAT_STRING @@ -224,7 +231,6 @@ +0 BugPattern SPP_USELESS_TERNARY +0 BugPattern SPP_USE_BIGDECIMAL_STRING_CTOR +0 BugPattern SPP_USE_CHARAT -+0 BugPattern SPP_USE_CONTAINSKEY +0 BugPattern SPP_USE_GET0 +0 BugPattern SPP_USE_GETPROPERTY +0 BugPattern SPP_USE_ISEMPTY Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/etc/findbugs.xml 2018-03-04 05:43:03 UTC (rev 1832) @@ -23,7 +23,7 @@ <!-- Detectors --> - <!-- COMMENT OUT FOR RELEASE + <!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -148,7 +148,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousComparatorReturnValues" speed="fast" reports="SCRV_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_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_CONTAINSKEY,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_SERIALVER_SHOULD_BE_PRIVATE,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING,SPP_NULL_CHECK_ON_OPTIONAL,SPP_WRONG_COMMONS_TO_STRING_OBJECT,SPP_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR" /> + reports="SPP_NEGATIVE_BITSET_ITEM,SPP_INTERN_ON_CONSTANT,SPP_NO_CHAR_SB_CTOR,SPP_USE_MATH_CONSTANT,SPP_STUTTERED_ASSIGNMENT,SPP_USE_ISNAN,SPP_USE_BIGDECIMAL_STRING_CTOR,SPP_STRINGBUFFER_WITH_EMPTY_STRING,SPP_EQUALS_ON_ENUM,SPP_INVALID_BOOLEAN_NULL_CHECK,SPP_USE_CHARAT,SPP_USELESS_TERNARY,SPP_SUSPECT_STRING_TEST,SPP_USE_STRINGBUILDER_LENGTH,SPP_INVALID_CALENDAR_COMPARE,SPP_USE_ISEMPTY,SPP_USE_GETPROPERTY,SPP_USELESS_CASING,SPP_SERIALVER_SHOULD_BE_PRIVATE,SPP_NON_ARRAY_PARM,SPP_EMPTY_CASING,SPP_TEMPORARY_TRIM,SPP_STRINGBUILDER_IS_MUTABLE,SPP_USE_GET0,SPP_DOUBLE_APPENDED_LITERALS,SPP_NULL_BEFORE_INSTANCEOF,SPP_NON_USEFUL_TOSTRING,SPP_TOSTRING_ON_STRING,SPP_EQUALS_ON_STRING_BUILDER,SPP_CONVERSION_OF_STRING_LITERAL,SPP_STATIC_FORMAT_STRING,SPP_NULL_CHECK_ON_OPTIONAL,SPP_WRONG_COMMONS_TO_STRING_OBJECT" /> <Detector class="com.mebigfatguy.fbcontrib.detect.SpoiledChildInterfaceImplementor" speed="fast" reports="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" /> @@ -264,7 +264,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ModifyingUnmodifiableCollection" speed="fast" reports="MUC_MODIFYING_UNMODIFIABLE_COLLECTION"/> - <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.PresizeCollections" speed="fast" reports="PSC_PRESIZE_COLLECTIONS,PSC_SUBOPTIMAL_COLLECTION_SIZING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ArrayIndexOutOfBounds" speed="fast" reports="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS,AIOB_ARRAY_STORE_TO_NULL_REFERENCE" /> @@ -322,14 +322,17 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.AnnotationIssues" speed="fast" reports="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE"/> - <Detector class="com.mebigfatguy.fbcontrib.detect.MapUsageIssues" speed="fast" reports="MUP_CONTAINSKEY_BEFORE_GET"/> + <Detector class="com.mebigfatguy.fbcontrib.detect.MapUsageIssues" speed="fast" reports="MUI_CONTAINSKEY_BEFORE_GET,MUI_GET_BEFORE_REMOVE,MUI_CALLING_SIZE_ON_SUBCONTAINER,MUI_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR,MUI_USE_CONTAINSKEY"/> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus" speed="fast" reports="" hidden="true" /> - <!-- COMMENT OUT FOR POINT RELEASE --> - <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE + <Detector class="com.mebigfatguy.fbcontrib.detect.ListUsageIssues" speed="fast" reports="LUI_USE_SINGLETON_LIST,LUI_USE_COLLECTION_ADD,LUI_USE_GET0"/> + + COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -422,7 +425,6 @@ <BugPattern abbrev="SPP" type="SPP_SUSPECT_STRING_TEST" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_USE_STRINGBUILDER_LENGTH" category="PERFORMANCE" /> <BugPattern abbrev="SPP" type="SPP_INVALID_CALENDAR_COMPARE" category="CORRECTNESS" /> - <BugPattern abbrev="SPP" type="SPP_USE_CONTAINSKEY" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_USE_ISEMPTY" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_USE_GETPROPERTY" category="STYLE" /> <BugPattern abbrev="SPP" type="SPP_USELESS_CASING" category="PERFORMANCE" /> @@ -441,7 +443,6 @@ <BugPattern abbrev="SPP" type="SPP_STATIC_FORMAT_STRING" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_NULL_CHECK_ON_OPTIONAL" category="CORRECTNESS" /> <BugPattern abbrev="SPP" type="SPP_WRONG_COMMONS_TO_STRING_OBJECT" category="CORRECTNESS" /> - <BugPattern abbrev="SPP" type="SPP_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR" category="CORRECTNESS" /> <BugPattern abbrev="BAS" type="BAS_BLOATED_ASSIGNMENT_SCOPE" category="PERFORMANCE" /> <BugPattern abbrev="SCII" type="SCII_SPOILED_CHILD_INTERFACE_IMPLEMENTOR" category="STYLE" /> <BugPattern abbrev="DWI" type="DWI_DELETING_WHILE_ITERATING" category="CORRECTNESS" /> @@ -550,6 +551,7 @@ <BugPattern abbrev="CU" type="CU_CLONE_USABILITY_THROWS" category="STYLE" /> <BugPattern abbrev="CAAL" type="CAAL_CONFUSING_ARRAY_AS_LIST" category="CORRECTNESS" /> <BugPattern abbrev="PSC" type="PSC_PRESIZE_COLLECTIONS" category="PERFORMANCE" /> + <BugPattern abbrev="PSC" type="PSC_SUBOPTIMAL_COLLECTION_SIZING" category="PERFORMANCE" /> <BugPattern abbrev="UMTP" type="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="NPMC" type="NPMC_NON_PRODUCTIVE_METHOD_CALL" category="CORRECTNESS" /> <BugPattern abbrev="AIOB" type="AIOB_ARRAY_INDEX_OUT_OF_BOUNDS" category="CORRECTNESS" /> @@ -618,5 +620,12 @@ <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" category="CORRECTNESS"/> <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS" experimental="true"/> <BugPattern abbrev="AI" type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" category="CORRECTNESS" experimental="true" /> - <BugPattern abbrev="MUP" type="MUP_CONTAINSKEY_BEFORE_GET" category="STYLE" experimental="true" /> + <BugPattern abbrev="MUI" type="MUI_CONTAINSKEY_BEFORE_GET" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="MUI" type="MUI_GET_BEFORE_REMOVE" category="CORRECTNESS"/> + <BugPattern abbrev="MUI" type="MUI_CALLING_SIZE_ON_SUBCONTAINER" category="CORRECTNESS" /> + <BugPattern abbrev="MUI" type="MUI_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR" category="CORRECTNESS" /> + <BugPattern abbrev="MUI" type="MUI_USE_CONTAINSKEY" category="CORRECTNESS" /> + <BugPattern abbrev="LUI" type="LUI_USE_SINGLETON_LIST" category="CORRECTNESS" /> + <BugPattern abbrev="LUI" type="LUI_USE_COLLECTION_ADD" category="CORRECTNESS" /> + <BugPattern abbrev="LUI" type="LUI_USE_GET0" category="CORRECTNESS" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/etc/messages.xml 2018-03-04 05:43:03 UTC (rev 1832) @@ -1731,7 +1731,16 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.ListUsageIssues"> + <Details> + <![CDATA[ + <p>Looks for dubious usage patterns around the List interface</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> </Detector> @@ -3221,7 +3230,7 @@ </Details> </BugPattern> - <BugPattern type="SPP_USE_CONTAINSKEY"> + <BugPattern type="MUI_USE_CONTAINSKEY"> <ShortDescription>Method calls keySet() just to call contains, use containsKey instead</ShortDescription> <LongDescription>Method {1} calls keySet() just to call contains, use containsKey instead</LongDescription> <Details> @@ -3490,7 +3499,7 @@ </Details> </BugPattern> - <BugPattern type="SPP_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR"> + <BugPattern type="MUI_NULL_CHECK_ON_MAP_SUBSET_ACCESSOR"> <ShortDescription>Method checks whether the keySet(), entrySet() or values() collection of a Map is null</ShortDescription> <LongDescription>Method {1} checks whether the keySet(), entrySet() or values() collection of a Map is null</LongDescription> <Details> @@ -4957,6 +4966,28 @@ ]]> </Details> </BugPattern> + + <BugPattern type="PSC_SUBOPTIMAL_COLLECTION_SIZING"> + <ShortDescription>Method uses suboptimal sizing to allocation a collection</ShortDescription> + <LongDescription>Method {1} uses suboptimal sizing to allocation a collection</LongDescription> + <Details> + <![CDATA[ + <p>This method allocates a collection using the a constructor that takes a size parameter. However, + because Maps and Sets have a loading factor, passing in the exact size you want is an + incorrect way to presize the collection, and may still cause reallocations. Since you are using + Guava, it is better to use + <code><pre> + Maps.newHashMapWithExpectedSize(c.size()); + </pre></code> + or + <code><pre> + Sets.newHashSetWithExpectedsize(c.size()); + </pre></code> + as this method calculates the correct size taking into account the loading factor. + </p> + ]]> + </Details> + </BugPattern> <BugPattern type="UMTP_UNBOUND_METHOD_TEMPLATE_PARAMETER"> <ShortDescription>Method declares unbound method template parameter(s)</ShortDescription> @@ -5991,7 +6022,7 @@ <![CDATA[ <p>This method creates a java.nio.file.Path object by first creating a java.io.File object, and then calling toPath() on it. It is simpler to just construct the Path object directly, say by using - {@code Path.get(String...)}. + {@code Paths.get(String...)}. </p> ]]> </Details> @@ -6034,7 +6065,20 @@ </Details> </BugPattern> - <BugPattern type="MUP_CONTAINSKEY_BEFORE_GET"> + <BugPattern type="MUI_CALLING_SIZE_ON_SUBCONTAINER"> + <ShortDescription>Method calls size() on a sub collection of a Map</ShortDescription> + <LongDescription>Method {1} calls size() on a sub collection of a Map</LongDescription> + <Details> + <![CDATA[ + <p>This method calls size on the keySet(), entrySet() or values() collection of a Map. These sub collections + will have the same size as the base Map and so it is just simpler to call size on that Map. Calling size() on + one of these sub collections will causes unnecessary allocations to occur. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="MUI_CONTAINSKEY_BEFORE_GET"> <ShortDescription>Method check a map with containsKey(), before using get()</ShortDescription> <LongDescription>Method {1} checks a map with containsKey(), before using get()</LongDescription> <Details> @@ -6086,12 +6130,87 @@ } where NOT_FOUND is some constant that denotes this special status. Of course you will need to find a special sentinel value for each type you are using that isn't possible to have normally. - </p> </pre> </code> + </p> ]]> </Details> </BugPattern> + + <BugPattern type="MUI_GET_BEFORE_REMOVE"> + <ShortDescription>Method gets an item from a map with get(), before using remove()</ShortDescription> + <LongDescription>Method {1} gets an item from a map with get(), before using remove()</LongDescription> + <Details> + <![CDATA[ + <p>This method fetches the value of an entry in a map using get(K k), and then follows it up with a remove(K k). + Since a remove() also returns the value, there is no point for doing the get, and just causes two map lookups + to occur when it can be done with just one.</p> + <p>As an example, instead of using + <code> + <pre> + Map<String, String> myMap = getSomeMap(); + String v myMap.get("foo")) { + myMap.remove("foo"); + </pre> + </code> + convert this to + <code> + <pre> + Map<String, String> myMap = getSomeMap(); + String v = myMap.remove("foo"); + </pre> + </code> + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="LUI_USE_SINGLETON_LIST"> + <ShortDescription>Method builds a list from one element using Arrays.asList</ShortDescription> + <LongDescription>Method {1} builds a list from one element using Arrays.asList rather than Collections.singletonList</LongDescription> + <Details> + <![CDATA[ + <p>This method builds a list using Arrays.asList(foo), passing in a single element. Arrays.asList needs to first create an array from this one + element, and then build a List that wraps this array. It is simpler to use Collections.singletonList(foo), which does not create the array, and + produces a far simpler instance of List. Since both of these arrays are immutable (from the Lists point of view) they are equivalent from a usage + standpoint. + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="LUI_USE_GET0"> + <ShortDescription>Method uses collection streaming to get first item in a List</ShortDescription> + <LongDescription>Method {1} uses collection streaming to get first item in a List</LongDescription> + <Details> + <![CDATA[ + <p>This method fetches the first item in a List using collection streaming. As a list is already ordered + there is no need to do that just use the regular get(0) interface.<br/> + Example: + <code><pre> + String s = myList.stream().findFirst().get(); + </pre></code> + Can be more simply done using + <code><pre> + String s = myList.get(0); + </pre></code> + </p> + ]]> + </Details> + </BugPattern> + + <BugPattern type="LUI_USE_COLLECTION_ADD"> + <ShortDescription>Method passes a temporary one item list to Collection.addAll()</ShortDescription> + <LongDescription>Method {1} passes a temporary one item list to Collection.addAll()</LongDescription> + <Details> + <![CDATA[ + <p>This method creates a temporary list using Collections.singletonList, or Arrays.asList with one + element in it, and then turns around and calls the addAll() method on another collection. Since you + are only adding one element to the collection, it is simpler to just call the add(object) method on + the collection you are using and by pass creating the intermediate List.</p> + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -6237,5 +6356,6 @@ <BugCode abbrev="UAC">Unnecessary Api Conversion</BugCode> <BugCode abbrev="RFI">Reflection Issues</BugCode> <BugCode abbrev="AI">Annotation Issues</BugCode> - <BugCode abbrev="MUP">Map Usage Issues</BugCode> + <BugCode abbrev="MUI">Map Usage Issues</BugCode> + <BugCode abbrev="LUI">List Usage Issues</BugCode> </MessageCollection> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/htdocs/index.shtml 2018-03-04 05:43:03 UTC (rev 1832) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.2.0 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.2.1 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -97,7 +97,7 @@ <li><b>[AI] Annotation Issues</b><br/> Looks for issues around use of common annotations </li> - <li><b>[MUP] Map Usage Issues</b><br/> + <li><b>[MUI] Map Usage Issues</b><br/> Looks for odd usage patterns when using Maps </li> </ul> Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/htdocs/repository.html 2018-03-04 05:43:03 UTC (rev 1832) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.2.0 or 7.2.0.sb</td></tr> + <tr><td><b>Version:</b></td><td>7.2.1 or 7.2.1.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/pom.xml 2018-03-04 05:43:03 UTC (rev 1832) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.2.0</version> + <version>7.2.1</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/FBContrib.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/FBContrib.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/FBContrib.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -37,7 +37,7 @@ public static void main(final String[] args) { JOptionPane.showMessageDialog(null, "To use fb-contrib, copy this jar file into your local FindBugs plugin directory, and use FindBugs as usual.\n\nfb-contrib is a trademark of MeBigFatGuy.com\nFindBugs is a trademark of the University of Maryland", - "fb-contrib: copyright 2005-2017", JOptionPane.INFORMATION_MESSAGE); + "fb-contrib: copyright 2005-2018", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/collect/CollectNullableMethodStatus.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectNullableMethodStatus.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectNullableMethodStatus.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,7 +29,7 @@ @SuppressWarnings({ "PMD", "CPD-START" }) public class CollectNullableMethodStatus extends AnnotationIssues implements NonReportingDetector { - public CollectNullableMethodStatus(BugReporter bugReporter) { + public CollectNullableMethodStatus(@SuppressWarnings("unused") BugReporter bugReporter) { super(null); } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/ImmutabilityType.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/collect/MethodInfo.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/MethodInfo.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/MethodInfo.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,7 +1,7 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Kevin Lubick - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 Kevin Lubick + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/OCSDebugger.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractClassEmptyMethods.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/AbstractCollectionScanningDetector.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractCollectionScanningDetector.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractCollectionScanningDetector.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbstractOverriddenMethod.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -52,7 +52,7 @@ private static final String USER_NULLABLE_ANNOTATIONS = "fb-contrib.ai.annotations"; - public static final Set<String> NULLABLE_ANNOTATIONS = new HashSet<>(); + private static final Set<String> NULLABLE_ANNOTATIONS = new HashSet<>(); static { NULLABLE_ANNOTATIONS.add("Lorg/jetbrains/annotations/Nullable;"); @@ -128,6 +128,10 @@ return; } + if (method.isSynthetic() && !isCollecting()) { + return; + } + if (methodHasNullableAnnotation(method)) { if (isCollecting()) { MethodInfo methodInfo = Statistics.getStatistics().getMethodStatistics(getClassName(), method.getName(), method.getSignature()); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayIndexOutOfBounds.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BackportReusePublicIdentifiers.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,7 +1,7 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Bhaskar Maddala - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 Bhaskar Maddala + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -81,13 +81,13 @@ private static final Set<FQMethod> dangerousAssignmentMethodSources = UnmodifiableSet.create( //@formatter:off - new FQMethod("java/lang/System", "currentTimeMillis", "()J"), - new FQMethod("java/lang/System", "nanoTime", "()J"), - new FQMethod("java/util/Calendar", "get", "(I)I"), - new FQMethod("java/util/GregorianCalendar", "get", "(I)I"), - new FQMethod("java/util/Iterator", "next", "()Ljava/lang/Object;"), - new FQMethod("java/util/regex/Matcher", "start", "()I"), - new FQMethod("java/util/concurrent/TimeUnit", "toMillis", "(J)J") + new FQMethod("java/lang/System", "currentTimeMillis", SignatureBuilder.SIG_VOID_TO_LONG), + new FQMethod("java/lang/System", "nanoTime", SignatureBuilder.SIG_VOID_TO_LONG), + new FQMethod("java/util/Calendar", "get", SignatureBuilder.SIG_INT_TO_INT), + new FQMethod("java/util/GregorianCalendar", "get", SignatureBuilder.SIG_INT_TO_INT), + new FQMethod("java/util/Iterator", "next", SignatureBuilder.SIG_VOID_TO_OBJECT), + new FQMethod("java/util/regex/Matcher", "start", SignatureBuilder.SIG_VOID_TO_INT), + new FQMethod("java/util/concurrent/TimeUnit", "toMillis", SignatureBuilder.SIG_LONG_TO_LONG) //@formatter:on ); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/CharsetIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CharsetIssues.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CharsetIssues.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ClassEnvy.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CloneUsability.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 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/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java 2017-12-27 00:20:36 UTC (rev 1831) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java 2018-03-04 05:43:03 UTC (rev 1832) @@ -1,6 +1,6 @@ /* * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2017 Dave Brosius + * Copyright (C) 2005-2018 Dave Brosius * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -48,7 +48,7 @@ private JavaClass queueInterface; private BugReporter bugRe... [truncated message content] |
From: <dbr...@us...> - 2017-12-27 00:20:38
|
Revision: 1831 http://sourceforge.net/p/fb-contrib/code/1831 Author: dbrosius Date: 2017-12-27 00:20:36 +0000 (Wed, 27 Dec 2017) Log Message: ----------- Version 7.2.0 Added Paths: ----------- tags/v7_2_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-12-27 00:18:49
|
Revision: 1830 http://sourceforge.net/p/fb-contrib/code/1830 Author: dbrosius Date: 2017-12-27 00:18:47 +0000 (Wed, 27 Dec 2017) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-12-26 23:49:41 UTC (rev 1829) +++ trunk/fb-contrib/build.xml 2017-12-27 00:18:47 UTC (rev 1830) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.1.0-SNAPSHOT" /> + <property name="fb-contrib.version" value="7.2.0" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-12-26 23:49:41 UTC (rev 1829) +++ trunk/fb-contrib/etc/findbugs.xml 2017-12-27 00:18:47 UTC (rev 1830) @@ -23,7 +23,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE --> + <!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -33,7 +33,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - <!-- COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -315,9 +315,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OptionalIssues" speed="fast" reports="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION,OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION,OI_OPTIONAL_ISSUES_CHECKING_REFERENCE,OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED,OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL"/> <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion" speed="fast" reports="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT,UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"/> - - <!-- COMMENT OUT FOR POINT RELEASE --> - + <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources" speed="fast" reports="UTWR_USE_TRY_WITH_RESOURCES"/> <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionIssues" speed="fast" reports="RFI_SET_ACCESSIBLE"/> @@ -330,6 +328,7 @@ <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-12-26 23:49:41 UTC (rev 1829) +++ trunk/fb-contrib/htdocs/index.shtml 2017-12-27 00:18:47 UTC (rev 1830) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.5 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.2.0 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on @@ -77,9 +77,16 @@ </div> <hr/> - <img id="git_image" src="flip2.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> + <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> Detectors added in git<br/> - <div id="git" style="display:block;"> + <div id="git" style="display:none;"> + <ul> + </ul> + </div> + <hr/> + <img id="v7_2_0_image" src="flip2.gif" onClick="toggleBlock('v7_2_0', 'v7_2_0_image');" align="top"/> + Detectors added in v7.2.0<br/> + <div id="v7_2_0" style="display:block;"> <ul> <li><b>[UTWR] Use Try With Resources</b><br/> Looks for try/finally blocks that manage resources, without using try-with-resources. Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2017-12-26 23:49:41 UTC (rev 1829) +++ trunk/fb-contrib/htdocs/repository.html 2017-12-27 00:18:47 UTC (rev 1830) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.0.5 or 7.0.5.sb</td></tr> + <tr><td><b>Version:</b></td><td>7.2.0 or 7.2.0.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-12-26 23:49:41 UTC (rev 1829) +++ trunk/fb-contrib/pom.xml 2017-12-27 00:18:47 UTC (rev 1830) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.1.0-SNAPSHOT</version> + <version>7.2.0</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-12-26 23:49:47
|
Revision: 1829 http://sourceforge.net/p/fb-contrib/code/1829 Author: dbrosius Date: 2017-12-26 23:49:41 +0000 (Tue, 26 Dec 2017) Log Message: ----------- sync 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 trunk/fb-contrib/etc/samples.fbp trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/pom.xml trunk/fb-contrib/samples.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectMethodsReturningImmutableCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/MethodInfo.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/Statistics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AbnormalFinallyBlockReturn.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ArrayWrappedCallByReference.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CharsetIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CommonsHashcodeBuilderToHashcode.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousListCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DubiousMapCollection.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ExceptionSoftening.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/HangingExecutors.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InefficientStringBuffering.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JAXRSIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/JPAIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ManualArrayCopy.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MissingMethodsDetector.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MoreDumbMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OrphanedDOMNode.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverzealousCasting.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ParallelLists.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PartiallyConstructedObjectAccess.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleUnsuspectedSerialization.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionOnObjectMethods.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SpoiledChildInterfaceImplementor.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StackedTryBlocks.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StaticArrayCreatedInMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StaticMethodInstanceInvocation.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuboptimalExpressionOrder.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousClusteredSessionSupport.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousNullGuard.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnboundMethodTemplateParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedCollectionContents.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseAddAll.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseCharacterParameterizedMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseSplit.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseToArray.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseTryWithResources.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/WiringIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/RegisterUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/XClassUtils.java trunk/fb-contrib/src/samples/java/ex/COM_Sample.java trunk/fb-contrib/src/samples/java/ex/HES_Sample.java trunk/fb-contrib/src/samples/java/ex/LO_Sample.java trunk/fb-contrib/src/samples/java/ex/MRC_Sample.java trunk/fb-contrib/src/samples/java/ex/PSC_Sample.java trunk/fb-contrib/src/samples/java/ex/SEO_Sample.java trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java trunk/fb-contrib/src/samples/java/ex/WI_Sample.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectNullableMethodStatus.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/AnnotationIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/MapUsageIssues.java trunk/fb-contrib/src/samples/java/ex/AI_Sample.java trunk/fb-contrib/src/samples/java/ex/MUP_Sample.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/.classpath 2017-12-26 23:49:41 UTC (rev 1829) @@ -45,5 +45,6 @@ <classpathentry kind="lib" path="lib/javax.ws.rs-api-2.0.1.jar"/> <classpathentry kind="lib" path="lib/mockito-core-2.8.47.jar" sourcepath="/home/dave/.m2/repository/org/mockito/mockito-core/2.8.47/mockito-core-2.8.47-sources.jar"/> <classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/> + <classpathentry kind="lib" path="lib/log4j-api-2.9.1.jar"/> <classpathentry kind="output" path="target/classes/main"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/build.xml 2017-12-26 23:49:41 UTC (rev 1829) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.0.5" /> + <property name="fb-contrib.version" value="7.1.0-SNAPSHOT" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -42,7 +42,7 @@ <target name="infra_jars" description="pull jars needed to build fb-contrib to ${user.dir}/.ant/lib"> <mkdir dir="${user.home}/.ant/lib" /> - <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/1.8.0/yank-1.8.0.jar" dest="${user.home}/.ant/lib"/> + <get src="http://repo1.maven.org/maven2/com/mebigfatguy/yank/yank/2.0.0/yank-2.0.0.jar" dest="${user.home}/.ant/lib"/> <get src="https://bitbucket.org/kjlubick/bugrankcheckstyle/downloads/bug-rank-check-style-1.0.0.jar" dest="${user.home}/.ant/lib"/> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/vcsversion/vcsversion/0.4.0/vcsversion-0.4.0.jar" dest="${user.home}/.ant/lib"/> <get src="http://repo1.maven.org/maven2/com/mebigfatguy/fb-delta/fb-delta/0.6.0/fb-delta-0.6.0.jar" dest="${user.home}/.ant/lib" ignoreerrors="true"/> @@ -103,6 +103,7 @@ <pathelement location="${lib.dir}/bcel-findbugs-${bcel-findbugs.version}.jar" /> <pathelement location="${lib.dir}/findbugs-annotations-${findbugs-annotations.version}.jar" /> <pathelement location="${lib.dir}/asm-debug-all-${asm-debug-all.version}.jar" /> + <pathelement location="${lib.dir}/jsr305-${jsr305.version}.jar" /> <pathelement location="${main.classes.dir}" /> </path> <path id="fb-contrib.test.classpath"> @@ -118,9 +119,11 @@ <pathelement location="${lib.dir}/asm-debug-all-${asm-debug-all.version}.jar" /> <pathelement location="${lib.dir}/javax.servlet.jsp-api-${javax.servlet.jsp-api.version}.jar" /> <pathelement location="${lib.dir}/junit-${junit.version}.jar" /> + <pathelement location="${lib.dir}/jsr305-${jsr305.version}.jar" /> <pathelement location="${lib.dir}/testng-${testng.version}.jar" /> <pathelement location="${lib.dir}/javax.servlet-api-${javax.servlet-api.version}.jar" /> <pathelement location="${lib.dir}/log4j-${log4j.version}.jar" /> + <pathelement location="${lib.dir}/log4j-api-${log4j-api.version}.jar" /> <pathelement location="${lib.dir}/commons-lang3-${commons-lang3.version}.jar" /> <pathelement location="${lib.dir}/commons-io-${commons-io.version}.jar" /> <pathelement location="${lib.dir}/backport-util-concurrent-${backport-util-concurrent.version}.jar" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/etc/bugrank.txt 2017-12-26 23:49:41 UTC (rev 1829) @@ -3,6 +3,7 @@ +0 BugPattern AFBR_ABNORMAL_FINALLY_BLOCK_RETURN +0 BugPattern AIOB_ARRAY_INDEX_OUT_OF_BOUNDS +0 BugPattern AIOB_ARRAY_STORE_TO_NULL_REFERENCE ++1 BugPattern AI_ANNOTATION_ISSUES_NEEDS_NULLABLE +0 BugPattern AOM_ABSTRACT_OVERRIDDEN_METHOD +0 BugPattern AWCBR_ARRAY_WRAPPED_CALL_BY_REFERENCE +0 BugPattern BAS_BLOATED_ASSIGNMENT_SCOPE @@ -104,6 +105,7 @@ +0 BugPattern LO_INVALID_FORMATTING_ANCHOR +0 BugPattern LO_INVALID_STRING_FORMAT_NOTATION +0 BugPattern LO_LOGGER_LOST_EXCEPTION_STACK_TRACE ++0 BugPattern LO_NON_PRIVATE_STATIC_LOGGER +0 BugPattern LO_STUTTERED_MESSAGE +0 BugPattern LO_SUSPECT_LOG_CLASS +0 BugPattern LO_SUSPECT_LOG_PARAMETER @@ -129,6 +131,7 @@ +2 BugPattern MOM_MISLEADING_OVERLOAD_MODEL +0 BugPattern MRC_METHOD_RETURNS_CONSTANT +0 BugPattern MUC_MODIFYING_UNMODIFIABLE_COLLECTION ++0 BugPattern MUP_CONTAINSKEY_BEFORE_GET +0 BugPattern NAB_NEEDLESS_AUTOBOXING_CTOR +0 BugPattern NAB_NEEDLESS_AUTOBOXING_VALUEOF +0 BugPattern NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION @@ -282,5 +285,6 @@ +0 BugPattern WEM_OBSCURING_EXCEPTION +0 BugPattern WEM_WEAK_EXCEPTION_MESSAGING +0 BugPattern WI_DUPLICATE_WIRED_TYPES ++0 BugPattern WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN +0 BugPattern WOC_WRITE_ONLY_COLLECTION_FIELD +0 BugPattern WOC_WRITE_ONLY_COLLECTION_LOCAL Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/etc/findbugs.xml 2017-12-26 23:49:41 UTC (rev 1829) @@ -15,12 +15,15 @@ <Earlier class="com.mebigfatguy.fbcontrib.collect.CollectMethodsReturningImmutableCollections" /> <LaterCategory name="reporting" spanplugins="true" /> </SplitPass> - + <SplitPass> + <Earlier class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus" /> + <LaterCategory name="reporting" spanplugins="true" /> + </SplitPass> </OrderingConstraints> <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -30,7 +33,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + <!-- COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -176,7 +179,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS,LO_EXCEPTION_WITH_LOGGER_PARMS,LO_APPENDED_STRING_IN_FORMAT_STRING,LO_INVALID_STRING_FORMAT_NOTATION,LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING,LO_TOSTRING_PARAMETER" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS,LO_EXCEPTION_WITH_LOGGER_PARMS,LO_APPENDED_STRING_IN_FORMAT_STRING,LO_INVALID_STRING_FORMAT_NOTATION,LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING,LO_TOSTRING_PARAMETER,LO_NON_PRIVATE_STATIC_LOGGER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse" speed="fast" reports="IICU_INCORRECT_INTERNAL_CLASS_USE" /> @@ -281,7 +284,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.ConflatingResourcesAndFiles" speed="fast" reports="CRF_CONFLATING_RESOURCES_AND_FILES" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="moderate" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes" speed="fast" reports="STT_STRING_PARSING_A_FIELD,STT_TOSTRING_STORED_IN_FIELD,STT_TOSTRING_MAP_KEYING" /> @@ -301,7 +304,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BuryingLogic" speed="fast" reports="BL_BURYING_LOGIC"/> - <Detector class="com.mebigfatguy.fbcontrib.detect.WiringIssues" speed="fast" reports="WI_DUPLICATE_WIRED_TYPES"/> + <Detector class="com.mebigfatguy.fbcontrib.detect.WiringIssues" speed="fast" reports="WI_DUPLICATE_WIRED_TYPES,WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN"/> <Detector class="com.mebigfatguy.fbcontrib.detect.ConcurrentCollectionIssues" speed="fast" reports="CCI_CONCURRENT_COLLECTION_ISSUES_USE_PUT_IS_RACY"/> @@ -313,14 +316,21 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion" speed="fast" reports="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT,UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"/> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources" speed="fast" reports="UTWR_USE_TRY_WITH_RESOURCES"/> <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionIssues" speed="fast" reports="RFI_SET_ACCESSIBLE"/> - COMMENT OUT FOR POINT RELEASE --> + <Detector class="com.mebigfatguy.fbcontrib.detect.AnnotationIssues" speed="fast" reports="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE"/> + <Detector class="com.mebigfatguy.fbcontrib.detect.MapUsageIssues" speed="fast" reports="MUP_CONTAINSKEY_BEFORE_GET"/> + + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus" speed="fast" reports="" hidden="true" /> + + + <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -484,6 +494,7 @@ <BugPattern abbrev="LO" type="LO_INVALID_STRING_FORMAT_NOTATION" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING" category="CORRECTNESS"/> <BugPattern abbrev="LO" type="LO_TOSTRING_PARAMETER" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_NON_PRIVATE_STATIC_LOGGER" category="CORRECTNESS" /> <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" /> @@ -594,6 +605,7 @@ <BugPattern abbrev="DMC" type="DMC_DUBIOUS_MAP_COLLECTION" category="CORRECTNESS"/> <BugPattern abbrev="BL" type="BL_BURYING_LOGIC" category="STYLE"/> <BugPattern abbrev="WI" type="WI_DUPLICATE_WIRED_TYPES" category="CORRECTNESS"/> + <BugPattern abbrev="WI" type="WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN" category="CORRECTNESS"/> <BugPattern abbrev="CCI" type="CCI_CONCURRENT_COLLECTION_ISSUES_USE_PUT_IS_RACY" category="CORRECTNESS"/> <BugPattern abbrev="UTWR" type="UTWR_USE_TRY_WITH_RESOURCES" category="STYLE" experimental="true"/> <BugPattern abbrev="SSCU" type="SSCU_SUSPICIOUS_SHADED_CLASS_USE" category="CORRECTNESS"/> @@ -606,4 +618,6 @@ <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT" category="CORRECTNESS"/> <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" category="CORRECTNESS"/> <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="AI" type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="MUP" type="MUP_CONTAINSKEY_BEFORE_GET" category="STYLE" experimental="true" /> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/etc/messages.xml 2017-12-26 23:49:41 UTC (rev 1829) @@ -30,6 +30,14 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.collect.CollectNullableMethodStatus"> + <Details> + <![CDATA[ + <p>Collects method calls that can return null</p> + ]]> + </Details> + </Detector> <Detector class="com.mebigfatguy.fbcontrib.detect.InefficientStringBuffering"> <Details> @@ -909,7 +917,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities"> <Details> <![CDATA[ - <p>Looks for odd patterns of use of Logger classes from either log4j, SLF4J or Commons Logging.</p> + <p>Looks for odd patterns of use of Logger classes from either Log4j, Log4j2, SLF4J or Commons Logging.</p> <p>It is a fast detector.</p> ]]> </Details> @@ -1705,7 +1713,25 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.AnnotationIssues"> + <Details> + <![CDATA[ + <p>Looks for issues around use of standard anntations</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.MapUsageIssues"> + <Details> + <![CDATA[ + <p>Looks for dubious usage patterns around the Map interface</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> </Detector> @@ -4030,8 +4056,8 @@ <LongDescription>Method {1} attempts to log using numbered formatting anchors</LongDescription> <Details> <![CDATA[ - <p>This method attempts to use an SLF4J logger to log a parameterized expression using formatting anchors. - However, SLF4J uses simple non numbered anchors such as {}, rather than anchors with digits in them as the + <p>This method attempts to use an SLF4J or Log4j2 logger to log a parameterized expression using formatting anchors. + However, SLF4J and Log4j2 use simple non numbered anchors such as {}, rather than anchors with digits in them as the code uses. Thus no parameter replacement will occur.</p> <p>This pattern is invalid: <code>LOGGER.error("{0} is broken", theThing);</code> @@ -4047,8 +4073,8 @@ <LongDescription>Method {1} attempts to log using String.format notation</LongDescription> <Details> <![CDATA[ - <p>This method attempts to use an SLF4J logger to log a parameterized expression using String.format notation. - However, SLF4J uses simple non numbered anchors such as {}, rather than anchors with percent signs in them as the + <p>This method attempts to use an SLF4J or Log4j2 logger to log a parameterized expression using String.format notation. + However, SLF4J and Log4j2 uses simple non numbered anchors such as {}, rather than anchors with percent signs in them as the code uses. Thus no parameter replacement will occur.</p> <p>This pattern is invalid: <code>LOGGER.error("%s is broken", theThing);</code> @@ -4060,11 +4086,11 @@ </BugPattern> <BugPattern type="LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS"> - <ShortDescription>Method passes an incorrect number of parameters to an SLF4J logging statement</ShortDescription> - <LongDescription>Method {1} passes an incorrect number of parameters to an SLF4J logging statement</LongDescription> + <ShortDescription>Method passes an incorrect number of parameters to an SLF4J or Log4j2 logging statement</ShortDescription> + <LongDescription>Method {1} passes an incorrect number of parameters to an SLF4J or Log4j2 logging statement</LongDescription> <Details> <![CDATA[ - <p>This method passes the wrong number of parameters to an SLF4J logging method (error, warn, info, debug) based on the number of anchors {} in the + <p>This method passes the wrong number of parameters to an SLF4J or Log4j2 logging method (error, warn, info, debug) based on the number of anchors {} in the format string. An additional exception argument is allowed if found.</p> ]]> </Details> @@ -4076,7 +4102,7 @@ <Details> <![CDATA[ <p>This method passes a standard exception as a logger parameter, and expects this exception to be substituted in - an SLF4J style parameter marker '{}'. This marker will not be translated as SLF4J doesn't process the Exception + an SLF4J or Log4j style parameter marker '{}'. This marker will not be translated as SLF4J or Log4j2 doesn't process the Exception class for markers. </p> ]]> @@ -4084,11 +4110,11 @@ </BugPattern> <BugPattern type="LO_APPENDED_STRING_IN_FORMAT_STRING"> - <ShortDescription>Method passes a concatenated string to SLF4J's format string</ShortDescription> - <LongDescription>Method {1} passes a concatenated string to SLF4J's format string</LongDescription> + <ShortDescription>Method passes a concatenated string to SLF4J's or Log4j2's format string</ShortDescription> + <LongDescription>Method {1} passes a concatenated string to SLF4J's or Log4j2's format string</LongDescription> <Details> <![CDATA[ - <p>This method uses an SLF4J logger to log a string, where the first (format) string is created using concatenation. + <p>This method uses an SLF4J or Log4j2 logger to log a string, where the first (format) string is created using concatenation. You should use {} markers to inject dynamic content into the string, so that String building is delayed until the actual log string is needed. If the log level is high enough that this log statement isn't used, then the appends will never be executed.</p> @@ -4098,13 +4124,13 @@ <BugPattern type="LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING"> - <ShortDescription>Method passes a simple String.format result to an SLF4J's format string</ShortDescription> - <LongDescription>Method {1} passes a simple String.format result to an SLF4J's format string</LongDescription> + <ShortDescription>Method passes a simple String.format result to an SLF4J's or Log4j2's format string</ShortDescription> + <LongDescription>Method {1} passes a simple String.format result to an SLF4J's or Log4j2's format string</LongDescription> <Details> <![CDATA[ - <p>This method uses an SLF4J logger to log a string, which was produced through a call to String.format, where + <p>This method uses an SLF4J or Log4j2 logger to log a string, which was produced through a call to String.format, where the format string passed was a constant string containing only simple format markers that could be directly handled - by slf4j. Rather than doing + by slf4j or Log4j. Rather than doing <pre> logger.error("String.format("This %s is an error", s)); <pre> @@ -4132,6 +4158,31 @@ </Details> </BugPattern> + <BugPattern type="LO_NON_PRIVATE_STATIC_LOGGER"> + <ShortDescription>Class defines non private logger using a static class context</ShortDescription> + <LongDescription>Class {0} defines a non private logger using a static class context</LongDescription> + <Details> + <![CDATA[ + <p>This class defines a static logger as non private. It does so by passing the name of a + class such as + <code><pre>public static final Logger LOG = LoggerFactory.getLogger(Foo.class);</pre></code> + Since this class is public it may be used in other classes, but doing so, will provide the incorrect + class reference as the class is hard coded. + </p> + <p> + It is recommend to define static loggers as private, and just redefine a new logger in any class + that you need to have logging done. + <p> + <p>If you wish to have a base class define the logger, and have derived classes use that logger, you can + potentially use instance based logging, such as + <code><pre>protected final Logger LOG = LoggerFactory.getLogger(getClass());</pre></code> + However this has the downside of being an instance based logger, and creating a logger object in each instance + of the class where it is used. + </p> + ]]> + </Details> + </BugPattern> + <BugPattern type="IICU_INCORRECT_INTERNAL_CLASS_USE"> <ShortDescription>Class relies on internal API classes</ShortDescription> <LongDescription>Class {0} relies on internal API classes</LongDescription> @@ -5778,6 +5829,19 @@ </Details> </BugPattern> + <BugPattern type="WI_MANUALLY_ALLOCATING_AN_AUTOWIRED_BEAN"> + <ShortDescription>Method allocates an object with new when the class is defined as an autowireable bean</ShortDescription> + <LongDescription>Method {1} allocates an object with new when the class is defined as an autowireable bean</LongDescription> + <Details> + <![CDATA[ + <p>this method allocates an object with new, but the class of the object that is being created is marked with a Spring annotation + denoting that this class is to be used through an @Autowire annotation. Allocating it with new, will likely mean that fields on the + class will not be autowired, but instead be null. You should just autowire an instance of this class into the class in question, or if + need be, use spring's getBean(name) method to fetch one.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="CCI_CONCURRENT_COLLECTION_ISSUES_USE_PUT_IS_RACY"> <ShortDescription>Method gets and sets a value of a ConcurrentHashMap in a racy manner</ShortDescription> <LongDescription>Method {1} gets and sets a value of a ConcurrentHashMap in a racy manner </LongDescription> @@ -5945,6 +6009,89 @@ ]]> </Details> </BugPattern> + + <BugPattern type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE"> + <ShortDescription>Method that can return null, is missing a @Nullable annotation</ShortDescription> + <LongDescription>Method {1} that can return null, is missing a @Nullable annotation</LongDescription> + <Details> + <![CDATA[ + <p>This method can return null, but is not annotated with an @Nullable annotation. Without this annotation, + various IDEs, and static analysis tools may not be able to fully discover possible NullPointerExceptions in + your code. By Adding these annotations, you will discover problems around null-ness, more easily.</p> + <p>Unfortunately there isn't just one @Nullable annotation, but this detector will recognize:</p> + <ul> + <li>org.jetbrains.annotations.Nullable</li> + <li>javax.annotation.Nullable</li> + <li>javax.annotation.CheckForNull</li> + <li>edu.umd.cs.findbugs.annotations.Nullable</li> + <li>org.springframework.lang.Nullable</li> + <li>android.support.annotations.Nullable</li> + </ul> + <p> + You can supply a comma separated list of classes that are custom Nullable Annotations if you desire, by using the + system property -Dfb-contrib.ai.annotations="com.acme.Foo,com.acme.Boo" when run. + ]]> + </Details> + </BugPattern> + + <BugPattern type="MUP_CONTAINSKEY_BEFORE_GET"> + <ShortDescription>Method check a map with containsKey(), before using get()</ShortDescription> + <LongDescription>Method {1} checks a map with containsKey(), before using get()</LongDescription> + <Details> + <![CDATA[ + <p>This method checks for the presense of a key in a map using containsKey(), before attempting to fetch the value of the key + using get(). This equates to doing two map lookups in a row. It is much simpler to just fetch the value with get, and checking + for non null instead.</p> + <p>As an example, instead of using + <code> + <pre> + Map<String, String> myMap = getSomeMap(); + if (myMap.containsKey("foo")) { + String value = myMap.get("foo"); + .... + } + </pre> + </code> + convert this to + <code> + <pre> + Map<String, String> myMap = getSomeMap(); + String value = myMap.get("foo"); + if (value != null) { + .... + } + </pre> + </code> + </p> + <p>The only caveat to this is that if you use a null value in a map to represent a third state for the key, then in this case + using containsKey is 'correct'. This means if an entry found in the map with a null value is taken differently then no entry + at all. However this is a very subtle programming paradigm, and likely to cause problems. If you wish to mark an entry as + not being present, it is better to use a named 'sentinel' value to denote this, so instead of: + <code> + <pre> + Map<String, String> myMap = getSomeMap(); + if (myMap.containsKey("foo")) { + String value = myMap.get("foo"); + .... + } + </pre> + </code> + convert this to + <code> + <pre> + Map<String, String> myMap = getSomeMap(); + String value = myMap.get("foo"); + if (NOT_FOUND.equals(value)) { + .... + } + where NOT_FOUND is some constant that denotes this special status. Of course you will need to find a special + sentinel value for each type you are using that isn't possible to have normally. + </p> + </pre> + </code> + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -6089,4 +6236,6 @@ <BugCode abbrev="OI">Optional Issues</BugCode> <BugCode abbrev="UAC">Unnecessary Api Conversion</BugCode> <BugCode abbrev="RFI">Reflection Issues</BugCode> + <BugCode abbrev="AI">Annotation Issues</BugCode> + <BugCode abbrev="MUP">Map Usage Issues</BugCode> </MessageCollection> Modified: trunk/fb-contrib/etc/samples.fbp =================================================================== --- trunk/fb-contrib/etc/samples.fbp 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/etc/samples.fbp 2017-12-26 23:49:41 UTC (rev 1829) @@ -1,30 +1,31 @@ <Project projectName="sample"> - <Jar>../target/classes/samples</Jar> - <AuxClasspathEntry>../lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-codec-1.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-collections-3.2.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-lang3-3.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/guava-19.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/httpclient-4.5.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/httpclient-cache-4.5.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/httpcore-4.4.5.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/junit-4.12.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/log4j-1.2.17.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/slf4j-api-1.7.21.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/spring-beans-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/spring-context-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/spring-tx-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/threetenbp-1.3.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/jena-shaded-guava-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/commons-io-2.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/testng-6.9.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/mockito-core-2.8.47.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/hamcrest-core-1.3.jar</AuxClasspathEntry> - <SrcDir>../src/samples/java</SrcDir> + <Jar>./../target/classes/samples</Jar> + <AuxClasspathEntry>./../lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/commons-codec-1.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/commons-collections-3.2.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/commons-lang3-3.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/guava-19.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/httpclient-4.5.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/httpclient-cache-4.5.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/httpcore-4.4.5.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/junit-4.12.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/slf4j-api-1.7.21.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/spring-beans-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/spring-context-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/spring-tx-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/threetenbp-1.3.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/jena-shaded-guava-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/commons-io-2.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/testng-6.9.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/mockito-core-2.8.47.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/hamcrest-core-1.3.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/log4j-api-2.9.1.jar</AuxClasspathEntry> + <SrcDir>./../src/samples/java</SrcDir> </Project> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/htdocs/index.shtml 2017-12-26 23:49:41 UTC (rev 1829) @@ -77,19 +77,28 @@ </div> <hr/> - <img id="git_image" src="flip1.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> + <img id="git_image" src="flip2.gif" onClick="toggleBlock('git', 'git_image');" align="top"/> Detectors added in git<br/> - <div id="git" style="display:none;"> + <div id="git" style="display:block;"> <ul> <li><b>[UTWR] Use Try With Resources</b><br/> Looks for try/finally blocks that manage resources, without using try-with-resources. </li> + <li><b>[RFI} Reflection Issues</b><br/> + Looks for issues around reflection, especially in light of java 9 and 10. + </li> + <li><b>[AI] Annotation Issues</b><br/> + Looks for issues around use of common annotations + </li> + <li><b>[MUP] Map Usage Issues</b><br/> + Looks for odd usage patterns when using Maps + </li> </ul> </div> <hr/> - <img id="v7_0_0_image" src="flip2.gif" onClick="toggleBlock('v7_0_0', 'v7_0_0_image');" align="top"/> + <img id="v7_0_0_image" src="flip1.gif" onClick="toggleBlock('v7_0_0', 'v7_0_0_image');" align="top"/> Detectors added in v7.0.0<br/> - <div id="v7_0_0" style="display:block;"> + <div id="v7_0_0" style="display:none;"> <ul> <li><b>[SSCU] Suspicious Shaded Class Use</b><br/> Looks for use of classes that have been shaded into 3rdparty jars, rather than using the Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/pom.xml 2017-12-26 23:49:41 UTC (rev 1829) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.0.5</version> + <version>7.1.0-SNAPSHOT</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> @@ -303,6 +303,12 @@ <version>1.3</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.9.1</version> + <scope>test</scope> + </dependency> </dependencies> <build> Modified: trunk/fb-contrib/samples.xml =================================================================== --- trunk/fb-contrib/samples.xml 2017-09-24 01:18:06 UTC (rev 1828) +++ trunk/fb-contrib/samples.xml 2017-12-26 23:49:41 UTC (rev 1829) @@ -1,14 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> -<BugCollection version="3.0.1" sequence="0" timestamp="1491777371371" analysisTimestamp="1491777371509" release=""> +<BugCollection version="3.0.1" sequence="0" timestamp="1513438250950" analysisTimestamp="1513438251053" release=""> <Project projectName="Samples"> <Jar>/home/dave/dev/fb-contrib/target/classes/samples</Jar> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/junit-4.12.jar</AuxClasspathEntry> + <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/jsr305-3.0.2.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/testng-6.9.10.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/log4j-api-2.9.1.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/commons-lang3-3.4.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/commons-io-2.4.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> @@ -23,7 +25,8 @@ <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/spring-context-4.3.3.RELEASE.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/spring-tx-4.3.3.RELEASE.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/mockito-all-2.0.2-beta.jar</AuxClasspathEntry> + <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/mockito-core-2.8.47.jar</AuxClasspathEntry> + <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/hamcrest-core-1.3.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/jena-shaded-guava-3.1.0.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry> <AuxClasspathEntry>/home/dave/dev/fb-contrib/lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry> @@ -160,6 +163,23 @@ <Message>At ACEM_Sample.java:[line 8]</Message> </SourceLine> </BugInstance> + <BugInstance type="IOI_USE_OF_FILE_STREAM_CONSTRUCTORS" priority="2" rank="18" abbrev="IOI" category="PERFORMANCE" instanceHash="3974c72a8ede5202c739fa557f4d32d6" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method uses a FileInputStream or FileOutputStream constructor</ShortMessage> + <LongMessage>Method ex.AFBR_Sample.test5() uses a FileInputStream or FileOutputStream constructor</LongMessage> + <Class classname="ex.AFBR_Sample" primary="true"> + <SourceLine classname="ex.AFBR_Sample" start="7" end="56" sourcefile="AFBR_Sample.java" sourcepath="ex/AFBR_Sample.java"> + <Message>At AFBR_Sample.java:[lines 7-56]</Message> + </SourceLine> + <Message>In class ex.AFBR_Sample</Message> + </Class> + <Method classname="ex.AFBR_Sample" name="test5" signature="()I" isStatic="false" primary="true"> + <SourceLine classname="ex.AFBR_Sample" start="46" end="56" startBytecode="0" endBytecode="244" sourcefile="AFBR_Sample.java" sourcepath="ex/AFBR_Sample.java"/> + <Message>In method ex.AFBR_Sample.test5()</Message> + </Method> + <SourceLine classname="ex.AFBR_Sample" primary="true" start="48" end="48" startBytecode="8" endBytecode="8" sourcefile="AFBR_Sample.java" sourcepath="ex/AFBR_Sample.java"> + <Message>At AFBR_Sample.java:[line 48]</Message> + </SourceLine> + </BugInstance> <BugInstance type="UTWR_USE_TRY_WITH_RESOURCES" priority="2" rank="17" abbrev="UTWR" category="STYLE" instanceHash="ec7e6902ec57bf55eb9d354038d69126" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> <ShortMessage>Method manually handles closing an auto-closeable resource</ShortMessage> <LongMessage>Method ex.AFBR_Sample.test5() manually handles closing an auto-closeable resource</LongMessage> @@ -503,6 +523,94 @@ <Message>At AIOB_Sample.java:[line 28]</Message> </SourceLine> </BugInstance> + <BugInstance type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" priority="3" rank="11" abbrev="AI" category="CORRECTNESS" instanceHash="8997fff7d130e44fa3336877e73ec213" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method that can return null, is missing a @Nullable annotation</ShortMessage> + <LongMessage>Method ex.AI_Sample.fpAnon() that can return null, is missing a @Nullable annotation</LongMessage> + <Class classname="ex.AI_Sample" primary="true"> + <SourceLine classname="ex.AI_Sample" start="7" end="47" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"> + <Message>At AI_Sample.java:[lines 7-47]</Message> + </SourceLine> + <Message>In class ex.AI_Sample</Message> + </Class> + <Method classname="ex.AI_Sample" name="fpAnon" signature="()Ljava/lang/String;" isStatic="false" primary="true"> + <SourceLine classname="ex.AI_Sample" start="42" end="42" startBytecode="0" endBytecode="61" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"/> + <Message>In method ex.AI_Sample.fpAnon()</Message> + </Method> + <SourceLine classname="ex.AI_Sample" start="42" end="42" startBytecode="0" endBytecode="61" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java" synthetic="true"> + <Message>At AI_Sample.java:[line 42]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" priority="3" rank="11" abbrev="AI" category="CORRECTNESS" instanceHash="5137a654788eabfd87288e02e5d97d22" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method that can return null, is missing a @Nullable annotation</ShortMessage> + <LongMessage>Method ex.AI_Sample.getFoo2() that can return null, is missing a @Nullable annotation</LongMessage> + <Class classname="ex.AI_Sample" primary="true"> + <SourceLine classname="ex.AI_Sample" start="7" end="47" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"> + <Message>At AI_Sample.java:[lines 7-47]</Message> + </SourceLine> + <Message>In class ex.AI_Sample</Message> + </Class> + <Method classname="ex.AI_Sample" name="getFoo2" signature="()Ljava/lang/String;" isStatic="false" primary="true"> + <SourceLine classname="ex.AI_Sample" start="15" end="15" startBytecode="0" endBytecode="46" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"/> + <Message>In method ex.AI_Sample.getFoo2()</Message> + </Method> + <SourceLine classname="ex.AI_Sample" start="15" end="15" startBytecode="0" endBytecode="46" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java" synthetic="true"> + <Message>At AI_Sample.java:[line 15]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" priority="3" rank="11" abbrev="AI" category="CORRECTNESS" instanceHash="a2329dbcb997792e9c8452d56dd06c8f" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method that can return null, is missing a @Nullable annotation</ShortMessage> + <LongMessage>Method ex.AI_Sample.nullBecauseOfConditional() that can return null, is missing a @Nullable annotation</LongMessage> + <Class classname="ex.AI_Sample" primary="true"> + <SourceLine classname="ex.AI_Sample" start="7" end="47" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"> + <Message>At AI_Sample.java:[lines 7-47]</Message> + </SourceLine> + <Message>In class ex.AI_Sample</Message> + </Class> + <Method classname="ex.AI_Sample" name="nullBecauseOfConditional" signature="()Ljava/lang/String;" isStatic="false" primary="true"> + <SourceLine classname="ex.AI_Sample" start="23" end="28" startBytecode="0" endBytecode="91" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"/> + <Message>In method ex.AI_Sample.nullBecauseOfConditional()</Message> + </Method> + <SourceLine classname="ex.AI_Sample" start="23" end="28" startBytecode="0" endBytecode="91" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java" synthetic="true"> + <Message>At AI_Sample.java:[lines 23-28]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" priority="2" rank="18" abbrev="RCN" category="STYLE" instanceHash="7be70d2b36f5fc44c80e4cfd33db7d33" instanceOccurrenceNum="0" instanceOccurrenceMax="0" cweid="476"> + <ShortMessage>Redundant nullcheck of value known to be non-null</ShortMessage> + <LongMessage>Redundant nullcheck of f, which is known to be non-null in ex.AI_Sample.nullBecauseOfConditional()</LongMessage> + <Class classname="ex.AI_Sample" primary="true"> + <SourceLine classname="ex.AI_Sample" start="7" end="47" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"> + <Message>At AI_Sample.java:[lines 7-47]</Message> + </SourceLine> + <Message>In class ex.AI_Sample</Message> + </Class> + <Method classname="ex.AI_Sample" name="nullBecauseOfConditional" signature="()Ljava/lang/String;" isStatic="false" primary="true"> + <SourceLine classname="ex.AI_Sample" start="23" end="28" startBytecode="0" endBytecode="91" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"/> + <Message>In method ex.AI_Sample.nullBecauseOfConditional()</Message> + </Method> + <LocalVariable name="f" register="1" pc="5" role="LOCAL_VARIABLE_VALUE_OF"> + <Message>Value loaded from f</Message> + </LocalVariable> + <Method classname="ex.AI_Sample" name="getFoo3" signature="()Ljava/lang/String;" isStatic="false" role="METHOD_RETURN_VALUE_OF"> + <SourceLine classname="ex.AI_Sample" start="19" end="19" startBytecode="0" endBytecode="44" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"/> + <Message>Return value of ex.AI_Sample.getFoo3() of type String</Message> + </Method> + <SourceLine classname="ex.AI_Sample" primary="true" start="24" end="24" startBytecode="6" endBytecode="6" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java" role="SOURCE_REDUNDANT_NULL_CHECK"> + <Message>Redundant null check at AI_Sample.java:[line 24]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="SIC_INNER_SHOULD_BE_STATIC_ANON" priority="3" rank="20" abbrev="SIC" category="PERFORMANCE" instanceHash="ff70b4f8148a02742ee4b8cde54a4050" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Could be refactored into a named static inner class</ShortMessage> + <LongMessage>The class ex.AI_Sample$1 could be refactored into a named _static_ inner class</LongMessage> + <Class classname="ex.AI_Sample$1" primary="true"> + <SourceLine classname="ex.AI_Sample$1" start="1" end="45" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java"> + <Message>At AI_Sample.java:[lines 1-45]</Message> + </SourceLine> + <Message>In class ex.AI_Sample$1</Message> + </Class> + <SourceLine classname="ex.AI_Sample$1" start="1" end="45" sourcefile="AI_Sample.java" sourcepath="ex/AI_Sample.java" synthetic="true"> + <Message>At AI_Sample.java:[lines 1-45]</Message> + </SourceLine> + </BugInstance> <BugInstance type="AOM_ABSTRACT_OVERRIDDEN_METHOD" priority="2" rank="7" abbrev="AOM" category="CORRECTNESS" instanceHash="6741663e6374c0c0b6968eeb59450e3b" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> <ShortMessage>Abstract method overrides a concrete implementation</ShortMessage> <LongMessage>Abstract method ex.AOM_Sample.test1() overrides a concrete implementation</LongMessage> @@ -642,6 +750,93 @@ <Message>At AWCBR_Sample.java:[lines 8-9]</Message> </SourceLine> </BugInstance> + <BugInstance type="FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY" priority="2" rank="9" abbrev="FCCD" category="CORRECTNESS" instanceHash="4897e60fb3065f5dbd581a772aa46136" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Class has a circular dependency with other classes</ShortMessage> + <LongMessage>Class ex.Annot has a circular dependency with other classes</LongMessage> + <Class classname="ex.Annot" primary="true"> + <SourceLine classname="ex.Annot" start="119" end="119" sourcefile="FCCD_Sample.java" sourcepath="ex/FCCD_Sample.java"> + <Message>At FCCD_Sample.java:[line 119]</Message> + </SourceLine> + <Message>In class ex.Annot</Message> + </Class> + <Class classname="ex.ChildAnnot"> + <SourceLine classname="ex.ChildAnnot" start="122" end="122" sourcefile="FCCD_Sample.java" sourcepath="ex/FCCD_Sample.java"> + <Message>At FCCD_Sample.java:[line 122]</Message> + </SourceLine> + <Message>In class ex.ChildAnnot</Message> + </Class> + <SourceLine classname="ex.Annot" start="119" end="119" sourcefile="FCCD_Sample.java" sourcepath="ex/FCCD_Sample.java" synthetic="true"> + <Message>At FCCD_Sample.java:[line 119]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" priority="3" rank="11" abbrev="AI" category="CORRECTNESS" instanceHash="fa23afba710182705db6423aea37dd8a" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method that can return null, is missing a @Nullable annotation</ShortMessage> + <LongMessage>Method ex.BAS_Sample.getList() that can return null, is missing a @Nullable annotation</LongMessage> + <Class classname="ex.BAS_Sample" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="15" end="248" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"> + <Message>At BAS_Sample.java:[lines 15-248]</Message> + </SourceLine> + <Message>In class ex.BAS_Sample</Message> + </Class> + <Method classname="ex.BAS_Sample" name="getList" signature="()Ljava/util/List;" isStatic="false" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="70" end="70" startBytecode="0" endBytecode="43" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"/> + <Message>In method ex.BAS_Sample.getList()</Message> + </Method> + <SourceLine classname="ex.BAS_Sample" start="70" end="70" startBytecode="0" endBytecode="43" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java" synthetic="true"> + <Message>At BAS_Sample.java:[line 70]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" priority="3" rank="11" abbrev="AI" category="CORRECTNESS" instanceHash="92e57e61cc45518deac85e60646b751a" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method that can return null, is missing a @Nullable annotation</ShortMessage> + <LongMessage>Method ex.BAS_Sample.testFPRefNull(boolean) that can return null, is missing a @Nullable annotation</LongMessage> + <Class classname="ex.BAS_Sample" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="15" end="248" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"> + <Message>At BAS_Sample.java:[lines 15-248]</Message> + </SourceLine> + <Message>In class ex.BAS_Sample</Message> + </Class> + <Method classname="ex.BAS_Sample" name="testFPRefNull" signature="(Z)Ljava/lang/Long;" isStatic="false" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="154" end="161" startBytecode="0" endBytecode="109" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"/> + <Message>In method ex.BAS_Sample.testFPRefNull(boolean)</Message> + </Method> + <SourceLine classname="ex.BAS_Sample" start="154" end="161" startBytecode="0" endBytecode="109" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java" synthetic="true"> + <Message>At BAS_Sample.java:[lines 154-161]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" priority="3" rank="11" abbrev="AI" category="CORRECTNESS" instanceHash="1e3e5af97f920b2e8dd86b8b9786b026" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method that can return null, is missing a @Nullable annotation</ShortMessage> + <LongMessage>Method ex.BAS_Sample.testFPSynchronized(String, String) that can return null, is missing a @Nullable annotation</LongMessage> + <Class classname="ex.BAS_Sample" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="15" end="248" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"> + <Message>At BAS_Sample.java:[lines 15-248]</Message> + </SourceLine> + <Message>In class ex.BAS_Sample</Message> + </Class> + <Method classname="ex.BAS_Sample" name="testFPSynchronized" signature="(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;" isStatic="false" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="198" end="207" startBytecode="0" endBytecode="223" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"/> + <Message>In method ex.BAS_Sample.testFPSynchronized(String, String)</Message> + </Method> + <SourceLine classname="ex.BAS_Sample" start="198" end="207" startBytecode="0" endBytecode="223" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java" synthetic="true"> + <Message>At BAS_Sample.java:[lines 198-207]</Message> + </SourceLine> + </BugInstance> + <BugInstance type="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE" priority="3" rank="11" abbrev="AI" category="CORRECTNESS" instanceHash="244bf80ed6ef603c094abf2d69311ef4" instanceOccurrenceNum="0" instanceOccurrenceMax="0"> + <ShortMessage>Method that can return null, is missing a @Nullable annotation</ShortMessage> + <LongMessage>Method ex.BAS_Sample.testSwitch(int) that can return null, is missing a @Nullable annotation</LongMessage> + <Class classname="ex.BAS_Sample" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="15" end="248" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"> + <Message>At BAS_Sample.java:[lines 15-248]</Message> + </SourceLine> + <Message>In class ex.BAS_Sample</Message> + </Class> + <Method classname="ex.BAS_Sample" name="testSwitch" signature="(I)Ljava/lang/String;" isStatic="false" primary="true"> + <SourceLine classname="ex.BAS_Sample" start="74" end="94" startBytecode="0" endBytecode="170" sourcefile="BAS_Sample.java" sourcepath="ex/BAS_Sample.java"/> + <Message>In method ex.BAS_Sample.testSwitch(int)</Message> + </Method> + <SourceLine classname="ex.BAS_Sample" start="74" end="94" startBytecode="0" endBytecode="170" sou... [truncated message content] |
From: <dbr...@us...> - 2017-09-24 01:18:07
|
Revision: 1828 http://sourceforge.net/p/fb-contrib/code/1828 Author: dbrosius Date: 2017-09-24 01:18:06 +0000 (Sun, 24 Sep 2017) Log Message: ----------- Version 7.0.5 Added Paths: ----------- tags/v7_0_5/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-09-24 01:16:37
|
Revision: 1827 http://sourceforge.net/p/fb-contrib/code/1827 Author: dbrosius Date: 2017-09-24 01:16:34 +0000 (Sun, 24 Sep 2017) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/bugrank.txt trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/samples/java/ex/CNC_Sample.java trunk/fb-contrib/src/samples/java/ex/LO_Sample.java trunk/fb-contrib/src/samples/java/ex/OI_Sample.java trunk/fb-contrib/src/samples/java/ex/UCPM_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/build.xml 2017-09-24 01:16:34 UTC (rev 1827) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.0.4" /> + <property name="fb-contrib.version" value="7.0.5" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/etc/bugrank.txt 2017-09-24 01:16:34 UTC (rev 1827) @@ -107,6 +107,7 @@ +0 BugPattern LO_STUTTERED_MESSAGE +0 BugPattern LO_SUSPECT_LOG_CLASS +0 BugPattern LO_SUSPECT_LOG_PARAMETER ++0 BugPattern LO_TOSTRING_PARAMETER +2 BugPattern LSC_LITERAL_STRING_COMPARISON +0 BugPattern LSYC_LOCAL_SYNCHRONIZED_COLLECTION +2 BugPattern MAC_MANUAL_ARRAY_COPY @@ -152,6 +153,7 @@ +0 BugPattern OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED +0 BugPattern OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION +0 BugPattern OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION ++0 BugPattern OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL +0 BugPattern OPM_OVERLY_PERMISSIVE_METHOD +0 BugPattern PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP +2 BugPattern PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/etc/findbugs.xml 2017-09-24 01:16:34 UTC (rev 1827) @@ -176,7 +176,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.SuspiciousClusteredSessionSupport" speed="fast" reports="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS,LO_EXCEPTION_WITH_LOGGER_PARMS,LO_APPENDED_STRING_IN_FORMAT_STRING,LO_INVALID_STRING_FORMAT_NOTATION,LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" reports="LO_LOGGER_LOST_EXCEPTION_STACK_TRACE,LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER,LO_STUTTERED_MESSAGE,LO_INVALID_FORMATTING_ANCHOR,LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS,LO_EXCEPTION_WITH_LOGGER_PARMS,LO_APPENDED_STRING_IN_FORMAT_STRING,LO_INVALID_STRING_FORMAT_NOTATION,LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING,LO_TOSTRING_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse" speed="fast" reports="IICU_INCORRECT_INTERNAL_CLASS_USE" /> @@ -309,7 +309,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnsynchronizedSingletonFieldWrites" speed="fast" reports="USFW_UNSYNCHRONIZED_SINGLETON_FIELD_WRITES"/> - <Detector class="com.mebigfatguy.fbcontrib.detect.OptionalIssues" speed="fast" reports="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION,OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION,OI_OPTIONAL_ISSUES_CHECKING_REFERENCE,OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED"/> + <Detector class="com.mebigfatguy.fbcontrib.detect.OptionalIssues" speed="fast" reports="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION,OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION,OI_OPTIONAL_ISSUES_CHECKING_REFERENCE,OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED,OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL"/> <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion" speed="fast" reports="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT,UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"/> @@ -482,7 +482,8 @@ <BugPattern abbrev="LO" type="LO_EXCEPTION_WITH_LOGGER_PARMS" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_APPENDED_STRING_IN_FORMAT_STRING" category="PERFORMANCE" /> <BugPattern abbrev="LO" type="LO_INVALID_STRING_FORMAT_NOTATION" category="CORRECTNESS" /> - <BugPattern abbrev="LO" type="LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING" /> + <BugPattern abbrev="LO" type="LO_EMBEDDED_SIMPLE_STRING_FORMAT_IN_FORMAT_STRING" category="CORRECTNESS"/> + <BugPattern abbrev="LO" type="LO_TOSTRING_PARAMETER" category="CORRECTNESS" /> <BugPattern abbrev="IICU" type="IICU_INCORRECT_INTERNAL_CLASS_USE" category="CORRECTNESS" /> <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" /> @@ -601,6 +602,7 @@ <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION" category="CORRECTNESS"/> <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_CHECKING_REFERENCE" category="CORRECTNESS"/> <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED" category="CORRECTNESS"/> + <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL" category="CORRECTNESS" /> <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT" category="CORRECTNESS"/> <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" category="CORRECTNESS"/> <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS" experimental="true"/> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/etc/messages.xml 2017-09-24 01:16:34 UTC (rev 1827) @@ -4117,6 +4117,21 @@ </Details> </BugPattern> + <BugPattern type="LO_TOSTRING_PARAMETER"> + <ShortDescription>Method explicitly calls toString() on a logger parameter</ShortDescription> + <LongDescription>Method {1} explicitly calls toString() on a logger parameter</LongDescription> + <Details> + <![CDATA[ + <p>This method uses parameterized logging to avoid the cost of string concatenation in the case that + the log level does not meet the needed level. However, one or more of the parameters passed to the logging + method uses .toString() to present a String representation for the parameter. This is unneeded as the logger + will do this for you, and because it is explicitly done, will always be called even if the log statement is + not actually written. Also, by dropping the '.toString()' you may avoid unnecessary NPEs. + Just pass the variable as a parameter instead. + ]]> + </Details> + </BugPattern> + <BugPattern type="IICU_INCORRECT_INTERNAL_CLASS_USE"> <ShortDescription>Class relies on internal API classes</ShortDescription> <LongDescription>Class {0} relies on internal API classes</LongDescription> @@ -5880,6 +5895,18 @@ </Details> </BugPattern> + <BugPattern type="OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL"> + <ShortDescription>Method uses Optional.orElseGet(null)</ShortDescription> + <LongDescription>Method {1} uses Optional.orElseGet(null)</LongDescription> + <Details> + <![CDATA[ + <p>This method uses Optional.orElseGet(null). This method is supposed to to receive a lambda expression for what to execute + when the Optional is not there. If you want to just return null, use Optional.orElse(null) instead. + </p> + ]]> + </Details> + </BugPattern> + <BugPattern type="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT"> <ShortDescription>Method constructs a Date object, merely to convert it to an Instant object</ShortDescription> <LongDescription>Method {1} constructs a Date object, merely to convert it to an Instant object</LongDescription> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/htdocs/index.shtml 2017-09-24 01:16:34 UTC (rev 1827) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.4 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.5 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/htdocs/repository.html 2017-09-24 01:16:34 UTC (rev 1827) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.0.4 or 7.0.4.sb</td></tr> + <tr><td><b>Version:</b></td><td>7.0.5 or 7.0.5.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/pom.xml 2017-09-24 01:16:34 UTC (rev 1827) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.0.4</version> + <version>7.0.5</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CollectionNamingConfusion.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -141,8 +141,8 @@ String clsName = SignatureUtils.stripSignature(signature); JavaClass cls = Repository.lookupClass(clsName); if ((cls.implementationOf(mapInterface) && !name.endsWith("map")) || (cls.implementationOf(setInterface) && !name.endsWith("set")) - || (cls.implementationOf(listInterface) && !name.endsWith("list")) - || (cls.implementationOf(queueInterface) && !name.endsWith("queue"))) { + || ((cls.implementationOf(listInterface) || cls.implementationOf(queueInterface)) && !name.endsWith("list") + && !name.endsWith("queue"))) { return true; } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -160,9 +160,10 @@ public void sawOpcode(int seen) { String ldcClassName = null; String seenMethodName = null; + boolean seenToString = false; int exMessageReg = -1; Integer arraySize = null; - Boolean simpleFormat = null; + boolean simpleFormat = false; try { stack.precomputation(this); @@ -182,7 +183,7 @@ if (format != null) { Matcher m = NON_SIMPLE_FORMAT.matcher(format); if (!m.matches()) { - simpleFormat = Boolean.TRUE; + simpleFormat = true; } } } @@ -218,6 +219,10 @@ seenMethodName = mthName; } } + + if (seenMethodName == null) { + seenToString = true; + } } } else if (seen == INVOKESPECIAL) { checkForLoggerParam(); @@ -245,7 +250,7 @@ LOUserValue<String> uv = (LOUserValue<String>) item.getUserValue(); if (uv != null) { if (((uv.getType() == LOUserValue.LOType.METHOD_NAME) && Values.TOSTRING.equals(uv.getValue())) - || (uv.getType() == LOUserValue.LOType.SIMPLE_FORMAT)) { + || (uv.getType() == LOUserValue.LOType.SIMPLE_FORMAT) || (uv.getType() == LOUserValue.LOType.TOSTRING)) { item.setUserValue(new LOUserValue<>(LOUserValue.LOType.NULL, null)); } } @@ -267,8 +272,10 @@ item.setUserValue(new LOUserValue<>(LOUserValue.LOType.MESSAGE_REG, Integer.valueOf(exMessageReg))); } else if (arraySize != null) { item.setUserValue(new LOUserValue<>(LOUserValue.LOType.ARRAY_SIZE, arraySize)); - } else if (simpleFormat != null) { - item.setUserValue(new LOUserValue<>(LOUserValue.LOType.SIMPLE_FORMAT, simpleFormat)); + } else if (simpleFormat) { + item.setUserValue(new LOUserValue<>(LOUserValue.LOType.SIMPLE_FORMAT, Boolean.TRUE)); + } else if (seenToString) { + item.setUserValue(new LOUserValue<>(LOUserValue.LOType.TOSTRING, null)); } } } @@ -352,11 +359,28 @@ } } } + + boolean foundToString = false; + for (int i = 0; i < (numParms - 1); i++) { + OpcodeStack.Item itm = stack.getStackItem(i); + LOUserValue<?> uv = (LOUserValue<?>) itm.getUserValue(); + foundToString = ((uv != null) + && ((uv.getType() == LOUserValue.LOType.TOSTRING) || (uv.getType() == LOUserValue.LOType.METHOD_NAME))); + if (foundToString) { + break; + } + } + + if (foundToString) { + bugReporter.reportBug(new BugInstance(this, BugType.LO_TOSTRING_PARAMETER.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) + .addSourceLine(this)); + } } } } } + } /** @@ -553,7 +577,7 @@ static class LOUserValue<T> { enum LOType { - CLASS_NAME, METHOD_NAME, MESSAGE_REG, ARRAY_SIZE, SIMPLE_FORMAT, NULL + CLASS_NAME, METHOD_NAME, MESSAGE_REG, ARRAY_SIZE, SIMPLE_FORMAT, TOSTRING, NULL }; LOType type; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -206,14 +206,20 @@ if (!activeStackOps.isEmpty()) { ActiveStackOp op = activeStackOps.getLast(); - Method getMethod = getLambdaMethod(op.getMethod().getMethodName()); - if (getMethod != null) { - byte[] byteCode = getMethod.getCode().getCode(); - if (byteCode.length <= 4) { - // we are looking for ALOAD, GETFIELD, or LDC followed by ARETURN, that should fit in 4 bytes - if (!hasInvoke(byteCode)) { - bugReporter.reportBug(new BugInstance(this, BugType.OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION.name(), LOW_PRIORITY) - .addClass(this).addMethod(this).addSourceLine(this)); + FQMethod method = op.getMethod(); + if (method == null) { + bugReporter.reportBug(new BugInstance(this, BugType.OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL.name(), LOW_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + } else { + Method getMethod = getLambdaMethod(method.getMethodName()); + if (getMethod != null) { + byte[] byteCode = getMethod.getCode().getCode(); + if (byteCode.length <= 4) { + // we are looking for ALOAD, GETFIELD, or LDC followed by ARETURN, that should fit in 4 bytes + if (!hasInvoke(byteCode)) { + bugReporter.reportBug(new BugInstance(this, BugType.OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION.name(), LOW_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this)); + } } } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -45,7 +45,8 @@ private final List<String> knownExceptions = UnmodifiableList.create( // @formatter:off - "uk/org/lidalia/" + "uk/org/lidalia/", + "au/com/bytecode/" // @formatter:on ); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -140,6 +140,7 @@ LO_STUTTERED_MESSAGE, LO_SUSPECT_LOG_CLASS, LO_SUSPECT_LOG_PARAMETER, + LO_TOSTRING_PARAMETER, LSC_LITERAL_STRING_COMPARISON, LSYC_LOCAL_SYNCHRONIZED_COLLECTION, @@ -188,6 +189,7 @@ OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED, OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION, OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION, + OI_OPTIONAL_ISSUES_USES_ORELSEGET_WITH_NULL, OPM_OVERLY_PERMISSIVE_METHOD, PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP, Modified: trunk/fb-contrib/src/samples/java/ex/CNC_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/CNC_Sample.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/samples/java/ex/CNC_Sample.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -1,6 +1,8 @@ package ex; + import java.util.Collections; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -13,6 +15,8 @@ // tag CNC_COLLECTION_NAMING_CONFUSION List<Double> bernoulliSet; + LinkedList<String> mLinkedList = new LinkedList<>(); + // tag 3xCNC_COLLECTION_NAMING_CONFUSION public void testCNC(Map<String, String> argSet, Set<String> nameList, List<String> nameMap) { Modified: trunk/fb-contrib/src/samples/java/ex/LO_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/LO_Sample.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/samples/java/ex/LO_Sample.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -102,6 +102,16 @@ l3.error(String.format("The error was %s", poo)); } + public void testToStringInParm(List<Long> data) { + l3.info("This is a parm: {}", data.toString()); + } + + public String testReuseToStringInParm(List<Long> data) { + String info = data.toString(); + l3.info("This is a parm: {}", info); + return info; + } + public void testFPReuseofSimpleFormatter(String poo) { String s = String.format("The error was %s", poo); l3.error(s); Modified: trunk/fb-contrib/src/samples/java/ex/OI_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/OI_Sample.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/samples/java/ex/OI_Sample.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -1,4 +1,6 @@ package ex; + +import java.util.Date; import java.util.Optional; import java.util.OptionalDouble; import java.util.OptionalInt; @@ -36,6 +38,10 @@ return Optional.of(3.14); } + public Date orElseGetNull(Optional<Date> o) { + return o.orElseGet(null); + } + public String fpDelayedOK(Optional<String> o, String a, String b) { return o.orElseGet(() -> String.format("%s boo %s hiss", a, b)); @@ -54,5 +60,4 @@ public Long fpBoxingIsTooCommon(Optional<Long> o) { return o.orElse(0L); } - } Modified: trunk/fb-contrib/src/samples/java/ex/UCPM_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/UCPM_Sample.java 2017-09-04 17:55:39 UTC (rev 1826) +++ trunk/fb-contrib/src/samples/java/ex/UCPM_Sample.java 2017-09-24 01:16:34 UTC (rev 1827) @@ -2,6 +2,12 @@ public class UCPM_Sample { + private static final String A; + + static { + A = "A"; + } + private StringBuffer sb; // made this a field to avoid "unnecessary use of // synchronized class" @@ -67,4 +73,10 @@ StringBuilder sb = new StringBuilder(); return sb.append("(").append(value).append(")").toString(); } + + public String fpStaticFinalField236() { + StringBuilder sb = new StringBuilder(); + sb.append(A); + return sb.toString(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-09-04 17:55:41
|
Revision: 1826 http://sourceforge.net/p/fb-contrib/code/1826 Author: dbrosius Date: 2017-09-04 17:55:39 +0000 (Mon, 04 Sep 2017) Log Message: ----------- Version 7.0.4 Added Paths: ----------- tags/v7_0_4/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-09-04 17:52:11
|
Revision: 1825 http://sourceforge.net/p/fb-contrib/code/1825 Author: dbrosius Date: 2017-09-04 17:52:07 +0000 (Mon, 04 Sep 2017) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/samples.fbp trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ContainsBasedConditional.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java trunk/fb-contrib/src/samples/java/ex/COM_Sample.java trunk/fb-contrib/src/samples/java/ex/LEST_Sample.java trunk/fb-contrib/src/samples/java/ex/LII_Sample.java trunk/fb-contrib/src/samples/java/ex/PDP_Sample.java trunk/fb-contrib/src/samples/java/ex/PSC_Sample.java trunk/fb-contrib/src/samples/java/ex/SEO_Sample.java trunk/fb-contrib/src/samples/java/ex/SUA_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/build.xml 2017-09-04 17:52:07 UTC (rev 1825) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.0.3" /> + <property name="fb-contrib.version" value="7.0.4" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/etc/findbugs.xml 2017-09-04 17:52:07 UTC (rev 1825) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -318,6 +318,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources" speed="fast" reports="UTWR_USE_TRY_WITH_RESOURCES"/> <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionIssues" speed="fast" reports="RFI_SET_ACCESSIBLE"/> + COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> Modified: trunk/fb-contrib/etc/samples.fbp =================================================================== --- trunk/fb-contrib/etc/samples.fbp 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/etc/samples.fbp 2017-09-04 17:52:07 UTC (rev 1825) @@ -1,30 +1,30 @@ <Project projectName="sample"> - <Jar>././././../target/classes/samples</Jar> - <AuxClasspathEntry>././././../lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/commons-codec-1.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/commons-collections-3.2.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/commons-lang3-3.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/guava-19.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/httpclient-4.5.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/httpclient-cache-4.5.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/httpcore-4.4.5.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/junit-4.12.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/log4j-1.2.17.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/slf4j-api-1.7.21.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/spring-beans-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/spring-context-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/spring-tx-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/threetenbp-1.3.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/jena-shaded-guava-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/commons-io-2.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>././././../lib/testng-6.9.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>./../lib/mockito-core-2.8.47.jar</AuxClasspathEntry> + <Jar>../target/classes/samples</Jar> + <AuxClasspathEntry>../lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-codec-1.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-collections-3.2.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-lang3-3.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/guava-19.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/httpclient-4.5.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/httpclient-cache-4.5.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/httpcore-4.4.5.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/junit-4.12.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/slf4j-api-1.7.21.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/spring-beans-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/spring-context-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/spring-tx-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/threetenbp-1.3.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/jena-shaded-guava-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/commons-io-2.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/testng-6.9.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/mockito-core-2.8.47.jar</AuxClasspathEntry> <AuxClasspathEntry>../lib/hamcrest-core-1.3.jar</AuxClasspathEntry> - <SrcDir>./././../src/samples/java</SrcDir> + <SrcDir>../src/samples/java</SrcDir> </Project> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/htdocs/index.shtml 2017-09-04 17:52:07 UTC (rev 1825) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.3 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.4 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/htdocs/repository.html 2017-09-04 17:52:07 UTC (rev 1825) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.0.3</td></tr> + <tr><td><b>Version:</b></td><td>7.0.4 or 7.0.4.sb</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/pom.xml 2017-09-04 17:52:07 UTC (rev 1825) @@ -6,7 +6,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.0.3</version> + <version>7.0.4</version> <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BuryingLogic.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -249,6 +249,7 @@ for (int offset : offsets) { casePositions.set(pc + offset); } + casePositions.set(pc + getDefaultSwitchOffset()); } } finally { stack.sawOpcode(this, seen); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ContainsBasedConditional.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ContainsBasedConditional.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ContainsBasedConditional.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -18,8 +18,7 @@ */ package com.mebigfatguy.fbcontrib.detect; -import java.util.ArrayList; -import java.util.List; +import java.util.BitSet; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.Constant; @@ -54,7 +53,7 @@ private BugReporter bugReporter; private OpcodeStack stack; - private List<Integer> switchLocs; + private BitSet switchLocs; private State state; private int loadType; private String constType; @@ -75,7 +74,7 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); - switchLocs = new ArrayList<Integer>(); + switchLocs = new BitSet(); super.visitClassContext(classContext); } finally { switchLocs = null; @@ -101,17 +100,18 @@ try { stack.precomputation(this); + int pc = getPC(); if ((seen == LOOKUPSWITCH) || (seen == TABLESWITCH)) { - switchLocs.add(Integer.valueOf(getPC())); + switchLocs.set(pc); for (int offset : getSwitchOffsets()) { - switchLocs.add(Integer.valueOf(getPC() + offset)); + switchLocs.set(pc + offset); } + switchLocs.set(pc + getDefaultSwitchOffset()); } - if (!switchLocs.isEmpty() && (getPC() == switchLocs.get(0).intValue())) { + if (switchLocs.get(pc)) { state = State.SAW_NOTHING; - switchLocs.remove(0); - return; + switchLocs.clear(pc); } switch (state) { @@ -128,7 +128,7 @@ } } else { loadType = seen; - bugPC = getPC(); + bugPC = pc; state = State.SAW_LOAD; } } else { @@ -175,7 +175,8 @@ break; case SAW_CONST: - if ((seen == INVOKEVIRTUAL) && "equals".equals(getNameConstantOperand()) && SignatureBuilder.SIG_OBJECT_TO_BOOLEAN.equals(getSigConstantOperand())) { + if ((seen == INVOKEVIRTUAL) && "equals".equals(getNameConstantOperand()) + && SignatureBuilder.SIG_OBJECT_TO_BOOLEAN.equals(getSigConstantOperand())) { state = State.SAW_EQUALS; } else if (seen == IF_ICMPEQ) { conditionCount++; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -33,6 +33,7 @@ import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.InvokeInstruction; import org.apache.bcel.generic.LDC; +import org.apache.bcel.generic.LDC2_W; import org.apache.bcel.generic.ReferenceType; import org.apache.bcel.generic.Type; @@ -144,6 +145,10 @@ return; } + if ((getMethod().getAccessFlags() & ACC_SYNCHRONIZED) != (superCode.getAccess() & ACC_SYNCHRONIZED)) { + return; + } + parmTypes = getMethod().getArgumentTypes(); nextParmIndex = 0; nextParmOffset = getMethod().isStatic() ? 0 : 1; @@ -248,7 +253,7 @@ * @return whether the access modifiers are the same */ private static boolean sameAccess(int parentAccess, int childAccess) { - return ((parentAccess & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == (childAccess & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED))); + return ((parentAccess & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)) == ((childAccess & (Constants.ACC_PUBLIC | Constants.ACC_PROTECTED)))); } /** @@ -351,6 +356,20 @@ return false; } // TODO: Other Constant types + } else if (childin instanceof LDC2_W) { + Type childType = ((LDC2_W) childin).getType(childPoolGen); + Type parentType = ((LDC2_W) parentin).getType(parentPoolGen); + if (!childType.equals(parentType)) { + return false; + } + + Object childValue = ((LDC2_W) childin).getValue(childPoolGen); + Object parentValue = ((LDC2_W) parentin).getValue(parentPoolGen); + + if (!childValue.equals(parentValue)) { + return false; + } + } else { if (!childin.equals(parentin)) { return false; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ListIndexedIterating.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -406,16 +406,24 @@ return true; } } else { + XField newField = itm.getXField(); + if (newField == null) { + return true; + } + XField seenField = loopCollectionItem.getXField(); - if (seenField != null) { - if (itm.getRegisterNumber() >= 0) { - return true; - } - XField newField = itm.getXField(); - if ((newField != null) && (!newField.getName().equals(seenField.getName()))) { - return true; - } + if (seenField == null) { + return true; } + + if (itm.getRegisterNumber() >= 0) { + return true; + } + + if ((loopCollectionItem.getFieldLoadedFromRegister() != itm.getFieldLoadedFromRegister()) || (itm.getFieldLoadedFromRegister() == -1) + || (!newField.getName().equals(seenField.getName()))) { + return true; + } } loopCollectionItem = itm; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LiteralStringComparison.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -75,7 +75,7 @@ public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); - lookupSwitches = new ArrayList<LookupDetails>(); + lookupSwitches = new ArrayList<>(); super.visitClassContext(classContext); } finally { stack = null; @@ -173,6 +173,7 @@ for (int offset : offsets) { bs.set(pc + offset); } + bs.set(pc + getDefaultSwitchOffset()); lookupSwitches.add(new LookupDetails(stringRef, bs)); } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -264,6 +264,10 @@ break; } } + if (catchInfo.getFinish() == Integer.MAX_VALUE) { + catchInfo.setFinish(pc); + } + } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { if (lastWasExitPoint) { // crazy jdk6 finally block injection -- shut Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -28,6 +28,7 @@ import org.apache.bcel.classfile.Method; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.QMethod; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import com.mebigfatguy.fbcontrib.utils.Values; @@ -55,11 +56,11 @@ /** * methodname:methodsig to type of setter methods */ - private Map<String, String> attributes; + private Map<QMethod, String> attributes; /** - * methodname:methodsig to (fieldname:fieldtype)s + * QMethod to (fieldname:fieldtype)s */ - private Map<String, Map<String, SourceLineAnnotation>> methodWrites; + private Map<QMethod, Map<String, SourceLineAnnotation>> methodWrites; private Map<String, FieldAnnotation> fieldAnnotations; /** @@ -113,8 +114,8 @@ * the class to look for setter methods to infer properties * @return the map of possible attributes/types */ - private static Map<String, String> getAttributes(JavaClass cls) { - Map<String, String> atts = new HashMap<>(); + private static Map<QMethod, String> getAttributes(JavaClass cls) { + Map<QMethod, String> atts = new HashMap<>(); Method[] methods = cls.getMethods(); for (Method m : methods) { String name = m.getName(); @@ -126,7 +127,7 @@ if (validAttrTypes.contains(parmSig)) { Code code = m.getCode(); if ((code != null) && (code.getCode().length < MAX_ATTRIBUTE_CODE_LENGTH)) { - atts.put(name + ':' + sig, parmSig); + atts.put(new QMethod(name, sig), parmSig); } } } @@ -158,7 +159,7 @@ @Override public void sawOpcode(int seen) { if (seen == PUTFIELD) { - String methodInfo = getMethodName() + ':' + getMethodSig(); + QMethod methodInfo = new QMethod(getMethodName(), getMethodSig()); Map<String, SourceLineAnnotation> fields = methodWrites.get(methodInfo); if (fields == null) { fields = new HashMap<>(); @@ -177,8 +178,8 @@ * generates all the bug reports for attributes that are not recycleable */ private void reportBugs() { - for (Map.Entry<String, String> attEntry : attributes.entrySet()) { - String methodInfo = attEntry.getKey(); + for (Map.Entry<QMethod, String> attEntry : attributes.entrySet()) { + QMethod methodInfo = attEntry.getKey(); String attType = attEntry.getValue(); Map<String, SourceLineAnnotation> fields = methodWrites.get(methodInfo); @@ -196,7 +197,7 @@ String fieldName = fieldInfo.substring(0, colonPos); - for (Map.Entry<String, Map<String, SourceLineAnnotation>> fwEntry : methodWrites.entrySet()) { + for (Map.Entry<QMethod, Map<String, SourceLineAnnotation>> fwEntry : methodWrites.entrySet()) { if (fwEntry.getKey().equals(methodInfo)) { continue; } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -76,6 +76,10 @@ public void visitCode(Code obj) { try { Method m = getMethod(); + if (m.isSynthetic()) { + return; + } + if (m.isStatic() || m.isPrivate() || Values.CONSTRUCTOR.equals(m.getName())) { parmSigs = SignatureUtils.getParameterSlotAndSignatures(m.isStatic(), m.getSignature()); if (!parmSigs.isEmpty() && prescreen(m)) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -268,6 +268,7 @@ for (int offset : offsets) { branchTargets.set(offset + pc); } + branchTargets.set(getDefaultSwitchOffset() + pc); } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { localMethodCalls.remove(Integer.valueOf(RegisterUtils.getAStoreReg(this, seen))); } else if (seen == PUTFIELD) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PresizeCollections.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -19,6 +19,7 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -26,6 +27,7 @@ import java.util.Set; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.CodeException; import com.mebigfatguy.fbcontrib.utils.BugType; import com.mebigfatguy.fbcontrib.utils.SignatureBuilder; @@ -42,235 +44,344 @@ import edu.umd.cs.findbugs.ba.ClassContext; /** - * finds methods that create and populate collections, and while knowing the end size of those collections, does not pre allocate the collection to be big - * enough. This just causes unneeded reallocations putting strain on the garbage collector. + * finds methods that create and populate collections, and while knowing the end + * size of those collections, does not pre allocate the collection to be big + * enough. This just causes unneeded reallocations putting strain on the garbage + * collector. */ @CustomUserValue public class PresizeCollections extends BytecodeScanningDetector { - private static final Set<String> PRESIZEABLE_COLLECTIONS = UnmodifiableSet.create("java/util/ArrayBlockingQueue", "java/util/ArrayDeque", - "java/util/ArrayList", "java/util/HashMap", "java/util/HashSet", "java/util/LinkedBlockingQueue", "java/util/LinkedHashMap", - "java/util/LinkedHashSet", "java/util/PriorityBlockingQueue", "java/util/PriorityQueue", "java/util/Vector"); + private static final Set<String> PRESIZEABLE_COLLECTIONS = UnmodifiableSet.create("java/util/ArrayBlockingQueue", + "java/util/ArrayDeque", "java/util/ArrayList", "java/util/HashMap", "java/util/HashSet", + "java/util/LinkedBlockingQueue", "java/util/LinkedHashMap", "java/util/LinkedHashSet", + "java/util/PriorityBlockingQueue", "java/util/PriorityQueue", "java/util/Vector"); - private BugReporter bugReporter; - private OpcodeStack stack; - private int allocNumber; - private Map<Integer, Integer> allocLocation; - private Map<Integer, List<Integer>> allocToAddPCs; - private List<DownBranch> downBranches; + private BugReporter bugReporter; + private OpcodeStack stack; + private int nextAllocNumber; + private Map<Comparable<?>, Integer> storeToAllocNumber; + private Map<Integer, Integer> allocLocation; + private Map<Integer, List<Integer>> allocToAddPCs; + private List<CodeRange> optionalRanges; - public PresizeCollections(BugReporter bugReporter) { - this.bugReporter = bugReporter; - } + public PresizeCollections(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } - /** - * overrides the visitor to initialize the opcode stack - * - * @param classContext - * the context object that holds the JavaClass being parsed - */ - @Override - public void visitClassContext(ClassContext classContext) { - try { - stack = new OpcodeStack(); - allocLocation = new HashMap<>(); - allocToAddPCs = new HashMap<>(); - downBranches = new ArrayList<>(); - super.visitClassContext(classContext); - } finally { - stack = null; - allocLocation = null; - allocToAddPCs = null; - downBranches = null; - } - } + /** + * overrides the visitor to initialize the opcode stack + * + * @param classContext + * the context object that holds the JavaClass being parsed + */ + @Override + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + storeToAllocNumber = new HashMap<>(); + allocLocation = new HashMap<>(); + allocToAddPCs = new HashMap<>(); + optionalRanges = new ArrayList<>(); + super.visitClassContext(classContext); + } finally { + stack = null; + storeToAllocNumber = null; + allocLocation = null; + allocToAddPCs = null; + optionalRanges = null; + } + } - /** - * implements the visitor to reset the opcode stack - * - * @param obj - * the context object of the currently parsed code block - */ - @Override - public void visitCode(Code obj) { - stack.resetForMethodEntry(this); - allocNumber = 0; - allocLocation.clear(); - allocToAddPCs.clear(); - downBranches.clear(); - super.visitCode(obj); + /** + * implements the visitor to reset the opcode stack + * + * @param obj + * the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + nextAllocNumber = 1; + storeToAllocNumber.clear(); + allocLocation.clear(); + allocToAddPCs.clear(); + optionalRanges.clear(); - for (List<Integer> pcs : allocToAddPCs.values()) { - if (pcs.size() > 16) { - bugReporter.reportBug(new BugInstance(this, BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) - .addSourceLine(this, pcs.get(0).intValue())); - } - } - } + addExceptionRanges(obj); - /** - * implements the visitor to look for creation of collections that are then populated with a known number of elements usually based on another collection, - * but the new collection is not presized. - * - * @param seen - * the opcode of the currently parsed instruction - */ - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "CLI_CONSTANT_LIST_INDEX", justification = "Constrained by FindBugs API") - @Override - public void sawOpcode(int seen) { - boolean sawAlloc = false; - try { - stack.precomputation(this); + super.visitCode(obj); - switch (seen) { - case INVOKESPECIAL: - String clsName = getClassConstantOperand(); - if (PRESIZEABLE_COLLECTIONS.contains(clsName)) { - String methodName = getNameConstantOperand(); - if (Values.CONSTRUCTOR.equals(methodName)) { - String signature = getSigConstantOperand(); - if (SignatureBuilder.SIG_VOID_TO_VOID.equals(signature)) { - sawAlloc = true; - } - } - } - break; + for (List<Integer> pcs : allocToAddPCs.values()) { + if (pcs.size() > 16) { + bugReporter.reportBug(new BugInstance(this, BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY) + .addClass(this).addMethod(this).addSourceLine(this, pcs.get(0).intValue())); + } + } + } - case INVOKEINTERFACE: - String methodName = getNameConstantOperand(); - if ("add".equals(methodName) || "addAll".equals(methodName)) { - String signature = getSigConstantOperand(); - int numArguments = SignatureUtils.getNumParameters(signature); - if ((numArguments == 1) && (stack.getStackDepth() > 1)) { - OpcodeStack.Item item = stack.getStackItem(1); - Integer allocNum = (Integer) item.getUserValue(); - if (allocNum != null) { - if ("addAll".equals(methodName)) { - allocToAddPCs.remove(allocNum); - } else { - List<Integer> lines = allocToAddPCs.get(allocNum); - if (lines == null) { - lines = new ArrayList<>(); - allocToAddPCs.put(allocNum, lines); - } - lines.add(Integer.valueOf(getPC())); - } - } - } - } else if ("put".equals(methodName) || "putAll".equals(methodName)) { - String signature = getSigConstantOperand(); - int numArguments = SignatureUtils.getNumParameters(signature); - if ((numArguments == 2) && (stack.getStackDepth() > 2)) { - OpcodeStack.Item item = stack.getStackItem(2); - Integer allocNum = (Integer) item.getUserValue(); - if (allocNum != null) { - if ("putAll".equals(methodName)) { - allocToAddPCs.remove(allocNum); - } else { - List<Integer> lines = allocToAddPCs.get(allocNum); - if (lines == null) { - lines = new ArrayList<>(); - allocToAddPCs.put(allocNum, lines); - } - lines.add(Integer.valueOf(getPC())); - } - } - } - } - break; + /** + * implements the visitor to look for creation of collections that are then + * populated with a known number of elements usually based on another + * collection, but the new collection is not presized. + * + * @param seen + * the opcode of the currently parsed instruction + */ + @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "CLI_CONSTANT_LIST_INDEX", justification = "Constrained by FindBugs API") + @Override + public void sawOpcode(int seen) { + Integer allocationNumber = null; + boolean sawAlloc = false; + try { + stack.precomputation(this); - case LOOKUPSWITCH: - case TABLESWITCH: - int[] offsets = getSwitchOffsets(); - if (offsets.length > 1) { - int secondCase = offsets[1] + getPC(); - DownBranch db = new DownBranch(getPC(), secondCase); - downBranches.add(db); - } - break; + switch (seen) { + case INVOKESPECIAL: + String clsName = getClassConstantOperand(); + if (PRESIZEABLE_COLLECTIONS.contains(clsName)) { + String methodName = getNameConstantOperand(); + if (Values.CONSTRUCTOR.equals(methodName)) { + String signature = getSigConstantOperand(); + if (SignatureBuilder.SIG_VOID_TO_VOID.equals(signature)) { + allocationNumber = Integer.valueOf(nextAllocNumber++); + sawAlloc = true; + } + } + } + break; - case IFEQ: - case IFNE: - case IFLT: - case IFLE: - case IF_ICMPEQ: - case IF_ICMPNE: - case IF_ICMPLT: - case IF_ICMPGE: - case IF_ICMPGT: - case IF_ICMPLE: - case IF_ACMPEQ: - case IF_ACMPNE: - case GOTO: - case GOTO_W: - if (getBranchOffset() < 0) { - int target = getBranchTarget(); - Iterator<Map.Entry<Integer, List<Integer>>> it = allocToAddPCs.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry<Integer, List<Integer>> entry = it.next(); - Integer allocLoc = allocLocation.get(entry.getKey()); - if ((allocLoc != null) && (allocLoc.intValue() < target)) { - List<Integer> pcs = entry.getValue(); - for (int pc : pcs) { - if (pc > target) { - int numDownBranches = countDownBranches(target, pc); - if (numDownBranches == 1) { - bugReporter.reportBug(new BugInstance(this, BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY).addClass(this) - .addMethod(this).addSourceLine(this, pc)); - it.remove(); - } - break; - } - } - } - } - } else { - DownBranch db = new DownBranch(getPC(), getBranchTarget()); - downBranches.add(db); - } - break; + case INVOKEINTERFACE: + String methodName = getNameConstantOperand(); + if ("add".equals(methodName) || "addAll".equals(methodName)) { + String signature = getSigConstantOperand(); + int numArguments = SignatureUtils.getNumParameters(signature); + if ((numArguments == 1) && (stack.getStackDepth() > 1)) { + OpcodeStack.Item item = stack.getStackItem(1); + Integer allocNum = (Integer) item.getUserValue(); + if (allocNum != null) { + if ("addAll".equals(methodName)) { + allocToAddPCs.remove(allocNum); + } else { + List<Integer> lines = allocToAddPCs.get(allocNum); + if (lines == null) { + lines = new ArrayList<>(); + allocToAddPCs.put(allocNum, lines); + } + lines.add(Integer.valueOf(getPC())); + } + } + } + } else if ("put".equals(methodName) || "putAll".equals(methodName)) { + String signature = getSigConstantOperand(); + int numArguments = SignatureUtils.getNumParameters(signature); + if ((numArguments == 2) && (stack.getStackDepth() > 2)) { + OpcodeStack.Item item = stack.getStackItem(2); + Integer allocNum = (Integer) item.getUserValue(); + if (allocNum != null) { + if ("putAll".equals(methodName)) { + allocToAddPCs.remove(allocNum); + } else { + List<Integer> lines = allocToAddPCs.get(allocNum); + if (lines == null) { + lines = new ArrayList<>(); + allocToAddPCs.put(allocNum, lines); + } + lines.add(Integer.valueOf(getPC())); + } + } + } + } + break; - case IFNULL: - case IFNONNULL: - case IFGE: - case IFGT: - // null check and >, >= branches are hard to presize - break; - } - } finally { - stack.sawOpcode(this, seen); - if (sawAlloc && (stack.getStackDepth() > 0)) { - OpcodeStack.Item item = stack.getStackItem(0); - ++allocNumber; - item.setUserValue(Integer.valueOf(allocNumber)); - allocLocation.put(Integer.valueOf(allocNumber), Integer.valueOf(getPC())); - } - } - } + case LOOKUPSWITCH: + case TABLESWITCH: + int[] offsets = getSwitchOffsets(); + if (offsets.length >= 2) { + int pc = getPC(); + int thisOffset = pc + offsets[0]; + for (int o = 0; o < (offsets.length - 1); o++) { + int nextOffset = offsets[o + 1] + pc; + CodeRange db = new CodeRange(thisOffset, nextOffset); + optionalRanges.add(db); + thisOffset = nextOffset; + } + } + break; - private int countDownBranches(int loopTop, int addPC) { - int numDownBranches = 0; - for (DownBranch db : downBranches) { - if ((db.fromPC > loopTop) && (db.fromPC < addPC) && (db.toPC > addPC)) { - numDownBranches++; - } - } + case IFEQ: + case IFNE: + case IFLT: + case IFLE: + case IF_ICMPEQ: + case IF_ICMPNE: + case IF_ICMPLT: + case IF_ICMPGE: + case IF_ICMPGT: + case IF_ICMPLE: + case IF_ACMPEQ: + case IF_ACMPNE: + case GOTO: + case GOTO_W: + if (getBranchOffset() < 0) { + int target = getBranchTarget(); + Iterator<Map.Entry<Integer, List<Integer>>> it = allocToAddPCs.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry<Integer, List<Integer>> entry = it.next(); + Integer allocLoc = allocLocation.get(entry.getKey()); + if ((allocLoc != null) && (allocLoc.intValue() < target)) { + List<Integer> pcs = entry.getValue(); + for (int pc : pcs) { + if (pc > target) { + int numDownBranches = countDownBranches(allocLoc.intValue(), pc); + if (numDownBranches == 1) { + bugReporter.reportBug(new BugInstance(this, + BugType.PSC_PRESIZE_COLLECTIONS.name(), NORMAL_PRIORITY).addClass(this) + .addMethod(this).addSourceLine(this, pc)); + it.remove(); + } + break; + } + } + } + } + } else { + CodeRange db = new CodeRange(getPC(), getBranchTarget()); + optionalRanges.add(db); + } + break; - return numDownBranches; - } + case IFNULL: + case IFNONNULL: + case IFGE: + case IFGT: + // null check and >, >= branches are hard to presize + if (getBranchOffset() > 0) { + CodeRange db = new CodeRange(getPC(), getBranchTarget()); + optionalRanges.add(db); + } + break; - static class DownBranch { - public int fromPC; - public int toPC; + case ASTORE: + case ASTORE_0: + case ASTORE_1: + case ASTORE_2: + case ASTORE_3: { + if (stack.getStackDepth() > 0) { + Integer alloc = (Integer) stack.getStackItem(0).getUserValue(); + if (alloc != null) { + storeToAllocNumber.put(getRegisterOperand(), alloc); + } + } + } + break; - DownBranch(int from, int to) { - fromPC = from; - toPC = to; - } + case ALOAD: + case ALOAD_0: + case ALOAD_1: + case ALOAD_2: + case ALOAD_3: { + allocationNumber = storeToAllocNumber.get(getRegisterOperand()); + } + break; - @Override - public String toString() { - return ToString.build(this); - } - } + case PUTFIELD: { + if (stack.getStackDepth() > 0) { + Integer alloc = (Integer) stack.getStackItem(0).getUserValue(); + if (alloc != null) { + storeToAllocNumber.put(getNameConstantOperand(), alloc); + } + } + } + break; + + case GETFIELD: { + allocationNumber = storeToAllocNumber.get(getNameConstantOperand()); + } + + } + } finally { + stack.sawOpcode(this, seen); + if ((allocationNumber != null) && (stack.getStackDepth() > 0)) { + OpcodeStack.Item item = stack.getStackItem(0); + item.setUserValue(allocationNumber); + if (sawAlloc) { + allocLocation.put(allocationNumber, Integer.valueOf(getPC())); + } + } + } + } + + private int countDownBranches(int allocationPos, int addPC) { + int numDownBranches = 0; + for (CodeRange db : optionalRanges) { + if ((db.fromPC > allocationPos) && (db.fromPC < addPC) && (db.toPC > addPC)) { + numDownBranches++; + } + } + + return numDownBranches; + } + + /** + * adds optionalRanges for all try/catch blocks + * + * @param c + * the currently parsed code object + */ + private void addExceptionRanges(Code c) { + + Map<CodeRange, List<Integer>> ranges = new HashMap<>(); + CodeException[] ces = c.getExceptionTable(); + if (ces != null) { + for (CodeException ce : ces) { + CodeRange range = new CodeRange(ce.getStartPC(), ce.getEndPC()); + List<Integer> handlers = ranges.get(range); + if (handlers == null) { + handlers = new ArrayList<>(6); + ranges.put(range, handlers); + } + handlers.add(ce.getHandlerPC()); + } + } + + for (Map.Entry<CodeRange, List<Integer>> entry : ranges.entrySet()) { + optionalRanges.add(entry.getKey()); + List<Integer> handlers = entry.getValue(); + Collections.sort(handlers); + for (int h = 0; h < (handlers.size() - 1); h++) { + optionalRanges.add(new CodeRange(handlers.get(h), handlers.get(h + 1))); + } + } + } + + static class CodeRange { + public int fromPC; + public int toPC; + + CodeRange(int from, int to) { + fromPC = from; + toPC = to; + } + + @Override + public int hashCode() { + return fromPC ^ toPC; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof CodeRange)) { + return false; + } + + CodeRange that = (CodeRange) o; + return (fromPC == that.fromPC) && (toPC == that.toPC); + } + + @Override + public String toString() { + return ToString.build(this); + } + } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousUninitializedArray.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -19,7 +19,11 @@ package com.mebigfatguy.fbcontrib.detect; import java.util.BitSet; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.bcel.Constants; import org.apache.bcel.Repository; @@ -61,9 +65,12 @@ } private final BugReporter bugReporter; + private boolean isEnum; private OpcodeStack stack; private String returnArraySig; private BitSet uninitializedRegs; + private Map<Integer, Integer> arrayAliases; + private Map<Integer, SUAUserValue> storedUVs; /** * constructs a SUA detector given the reporter to report bugs on @@ -84,12 +91,17 @@ @Override public void visitClassContext(ClassContext classContext) { try { + isEnum = classContext.getJavaClass().isEnum(); stack = new OpcodeStack(); uninitializedRegs = new BitSet(); + arrayAliases = new HashMap<>(); + storedUVs = new HashMap<>(); super.visitClassContext(classContext); } finally { stack = null; uninitializedRegs = null; + arrayAliases = null; + storedUVs = null; } } @@ -107,6 +119,10 @@ return; } + if (isEnum && m.getName().equals("values")) { + return; + } + String sig = m.getSignature(); int sigPos = sig.indexOf(")["); if (sigPos < 0) { @@ -126,6 +142,8 @@ stack.resetForMethodEntry(this); returnArraySig = sig.substring(sigPos + 1); uninitializedRegs.clear(); + arrayAliases.clear(); + storedUVs.clear(); super.visitCode(obj); } @@ -132,7 +150,7 @@ /** * overrides the visitor to annotate new array creation with a user value that denotes it as being uninitialized, and then if the array is populated to * remove that user value. It then finds return values that have uninitialized arrays. byte arrays are not collected as creating a blank byte array is - * probably a reasonably normal occurance. + * probably a reasonably normal occurrence. * * @param seen * the context parameter of the currently parsed op code @@ -147,7 +165,8 @@ case NEWARRAY: { if (!isTOS0()) { int typeCode = getIntConstant(); - if ((typeCode != Constants.T_BYTE) && returnArraySig.equals(SignatureUtils.toArraySignature(SignatureUtils.getTypeCodeSignature(typeCode)))) { + if ((typeCode != Constants.T_BYTE) + && returnArraySig.equals(SignatureUtils.toArraySignature(SignatureUtils.getTypeCodeSignature(typeCode)))) { userValue = SUAUserValue.UNINIT_ARRAY; } } @@ -195,7 +214,8 @@ } item.setUserValue(null); if (reg >= 0) { - uninitializedRegs.clear(reg); + clearAliases(reg); + storedUVs.remove(reg); } } } @@ -234,7 +254,8 @@ } item.setUserValue(null); if (reg >= 0) { - uninitializedRegs.clear(reg); + clearAliases(reg); + storedUVs.remove(reg); } } else { // error condition - stack isn't right @@ -252,9 +273,24 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); SUAUserValue uv = (SUAUserValue) item.getUserValue(); + storedUVs.put(Integer.valueOf(reg), uv); uninitializedRegs.set(reg, (uv != null) && (uv.isUnitializedArray())); + Integer aliasReg = arrayAliases.get(reg); + if (aliasReg != null) { + uninitializedRegs.set(aliasReg, (uv != null) && (uv.isUnitializedArray())); + } + + int targetReg = item.getRegisterNumber(); + if ((targetReg >= 0) && (targetReg != reg)) { + arrayAliases.put(reg, targetReg); + } else if ((uv != null) && uv.isRegister()) { + arrayAliases.put(reg, uv.getRegister()); + } else { + arrayAliases.remove(reg); + } } else { - uninitializedRegs.clear(reg); + clearAliases(reg); + storedUVs.remove(Integer.valueOf(reg)); } } break; @@ -265,9 +301,7 @@ case ALOAD_2: case ALOAD_3: { int reg = RegisterUtils.getALoadReg(this, seen); - if (uninitializedRegs.get(reg)) { - userValue = SUAUserValue.UNINIT_ARRAY; - } + userValue = storedUVs.get(Integer.valueOf(reg)); } break; @@ -277,7 +311,8 @@ item.setUserValue(null); int reg = item.getRegisterNumber(); if (reg >= 0) { - uninitializedRegs.clear(reg); + clearAliases(reg); + storedUVs.remove(reg); } } } @@ -288,7 +323,6 @@ OpcodeStack.Item item = stack.getStackItem(0); SUAUserValue uv = (SUAUserValue) item.getUserValue(); if ((uv != null) && (uv.isUnitializedArray())) { - bugReporter.reportBug(new BugInstance(this, BugType.SUA_SUSPICIOUS_UNINITIALIZED_ARRAY.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addSourceLine(this)); } @@ -296,16 +330,21 @@ } break; + case DUP: + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + userValue = (SUAUserValue) item.getUserValue(); + } + break; + default: break; } - } finally - - { + } finally { TernaryPatcher.pre(stack, seen); stack.sawOpcode(this, seen); TernaryPatcher.post(stack, seen); - if (stack.getStackDepth() > 0) { + if ((Constants.PRODUCE_STACK[seen] > 0) && (stack.getStackDepth() > 0)) { OpcodeStack.Item item = stack.getStackItem(0); item.setUserValue(userValue); } @@ -312,6 +351,41 @@ } } + private void clearAliases(int reg) { + + clearClosureAliases(reg, new BitSet()); + } + + private void clearClosureAliases(int reg, BitSet alreadyCleared) { + + if (alreadyCleared.get(reg)) { + return; + } + + uninitializedRegs.clear(reg); + alreadyCleared.set(reg); + if (uninitializedRegs.isEmpty()) { + return; + } + + Integer targetReg = arrayAliases.get(reg); + if (targetReg != null) { + clearClosureAliases(targetReg, alreadyCleared); + } + + Set<Integer> clear = new HashSet<>(); + for (Map.Entry<Integer, Integer> entry : arrayAliases.entrySet()) { + targetReg = entry.getValue(); + if (targetReg.equals(reg)) { + clear.add(entry.getKey()); + } + } + + for (Integer cr : clear) { + clearClosureAliases(cr, alreadyCleared); + } + } + private boolean isTOS0() { if (stack.getStackDepth() == 0) { return false; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java 2017-07-19 21:31:58 UTC (rev 1824) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/ToString.java 2017-09-04 17:52:07 UTC (rev 1825) @@ -24,80 +24,85 @@ import java.util.HashSet; import java.util.Set; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * an automatic toString() builder using reflection */ public class ToString { - /** - * holds objects that have already been converted to string to avoid infinite loops in the toString generation - */ - private static class VisitedInfo { - Set<Integer> visited = new HashSet<>(); - int count = 0; - } + /** + * holds objects that have already been converted to string to avoid infinite + * loops in the toString generation + */ + private static class VisitedInfo { + Set<Integer> visited = new HashSet<>(); + int count = 0; + } - private static final ThreadLocal<VisitedInfo> visited = new ThreadLocal<VisitedInfo>() { + private static final ThreadLocal<VisitedInfo> visited = new ThreadLocal<VisitedInfo>() { - @Override - protected VisitedInfo initialValue() { - return new VisitedInfo(); - } - }; + @Override + protected VisitedInfo initialValue() { + return new VisitedInfo(); + } + }; - private ToString() { - } + private ToString() { + } - public static String build(Object o, String... ignoredFields) { - VisitedInfo vi = visited.get(); - try { - vi.count++; - return generate(o, (ignoredFields == null) ? null : Arrays.<String> asList(ignoredFields), vi.visited); - } finally { - if (--vi.count == 0) { - vi.visited.clear(); - } - } - } + public static String build(Object o, String... ignoredFields) { + VisitedInfo vi = visited.get(); + try { + vi.count++; + return generate(o, (ignoredFields == null) ? null : Arrays.<String>asList(ignoredFields), vi.visited); + } finally { + if (--vi.count == 0) { + vi.visited.clear(); + } + } + } - private static String generate(Object o, Collection<String> ignoredFields, Set<Integer> visitedObjects) { + @SuppressFBWarnings(value = "RFI_SET_ACCESSIBLE", justification = "No other simple way to to show value of object") + private static String generate(Object o, Collection<String> ignoredFields, Set<Integer> visitedObjects) { - StringBuilder sb = new StringBuilder(100); - Class<?> cls = o.getClass(); - Integer identityHC = Integer.valueOf(System.identityHashCode(o)); - sb.append(cls.getSimpleName()).append('[').append(identityHC).append("]{"); + StringBuilder sb = new StringBuilder(100); + Class<?> cls = o.getClass(); + Integer identityHC = Integer.valueOf(System.identityHashCode(o)); + sb.append(cls.getSimpleName()).append('[').append(identityHC).append("]{"); - if (!visitedObjects.contains(identityHC)) { - try { - visitedObjects.add(identityHC); - String sep = ""; - for (Field f : cls.getDeclaredFields()) { - String fieldName = f.getName(); - if (!f.isSynthetic() && !fieldName.contains("$") && ((ignoredFields == null) || !ignoredFields.contains(fieldName))) { - sb.append(sep); - sep = ", "; - sb.append(fieldName).append('='); - try { - f.setAccessible(true); - Object value = f.get(o); - if (value == null) { - sb.append((String) null); - } else if (value.getClass().isArray()) { - sb.append(Arrays.toString((Object[]) value)); - } else { - sb.append(value); - } - } catch (SecurityException e) { - sb.append("*SECURITY_EXCEPTION*"); - } - } - } - } catch (IllegalAccessException | RuntimeException e) { - // if we get an exception show as much as we can get - } - } + if (!visitedObjects.contains(identityHC)) { + try { + visitedObjects.add(identityHC); + String sep = ""; + for (Field f : cls.getDeclaredFields()) { + String fieldName = f.getName(); + if (!f.isSynthetic() && !fieldName.contains("$") + && ((ignoredFields == null) || !ignoredFields.contains(fieldName))) { + sb.append(sep); + sep = ", "; + sb.append(fieldName).append('='); + try { + f.setAccessible(true); + Object value = f.get(o); + if (value == null) { + sb.append((String) null); + } else if (value.getClass().isArray()) { + sb.append(Arrays.toString((Object[]) value)); + } else { + sb.append(value); + } + } catch (SecurityException e) { + sb.append("*SECURITY_EXCEPTION*"); + } + } + } + } catch (IllegalAccessException | RuntimeException e) { + // if we get an exception show as much as we can get + } + } - sb.a... [truncated message content] |
From: <dbr...@us...> - 2017-07-19 21:32:00
|
Revision: 1824 http://sourceforge.net/p/fb-contrib/code/1824 Author: dbrosius Date: 2017-07-19 21:31:58 +0000 (Wed, 19 Jul 2017) Log Message: ----------- Version 7.0.3 Added Paths: ----------- tags/v7_0_3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-07-19 21:29:50
|
Revision: 1823 http://sourceforge.net/p/fb-contrib/code/1823 Author: dbrosius Date: 2017-07-19 21:29:47 +0000 (Wed, 19 Jul 2017) Log Message: ----------- sync 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 trunk/fb-contrib/etc/samples.fbp trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SuspiciousShadedClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/samples/java/ex/BED_Sample.java trunk/fb-contrib/src/samples/java/ex/FCCD_Sample.java trunk/fb-contrib/src/samples/java/ex/LO_Sample.java trunk/fb-contrib/src/samples/java/ex/OPM_Sample.java trunk/fb-contrib/src/samples/java/ex/UTAO_Sample.java trunk/fb-contrib/yank.xls Added Paths: ----------- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java trunk/fb-contrib/src/samples/java/ex/RFI_Sample.java trunk/fb-contrib/src/samples/java/ex/opm/ trunk/fb-contrib/src/samples/java/ex/opm/RuleMatcher.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/.classpath 2017-07-19 21:29:47 UTC (rev 1823) @@ -18,8 +18,11 @@ <classpathentry kind="lib" path="lib/findbugs-3.0.1.jar" sourcepath="lib/sources/findbugs-3.0.1-sources.jar"/> <classpathentry kind="lib" path="lib/junit-4.12.jar"/> <classpathentry kind="lib" path="lib/javax.persistence-2.1.1.jar" sourcepath="/home/dave/.m2/repository/org/eclipse/persistence/javax.persistence/2.1.1/javax.persistence-2.1.1-sources.jar"/> - <classpathentry kind="lib" path="lib/mockito-all-2.0.2-beta.jar"/> - <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> + <classpathentry combineaccessrules="false" kind="src" path="/findbugs"> + <accessrules> + <accessrule kind="nonaccessible" pattern="org/hamcrest/**"/> + </accessrules> + </classpathentry> <classpathentry kind="lib" path="lib/threetenbp-1.3.2.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.2.jar"/> @@ -40,5 +43,7 @@ <classpathentry kind="lib" path="lib/commons-io-2.4.jar"/> <classpathentry kind="lib" path="lib/jersey-media-multipart-2.25.1.jar"/> <classpathentry kind="lib" path="lib/javax.ws.rs-api-2.0.1.jar"/> + <classpathentry kind="lib" path="lib/mockito-core-2.8.47.jar" sourcepath="/home/dave/.m2/repository/org/mockito/mockito-core/2.8.47/mockito-core-2.8.47-sources.jar"/> + <classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/> <classpathentry kind="output" path="target/classes/main"/> </classpath> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/build.xml 2017-07-19 21:29:47 UTC (rev 1823) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.0.2" /> + <property name="fb-contrib.version" value="7.0.3" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> @@ -108,7 +108,8 @@ <path id="fb-contrib.test.classpath"> <pathelement location="${lib.dir}/testng-${testng.version}.jar" /> <pathelement location="${lib.dir}/jcommander-${jcommander.version}.jar" /> - <pathelement location="${lib.dir}/mockito-all-${mockito-all.version}.jar" /> + <pathelement location="${lib.dir}/mockito-core-${mockito-core.version}.jar" /> + <pathelement location="${lib.dir}/hamcrest-core-${hamcrest-core.version}.jar" /> <pathelement location="${findbugs.dir}/lib/dom4j-1.6.1.jar" /> <pathelement location="${findbugs.dir}/lib/jaxen-1.1.6.jar" /> @@ -134,7 +135,8 @@ <pathelement location="${lib.dir}/spring-context-${spring-context.version}.jar" /> <pathelement location="${lib.dir}/spring-tx-${spring-tx.version}.jar" /> <pathelement location="${lib.dir}/javax.persistence-${javax.persistence.version}.jar" /> - <pathelement location="${lib.dir}/mockito-all-${mockito-all.version}.jar" /> + <pathelement location="${lib.dir}/mockito-core-${mockito-core.version}.jar" /> + <pathelement location="${lib.dir}/hamcrest-core-${hamcrest-core.version}.jar" /> <pathelement location="${lib.dir}/jena-shaded-guava-${jena-shaded-guava.version}.jar" /> <pathelement location="${lib.dir}/javax.ws.rs-api-${javax.ws.rs-api.version}.jar" /> <pathelement location="${lib.dir}/jersey-media-multipart-${jersey-media-multipart.version}.jar" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/etc/bugrank.txt 2017-07-19 21:29:47 UTC (rev 1823) @@ -64,11 +64,13 @@ +0 BugPattern IKNC_INCONSISTENT_HTTP_ATTRIBUTE_CASING +0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING +1 BugPattern IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES ++0 BugPattern IMC_IMMATURE_CLASS_LOWER_CLASS +2 BugPattern IMC_IMMATURE_CLASS_NO_EQUALS +2 BugPattern IMC_IMMATURE_CLASS_NO_HASHCODE +0 BugPattern IMC_IMMATURE_CLASS_NO_PACKAGE +2 BugPattern IMC_IMMATURE_CLASS_NO_TOSTRING +0 BugPattern IMC_IMMATURE_CLASS_PRINTSTACKTRACE ++0 BugPattern IMC_IMMATURE_CLASS_UPPER_PACKAGE +0 BugPattern IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER +0 BugPattern IOI_COPY_WITH_READER +0 BugPattern IOI_DOUBLE_BUFFER_COPY @@ -162,6 +164,7 @@ +0 BugPattern PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS +0 BugPattern PSC_PRESIZE_COLLECTIONS +0 BugPattern PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION ++0 BugPattern RFI_SET_ACCESSIBLE +0 BugPattern ROOM_REFLECTION_ON_OBJECT_METHODS +0 BugPattern S508C_APPENDED_STRING +0 BugPattern S508C_NON_ACCESSIBLE_JCOMPONENT Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/etc/findbugs.xml 2017-07-19 21:29:47 UTC (rev 1823) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -77,7 +77,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.NeedlessAutoboxing" speed="fast" reports="NAB_NEEDLESS_AUTOBOXING_CTOR,NAB_NEEDLESS_BOXING_STRING_CTOR,NAB_NEEDLESS_AUTOBOXING_VALUEOF,NAB_NEEDLESS_BOXING_PARSE,NAB_NEEDLESS_BOXING_VALUEOF,NAB_NEEDLESS_BOX_TO_UNBOX,NAB_NEEDLESS_BOX_TO_CAST,NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryStoreBeforeReturn" speed="fast" reports="USBR_UNNECESSARY_STORE_BEFORE_RETURN,UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryStoreBeforeReturn" speed="fast" reports="USBR_UNNECESSARY_STORE_BEFORE_RETURN" /> <Detector class="com.mebigfatguy.fbcontrib.detect.CopiedOverriddenMethod" speed="fast" reports="COM_COPIED_OVERRIDDEN_METHOD,COM_PARENT_DELEGATED_CALL" /> @@ -285,7 +285,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes" speed="fast" reports="STT_STRING_PARSING_A_FIELD,STT_TOSTRING_STORED_IN_FIELD,STT_TOSTRING_MAP_KEYING" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING,IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES,IMC_IMMATURE_CLASS_PRINTSTACKTRACE,IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING,IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES,IMC_IMMATURE_CLASS_PRINTSTACKTRACE,IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER,IMC_IMMATURE_CLASS_UPPER_PACKAGE,IMC_IMMATURE_CLASS_LOWER_CLASS" /> <Detector class="com.mebigfatguy.fbcontrib.detect.JAXRSIssues" speed="fast" reports="JXI_GET_ENDPOINT_CONSUMES_CONTENT,JXI_INVALID_CONTEXT_PARAMETER_TYPE,JXI_PARM_PARAM_NOT_FOUND_IN_PATH,JXI_UNDEFINED_PARAMETER_SOURCE_IN_ENDPOINT" /> @@ -313,10 +313,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion" speed="fast" reports="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT,UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"/> - <!-- COMMENT OUT FOR POINT RELEASE + <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources" speed="fast" reports="UTWR_USE_TRY_WITH_RESOURCES"/> + <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionIssues" speed="fast" reports="RFI_SET_ACCESSIBLE"/> COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -571,6 +572,8 @@ <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_NO_TOSTRING" category="STYLE" /> <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_PRINTSTACKTRACE" category="STYLE" /> <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER" category="STYLE" /> + <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_UPPER_PACKAGE" category="STYLE" /> + <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_LOWER_CLASS" category="STYLE" /> <BugPattern abbrev="JXI" type="JXI_GET_ENDPOINT_CONSUMES_CONTENT" category="CORRECTNESS" /> <BugPattern abbrev="JXI" type="JXI_INVALID_CONTEXT_PARAMETER_TYPE" category="CORRECTNESS" /> <BugPattern abbrev="JXI" type="JXI_PARM_PARAM_NOT_FOUND_IN_PATH" category="CORRECTNESS" /> @@ -591,12 +594,13 @@ <BugPattern abbrev="WI" type="WI_DUPLICATE_WIRED_TYPES" category="CORRECTNESS"/> <BugPattern abbrev="CCI" type="CCI_CONCURRENT_COLLECTION_ISSUES_USE_PUT_IS_RACY" category="CORRECTNESS"/> <BugPattern abbrev="UTWR" type="UTWR_USE_TRY_WITH_RESOURCES" category="STYLE" experimental="true"/> - <BugPattern abbrev="SSCU" type="SSCU_SUSPICIOUS_SHADED_CLASS_USE" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="USFW" type="USFW_UNSYNCHRONIZED_SINGLETON_FIELD_WRITES" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_CHECKING_REFERENCE" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT" category="CORRECTNESS" experimental="true"/> - <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" category="CORRECTNESS" experimental="true"/> + <BugPattern abbrev="SSCU" type="SSCU_SUSPICIOUS_SHADED_CLASS_USE" category="CORRECTNESS"/> + <BugPattern abbrev="USFW" type="USFW_UNSYNCHRONIZED_SINGLETON_FIELD_WRITES" category="CORRECTNESS"/> + <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION" category="CORRECTNESS"/> + <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION" category="CORRECTNESS"/> + <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_CHECKING_REFERENCE" category="CORRECTNESS"/> + <BugPattern abbrev="OI" type="OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED" category="CORRECTNESS"/> + <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT" category="CORRECTNESS"/> + <BugPattern abbrev="UAC" type="UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH" category="CORRECTNESS"/> + <BugPattern abbrev="RFI" type="RFI_SET_ACCESSIBLE" category="CORRECTNESS" experimental="true"/> </FindbugsPlugin> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/etc/messages.xml 2017-07-19 21:29:47 UTC (rev 1823) @@ -1696,7 +1696,16 @@ </Details> </Detector> + <Detector class="com.mebigfatguy.fbcontrib.detect.ReflectionIssues"> + <Details> + <![CDATA[ + <p>Looks for issues around the use of java reflection.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger"> <Details></Details> </Detector> @@ -3691,8 +3700,8 @@ </BugPattern> <BugPattern type="UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT"> - <ShortDescription>JUnit test method asserts that a value is true or false</ShortDescription> - <LongDescription>JUnit test method {1} asserts that a value is true or false</LongDescription> + <ShortDescription>JUnit test method asserts that a value is equal to true or false</ShortDescription> + <LongDescription>JUnit test method {1} asserts that a value is equal to true or false</LongDescription> <Details> <![CDATA[ <p>This method asserts that a value is equal to true or false. It is simpler to just @@ -5318,18 +5327,18 @@ <p>This method builds a key for a map, using a StringBuilder, either implicitly or explicitly. This means the type of the key is something more t han a String constant, it is a properly formatted String. However, there is no type based verification that all uses of this key will follow this formatting. It is much better to use a proper, simple, - bean class that holds two (or more fields) so that it is clear what is expected for key use. + bean class that holds two (or more) fields so that it is clear what is expected for key use. </p> <p> Example<br/> instead of - {@code + <pre><code> V v = myMap.get(tableName + "-" + columnName); - } + </code></pre> use - {@code + <pre><code> V v = myMap.get(new ColumnSpec(tableName, columnName)); - } + </code></pre> where ColumnSpec is a simple bean-like class of your creation. The advantages, are <ul> <li>The ColumnSpec fully describes what is expected, you need a tableName and columnName</li> @@ -5469,7 +5478,30 @@ </Details> </BugPattern> + <BugPattern type="IMC_IMMATURE_CLASS_UPPER_PACKAGE"> + <ShortDescription>Class is defined in a package with upper case characters</ShortDescription> + <LongDescription>Class {0} is defined in a package with upper case characters</LongDescription> + <Details> + <![CDATA[ + <p>This class is defined within a package that uses upper case letters. Package names are + expected to be in the form of alllowercase.</p> + ]]> + </Details> + </BugPattern> + <BugPattern type="IMC_IMMATURE_CLASS_LOWER_CLASS"> + <ShortDescription>Class does not start with an upper case letter</ShortDescription> + <LongDescription>Class {0} does not start with an upper case letter</LongDescription> + <Details> + <![CDATA[ + <p>This class has been given a name that does not start with an upper case letter. + Classes should follow a pattern of uppercasing the first letter of each word, AsAnExample</p> + ]]> + </Details> + </BugPattern> + + + <BugPattern type="JXI_GET_ENDPOINT_CONSUMES_CONTENT"> <ShortDescription>JAX-RS Method implements a GET request but consumes input</ShortDescription> <LongDescription>JAX-RS Method {1} implements a GET request but consumes input</LongDescription> @@ -5873,6 +5905,19 @@ ]]> </Details> </BugPattern> + + <BugPattern type="RFI_SET_ACCESSIBLE"> + <ShortDescription>Method uses AccessibleObject.setAccessible to modify accessibility of classes</ShortDescription> + <LongDescription>Method {1} uses AccessibleObject.setAccessible to modify accessibility of classes</LongDescription> + <Details> + <![CDATA[ + <p>This method uses the reflective setAccessible method to alter the behavior of methods and fields in classes + in ways that were not expected to be accessed by the author. Doing so circumvents the protections that the author + provided through the class definition, and may expose your application unexpected side effects and problems. This + functionality is deprecated in Java 9, and in Java 10 it is expected that this functionality won't work at all. + ]]> + </Details> + </BugPattern> <!-- BugCode --> @@ -6016,4 +6061,5 @@ <BugCode abbrev="USFW">Unsynchronized Singleton Field Writes</BugCode> <BugCode abbrev="OI">Optional Issues</BugCode> <BugCode abbrev="UAC">Unnecessary Api Conversion</BugCode> + <BugCode abbrev="RFI">Reflection Issues</BugCode> </MessageCollection> Modified: trunk/fb-contrib/etc/samples.fbp =================================================================== --- trunk/fb-contrib/etc/samples.fbp 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/etc/samples.fbp 2017-07-19 21:29:47 UTC (rev 1823) @@ -1,29 +1,30 @@ <Project projectName="sample"> - <Jar>././../target/classes/samples</Jar> - <AuxClasspathEntry>././../lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/commons-codec-1.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/commons-collections-3.2.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/commons-lang3-3.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/guava-19.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/httpclient-4.5.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/httpclient-cache-4.5.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/httpcore-4.4.5.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/junit-4.12.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/log4j-1.2.17.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/mockito-all-2.0.2-beta.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/slf4j-api-1.7.21.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/spring-beans-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/spring-context-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/spring-tx-4.3.3.RELEASE.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/threetenbp-1.3.2.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/jena-shaded-guava-3.1.0.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/commons-io-2.4.jar</AuxClasspathEntry> - <AuxClasspathEntry>././../lib/testng-6.9.10.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry> - <AuxClasspathEntry>../lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry> - <SrcDir>./../src/samples/java</SrcDir> + <Jar>././././../target/classes/samples</Jar> + <AuxClasspathEntry>././././../lib/asm-debug-all-5.0.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/backport-util-concurrent-3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/commons-codec-1.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/commons-collections-3.2.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/commons-lang3-3.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/guava-19.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/httpclient-4.5.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/httpclient-cache-4.5.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/httpcore-4.4.5.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/javax.persistence-2.1.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/javax.servlet-api-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/javax.servlet.jsp-api-2.3.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/junit-4.12.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/log4j-1.2.17.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/slf4j-api-1.7.21.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/spring-beans-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/spring-context-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/spring-tx-4.3.3.RELEASE.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/threetenbp-1.3.2.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/jena-shaded-guava-3.1.0.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/commons-io-2.4.jar</AuxClasspathEntry> + <AuxClasspathEntry>././././../lib/testng-6.9.10.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/javax.ws.rs-api-2.0.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>././../lib/jersey-media-multipart-2.25.1.jar</AuxClasspathEntry> + <AuxClasspathEntry>./../lib/mockito-core-2.8.47.jar</AuxClasspathEntry> + <AuxClasspathEntry>../lib/hamcrest-core-1.3.jar</AuxClasspathEntry> + <SrcDir>./././../src/samples/java</SrcDir> </Project> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/htdocs/index.shtml 2017-07-19 21:29:47 UTC (rev 1823) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.2 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.3 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/htdocs/repository.html 2017-07-19 21:29:47 UTC (rev 1823) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.0.2</td></tr> + <tr><td><b>Version:</b></td><td>7.0.3</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/pom.xml 2017-07-19 21:29:47 UTC (rev 1823) @@ -1,23 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- pom.xml developed by Grzegorz Slowikowski --> -<project - xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.0.2</version> + <version>7.0.3</version> + <!-- TODO: Delete this and replace with enforcer plugin. This is for maven plugins only! Latest maven will through warnings. --> <prerequisites> - <maven>2.2.1</maven> + <maven>3.2.5</maven> </prerequisites> + <!-- TODO: Oss parent is obsolete, define items directly for releasing --> <parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> - <version>5</version> + <version>9</version> + <relativePath /> </parent> <name>FindBugs Contrib plugin library</name> @@ -71,15 +72,18 @@ <email>she...@ya...</email> </contributor> <contributor> - <name>Juan Martín Sotuyo Dodero</name> - <email>jua...@gm...</email> + <name>Juan Martín Sotuyo Dodero</name> + <email>jua...@gm...</email> </contributor> <contributor> - <name>Richard Fearn</name> + <name>Richard Fearn</name> </contributor> <contributor> - <name>Mikkel Kjeldsen</name> + <name>Mikkel Kjeldsen</name> </contributor> + <contributor> + <name>Jeremy Landis</name> + </contributor> </contributors> <licenses> @@ -130,6 +134,12 @@ <artifactId>findbugs</artifactId> <version>3.0.1</version> <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>xml-apis</groupId> + <artifactId>xml-apis</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>com.google.code.findbugs</groupId> @@ -140,69 +150,166 @@ <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>annotations</artifactId> - <version>3.0.0</version> + <version>3.0.1u2</version> <scope>provided</scope> </dependency> - <dependency><scope>test</scope><groupId>backport-util-concurrent</groupId><artifactId>backport-util-concurrent</artifactId><version>3.1</version></dependency> - <dependency><scope>test</scope><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>19.0</version></dependency> - <dependency><scope>test</scope><groupId>commons-codec</groupId><artifactId>commons-codec</artifactId><version>1.10</version></dependency> - <dependency><scope>test</scope><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.4</version></dependency> - <dependency><scope>test</scope><groupId>commons-collections</groupId><artifactId>commons-collections</artifactId><version>3.2.2</version></dependency> - <dependency><scope>test</scope><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version></dependency> - <dependency><scope>test</scope><groupId>javax.servlet.jsp</groupId><artifactId>javax.servlet.jsp-api</artifactId><version>2.3.1</version></dependency> - <dependency><scope>test</scope><groupId>javax.ws.rs</groupId><artifactId>javax.ws.rs-api</artifactId><version>2.0.1</version></dependency> - <dependency><scope>test</scope><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency> - <dependency><scope>test</scope><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency> - <dependency><scope>test</scope><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.3</version></dependency> - <dependency><scope>test</scope><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>4.5.2</version></dependency> - <dependency><scope>test</scope><groupId>org.apache.httpcomponents</groupId><artifactId>httpcore</artifactId><version>4.4.5</version></dependency> - <dependency><scope>test</scope><groupId>org.mockito</groupId><artifactId>mockito-all</artifactId><version>2.0.2-beta</version></dependency> - <dependency><scope>test</scope><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.7.21</version></dependency> - <dependency><scope>test</scope><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>4.3.3.RELEASE</version></dependency> - <dependency><scope>test</scope><groupId>org.testng</groupId><artifactId>testng</artifactId><version>6.9.10</version></dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>4.3.3.RELEASE</version> - <scope>test</scope> + <scope>test</scope> + <groupId>backport-util-concurrent</groupId> + <artifactId>backport-util-concurrent</artifactId> + <version>3.1</version> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>4.3.3.RELEASE</version> - <scope>test</scope> + <scope>test</scope> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>22.0-android</version> </dependency> <dependency> - <groupId>org.threeten</groupId> - <artifactId>threetenbp</artifactId> - <version>1.3.2</version> - <scope>test</scope> + <scope>test</scope> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>1.10</version> </dependency> <dependency> - <groupId>org.apache.jena</groupId> - <artifactId>jena-shaded-guava</artifactId> - <version>3.1.0</version> - <scope>test</scope> + <scope>test</scope> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.5</version> </dependency> <dependency> - <groupId>org.glassfish.jersey.media</groupId> - <artifactId>jersey-media-multipart</artifactId> - <version>2.25.1</version> - <scope>test</scope> + <scope>test</scope> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>3.2.2</version> </dependency> <dependency> - <groupId>org.eclipse.persistence</groupId> - <artifactId>javax.persistence</artifactId> - <version>2.1.1</version> - <scope>test</scope> + <scope>test</scope> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> </dependency> + <dependency> + <scope>test</scope> + <groupId>javax.servlet.jsp</groupId> + <artifactId>javax.servlet.jsp-api</artifactId> + <version>2.3.1</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>2.0.1</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.6</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.3</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>4.4.6</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>2.8.47</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.25</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.springframework</groupId> + <artifactId>spring-tx</artifactId> + <version>4.3.9.RELEASE</version> + </dependency> + <dependency> + <scope>test</scope> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <version>6.9.10</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>4.3.9.RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>4.3.9.RELEASE</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.threeten</groupId> + <artifactId>threetenbp</artifactId> + <version>1.3.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>jena-shaded-guava</artifactId> + <version>3.3.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-multipart</artifactId> + <version>2.25.1</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.glassfish.hk2</groupId> + <artifactId>osgi-resource-locator</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.eclipse.persistence</groupId> + <artifactId>javax.persistence</artifactId> + <version>2.1.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + <version>1.3</version> + <scope>test</scope> + </dependency> </dependencies> <build> - <outputDirectory>${basedir}/target/classes/main</outputDirectory> + <outputDirectory>${project.basedir}/target/classes/main</outputDirectory> <resources> <resource> - <directory>${basedir}</directory> + <directory>${project.basedir}</directory> <includes> <include>plugin.xml</include> <include>license.txt</include> @@ -209,7 +316,7 @@ </includes> </resource> <resource> - <directory>${basedir}/etc</directory> + <directory>${project.basedir}/etc</directory> <excludes> <exclude>*.xsd</exclude> <exclude>*.xsl</exclude> @@ -219,14 +326,40 @@ <pluginManagement> <plugins> - <plugin><artifactId>maven-clean-plugin</artifactId><version>2.6.1</version></plugin> - <plugin><groupId>org.codehaus.mojo</groupId><artifactId>buildnumber-maven-plugin</artifactId><version>1.3</version></plugin> - <plugin><groupId>org.codehaus.mojo</groupId><artifactId>build-helper-maven-plugin</artifactId><version>1.9.1</version></plugin> - <plugin><groupId>org.codehaus.mojo</groupId><artifactId>findbugs-maven-plugin</artifactId><version>2.5.5</version></plugin> - <plugin><artifactId>maven-compiler-plugin</artifactId><version>3.3</version></plugin> - <plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.2</version></plugin> - <plugin><artifactId>maven-install-plugin</artifactId><version>2.5.2</version></plugin> - <plugin><artifactId>maven-jar-plugin</artifactId><version>2.6</version> + <plugin> + <artifactId>maven-clean-plugin</artifactId> + <version>3.0.0</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <version>1.4</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.0.0</version> + </plugin> + <plugin> + <groupId>com.github.hazendaz.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>3.0.6</version> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.6.1</version> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.8.2</version> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <version>2.5.2</version> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> <configuration> <archive> <manifestEntries> @@ -242,18 +375,39 @@ <Bundle-Vendor>FB-Contrib Project</Bundle-Vendor> <Require-Bundle>edu.umd.cs.findbugs.plugin.eclipse</Require-Bundle> <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy> - <Export-Package>com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, com.mebigfatguy.fbcontrib.debug</Export-Package> - <Import-Package>edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.bcel, edu.umd.cs.findbugs.visitclass, org.apache.bcel, org.apache.bcel.classfile, org.apache.bcel.generic</Import-Package> + <Export-Package>com.mebigfatguy.fbcontrib.collect, com.mebigfatguy.fbcontrib.detect, + com.mebigfatguy.fbcontrib.debug</Export-Package> + <Import-Package>edu.umd.cs.findbugs, edu.umd.cs.findbugs.ba, edu.umd.cs.findbugs.bcel, + edu.umd.cs.findbugs.visitclass, org.apache.bcel, org.apache.bcel.classfile, + org.apache.bcel.generic</Import-Package> </manifestEntries> </archive> </configuration> </plugin> - <plugin><artifactId>maven-pmd-plugin</artifactId><version>3.5</version></plugin> - <plugin><artifactId>maven-project-info-reports-plugin</artifactId><version>2.7</version></plugin> - <plugin><artifactId>maven-resources-plugin</artifactId><version>2.7</version></plugin> - <plugin><artifactId>maven-site-plugin</artifactId><version>3.4</version></plugin> - <plugin><artifactId>maven-source-plugin</artifactId><version>2.2.1</version></plugin> - <plugin><artifactId>maven-surefire-plugin</artifactId><version>2.18.1</version></plugin> + <plugin> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>2.9</version> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <version>3.6</version> + </plugin> + <plugin> + <artifactId>maven-source-plugin</artifactId> + <version>3.0.1</version> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.20</version> + </plugin> + <plugin> + <artifactId>maven-pmd-plugin</artifactId> + <version>3.5</version> + </plugin> </plugins> </pluginManagement> @@ -261,8 +415,16 @@ <plugin> <artifactId>maven-pmd-plugin</artifactId> <dependencies> - <dependency><groupId>net.sourceforge.pmd</groupId><artifactId>pmd-java</artifactId><version>5.5.1</version></dependency> - <dependency><groupId>net.sourceforge.pmd</groupId><artifactId>pmd-core</artifactId><version>5.5.1</version></dependency> + <dependency> + <groupId>net.sourceforge.pmd</groupId> + <artifactId>pmd-java</artifactId> + <version>5.5.1</version> + </dependency> + <dependency> + <groupId>net.sourceforge.pmd</groupId> + <artifactId>pmd-core</artifactId> + <version>5.5.1</version> + </dependency> </dependencies> <configuration> <rulesets> @@ -286,7 +448,8 @@ </executions> </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId><artifactId>buildnumber-maven-plugin</artifactId> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> <executions> <execution> <phase>validate</phase> @@ -297,7 +460,8 @@ </executions> </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId><artifactId>build-helper-maven-plugin</artifactId> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> <configuration> <sources> <source>src/samples/java</source> @@ -314,7 +478,7 @@ </plugin> <plugin> <artifactId>maven-dependency-plugin</artifactId> - <version>2.10</version> + <version>3.0.1</version> <executions> <execution> <id>unpack-findbugs-core</id> @@ -343,20 +507,31 @@ </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId><artifactId>findbugs-maven-plugin</artifactId> + <groupId>com.github.hazendaz.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> <dependencies> - <dependency><groupId>com.google.code.findbugs</groupId><artifactId>findbugs</artifactId><version>3.0.1</version></dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>findbugs</artifactId> + <version>3.0.1</version> + </dependency> </dependencies> <configuration> <excludeFilterFile>etc/findbugs-exclude.xml</excludeFilterFile> <effort>Max</effort> <plugins> - <plugin><groupId>com.mebigfatguy.fb-contrib</groupId><artifactId>fb-contrib</artifactId><version>${project.version}</version></plugin> + <plugin> + <groupId>com.mebigfatguy.fb-contrib</groupId> + <artifactId>fb-contrib</artifactId> + <version>${project.version}</version> + </plugin> </plugins> </configuration> <executions> <execution> - <goals><goal>check</goal></goals> + <goals> + <goal>check</goal> + </goals> </execution> </executions> </plugin> @@ -375,7 +550,8 @@ <reporting> <plugins> <plugin> - <artifactId>maven-pmd-plugin</artifactId><version>3.6</version> + <artifactId>maven-pmd-plugin</artifactId> + <version>3.6</version> <configuration> <rulesets> <ruleset>/rulesets/java/basic.xml</ruleset> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -48,7 +48,7 @@ public class BogusExceptionDeclaration extends BytecodeScanningDetector { private static final Set<String> safeClasses = UnmodifiableSet.create( - //@formatter:off + //@formatter:off Values.SLASHED_JAVA_LANG_OBJECT, Values.SLASHED_JAVA_LANG_STRING, Values.SLASHED_JAVA_LANG_INTEGER, @@ -275,8 +275,8 @@ */ private void removeThrownExceptionHierarchy(String thrownException) { try { - if (Values.DOTTED_JAVA_LANG_EXCEPTION.equals(thrownException)) { - // Exception can be thrown even tho the method isn't declared to throw Exception in the case of templated Exceptions + if (Values.DOTTED_JAVA_LANG_EXCEPTION.equals(thrownException) || Values.DOTTED_JAVA_LANG_THROWABLE.equals(thrownException)) { + // Exception/Throwable can be thrown even tho the method isn't declared to throw Exception/Throwable in the case of templated Exceptions clearExceptions(); } else { removeException(thrownException); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -29,9 +29,11 @@ import org.apache.bcel.classfile.Constant; import org.apache.bcel.classfile.ConstantClass; +import org.apache.bcel.classfile.ElementValue; import org.apache.bcel.classfile.JavaClass; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import com.mebigfatguy.fbcontrib.utils.ToString; import com.mebigfatguy.fbcontrib.utils.Values; @@ -38,6 +40,7 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.internalAnnotations.DottedClassName; /** * looks for classes that have dependencies on each other in a circular way. Class initialization can be compromised in this scenario, and usually points to a @@ -67,6 +70,22 @@ } @Override + public void visitAnnotation(@DottedClassName String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) { + if (!runtimeVisible) { + return; + } + + for (ElementValue v : map.values()) { + if (v.getElementValueType() == ElementValue.CLASS) { + String annotationClsAttr = SignatureUtils.stripSignature(v.stringifyValue()); + + Set<String> dependencies = getDependenciesForClass(clsName); + dependencies.add(annotationClsAttr); + } + } + } + + @Override public void sawOpcode(int seen) { if ((seen == INVOKESPECIAL) || (seen == INVOKESTATIC) || (seen == INVOKEVIRTUAL)) { processInvoke(); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -1,5 +1,6 @@ package com.mebigfatguy.fbcontrib.detect; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -29,6 +30,7 @@ public class ImmatureClass extends BytecodeScanningDetector { private static final Pattern ARG_PATTERN = Pattern.compile("(arg|parm|param)\\d"); + private static final String PACKAGE_INFO = "package-info"; private static final int MAX_EMPTY_METHOD_SIZE = 2; // ACONST_NULL, ARETURN @@ -59,10 +61,24 @@ JavaClass cls = classContext.getJavaClass(); fieldStatus = FieldStatus.NONE; - if (cls.getPackageName().isEmpty()) { + String packageName = cls.getPackageName(); + if (packageName.isEmpty()) { bugReporter.reportBug(new BugInstance(this, BugType.IMC_IMMATURE_CLASS_NO_PACKAGE.name(), LOW_PRIORITY).addClass(cls)); } + if (!packageName.equals(packageName.toLowerCase(Locale.ENGLISH))) { + bugReporter.reportBug(new BugInstance(this, BugType.IMC_IMMATURE_CLASS_UPPER_PACKAGE.name(), LOW_PRIORITY).addClass(cls)); + } + + String simpleClassName = cls.getClassName(); + int dotPos = simpleClassName.lastIndexOf('.'); + if (dotPos >= 0) { + simpleClassName = simpleClassName.substring(dotPos + 1); + } + if (!Character.isUpperCase(simpleClassName.charAt(0)) && !simpleClassName.contains("$") && !PACKAGE_INFO.equals(simpleClassName)) { + bugReporter.reportBug(new BugInstance(this, BugType.IMC_IMMATURE_CLASS_LOWER_CLASS.name(), LOW_PRIORITY).addClass(cls)); + } + if ((!cls.isAbstract()) && (!cls.isEnum()) && !cls.getClassName().contains("$") && !isTestClass(cls)) { try { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/InvalidConstantArgument.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -61,12 +61,13 @@ ParameterInfo.createIntegerParameterInfo(0, true, EtchedBorder.LOWERED, EtchedBorder.RAISED)), new InvalidPattern("javax/swing/JScrollBar#\\<init\\>\\(I.*\\)V", ParameterInfo.createIntegerParameterInfo(0, true, Adjustable.HORIZONTAL, Adjustable.VERTICAL)), + // TODO: Until travis-ci issue uncovered, add type param as integer on next three. new InvalidPattern("java/lang/Thread#setPriority\\(I\\)V", - new ParameterInfo<>(0, true, Range.createIntegerRange(Thread.MIN_PRIORITY, Thread.MAX_PRIORITY))), + new ParameterInfo<Integer>(0, true, Range.createIntegerRange(Thread.MIN_PRIORITY, Thread.MAX_PRIORITY))), new InvalidPattern("java/math/BigDecimal#divide\\(Ljava/math/BigDecimal;.*I\\)Ljava/math/BigDecimal;", - new ParameterInfo<>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))), + new ParameterInfo<Integer>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))), new InvalidPattern("java/math/BigDecimal#setScale\\(II\\)Ljava/math/BigDecimal;", - new ParameterInfo<>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))), + new ParameterInfo<Integer>(0, false, Range.createIntegerRange(BigDecimal.ROUND_UP, BigDecimal.ROUND_UNNECESSARY))), new InvalidPattern("java/sql/Connection#createStatement\\(II\\)Ljava/sql/Statement;", ParameterInfo.createIntegerParameterInfo(0, true, ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE)), new InvalidPattern("java/sql/Connection#createStatement\\(III?\\)Ljava/sql/Statement;", Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -430,6 +430,8 @@ // to Foo.class.getName() loggingClassName = (String) userValue; } + } else { + return; } } } else if (SIG_STRING_AND_FACTORY_TO_LOG4J_LOGGER.equals(signature) && (stack.getStackDepth() > 1)) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -194,7 +194,7 @@ if (OR_ELSE_METHODS.contains(curCalledMethod)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item itm = stack.getStackItem(0); - if ((itm.getReturnValueOf() != null) && !isTrivialStackOps()) { + if ((itm.getRegisterNumber() < 0) && (itm.getReturnValueOf() != null) && !isTrivialStackOps()) { bugReporter.reportBug(new BugInstance(this, BugType.OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION.name(), NORMAL_PRIORITY) .addClass(this).addMethod(this).addSourceLine(this)); } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2017-05-29 20:54:00 UTC (rev 1822) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -155,8 +155,8 @@ String parms = methodSig.split("\\(|\\)")[1]; if (parms.indexOf(Values.SIG_QUALIFIED_CLASS_SUFFIX_CHAR) >= 0) { - outer: for (JavaClass cls : constrainingClasses) { - Method[] methods = cls.getMethods(); + outer: for (JavaClass constrainCls : constrainingClasses) { + Method[] methods = constrainCls.getMethods(); for (Method m : methods) { if (methodName.equals(m.getName()) && methodSig.equals(m.getSignature())) { methodSignatureIsConstrained = true; @@ -494,9 +494,9 @@ continue; } - JavaClass cls = Repository.lookupClass(clsName); - if (cls.isClass() && (!cls.isAbstract())) { - Map<JavaClass, List<MethodInfo>> definers = getClassDefiners(cls); + JavaClass clz = Repository.lookupClass(clsName); + if (clz.isClass() && (!clz.isAbstract())) { + Map<JavaClass, List<MethodInfo>> definers = getClassDefiners(clz); if (!definers.isEmpty()) { parameterDefiners.put(Integer.valueOf(i + (methodIsStatic ? 0 : 1)), definers); @@ -675,18 +675,18 @@ /** * returns whether this class is used to convert types of some sort, such that you don't want to suggest reducing the class specified to be more generic * - * @param cls + * @param conversionCls * the class to check * @return whether this class is used in conversions */ - private boolean isaConversionClass(JavaClass cls) { - for (AnnotationEntry entry : cls.getAnnotationEntries()) { + private boolean isaConversionClass(JavaClass conversionCls) { + for (AnnotationEntry entry : conversionCls.getAnnotationEntries()) { if (CONVERSION_ANNOTATIONS.contains(entry.getAnnotationType())) { return true; } // this ignores the fact that this class might be a grand child, but meh - if (CONVERSION_SUPER_CLASSES.contains(cls.getSuperclassName())) { + if (CONVERSION_SUPER_CLASSES.contains(conversionCls.getSuperclassName())) { return true; } } Added: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java (rev 0) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ReflectionIssues.java 2017-07-19 21:29:47 UTC (rev 1823) @@ -0,0 +1,89 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2017 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... [truncated message content] |
From: <dbr...@us...> - 2017-05-29 20:54:01
|
Revision: 1822 http://sourceforge.net/p/fb-contrib/code/1822 Author: dbrosius Date: 2017-05-29 20:54:00 +0000 (Mon, 29 May 2017) Log Message: ----------- Version 7.0.2 Added Paths: ----------- tags/v7_0_2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-05-29 20:49:50
|
Revision: 1821 http://sourceforge.net/p/fb-contrib/code/1821 Author: dbrosius Date: 2017-05-29 20:49:46 +0000 (Mon, 29 May 2017) Log Message: ----------- sync 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/findbugsplugin.xsd trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StringifiedTypes.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnnecessaryApiConversion.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseTryWithResources.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java trunk/fb-contrib/src/samples/java/ex/IMC_Sample.java trunk/fb-contrib/src/samples/java/ex/PCAIL_Sample.java trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java trunk/fb-contrib/src/samples/java/ex/STT_Sample.java trunk/fb-contrib/src/test/java/com/mebigfatguy/fbcontrib/utils/SignatureUtilsTest.java Modified: trunk/fb-contrib/.classpath =================================================================== --- trunk/fb-contrib/.classpath 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/.classpath 2017-05-29 20:49:46 UTC (rev 1821) @@ -17,7 +17,7 @@ </classpathentry> <classpathentry kind="lib" path="lib/findbugs-3.0.1.jar" sourcepath="lib/sources/findbugs-3.0.1-sources.jar"/> <classpathentry kind="lib" path="lib/junit-4.12.jar"/> - <classpathentry kind="lib" path="lib/javax.persistence-2.1.1.jar"/> + <classpathentry kind="lib" path="lib/javax.persistence-2.1.1.jar" sourcepath="/home/dave/.m2/repository/org/eclipse/persistence/javax.persistence/2.1.1/javax.persistence-2.1.1-sources.jar"/> <classpathentry kind="lib" path="lib/mockito-all-2.0.2-beta.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/findbugs"/> <classpathentry kind="lib" path="lib/threetenbp-1.3.2.jar"/> Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/build.xml 2017-05-29 20:49:46 UTC (rev 1821) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.0.1" /> + <property name="fb-contrib.version" value="7.0.2" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/etc/bugrank.txt 2017-05-29 20:49:46 UTC (rev 1821) @@ -228,6 +228,7 @@ +0 BugPattern STB_STACKED_TRY_BLOCKS +2 BugPattern STS_SPURIOUS_THREAD_STATES +0 BugPattern STT_STRING_PARSING_A_FIELD ++0 BugPattern STT_TOSTRING_MAP_KEYING +0 BugPattern STT_TOSTRING_STORED_IN_FIELD +0 BugPattern SUA_SUSPICIOUS_UNINITIALIZED_ARRAY +0 BugPattern SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT @@ -249,27 +250,27 @@ +0 BugPattern USBR_UNNECESSARY_STORE_BEFORE_RETURN +0 BugPattern USFW_UNSYNCHRONIZED_SINGLETON_FIELD_WRITES +0 BugPattern USS_USE_STRING_SPLIT -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE -+2 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL -+0 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_ASSERT_USED ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE ++1 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_EQUALS ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL ++3 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL +1 BugPattern UTAO_JUNIT_ASSERTION_ODDITIES_USING_DEPRECATED -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE -+2 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL -+0 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NULL ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ACTUAL_CONSTANT ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_ASSERT_USED ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_BOOLEAN_ASSERT ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_IMPOSSIBLE_NULL ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_INEXACT_DOUBLE ++1 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_NO_ASSERT ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_EQUALS ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL ++3 BugPattern UTAO_TESTNG_ASSERTION_ODDITIES_USE_ASSERT_NULL +0 BugPattern UTA_USE_TO_ARRAY +0 BugPattern UTWR_USE_TRY_WITH_RESOURCES +0 BugPattern UVA_USE_VAR_ARGS Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/etc/findbugs.xml 2017-05-29 20:49:46 UTC (rev 1821) @@ -20,7 +20,7 @@ <!-- Detectors --> -<!-- COMMENT OUT FOR RELEASE +<!-- COMMENT OUT FOR RELEASE <Detector class="com.mebigfatguy.fbcontrib.debug.OCSDebugger" speed="fast"/> @@ -30,7 +30,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -283,7 +283,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OverlyPermissiveMethod" speed="fast" reports="OPM_OVERLY_PERMISSIVE_METHOD" /> - <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes" speed="fast" reports="STT_STRING_PARSING_A_FIELD,STT_TOSTRING_STORED_IN_FIELD" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.StringifiedTypes" speed="fast" reports="STT_STRING_PARSING_A_FIELD,STT_TOSTRING_STORED_IN_FIELD,STT_TOSTRING_MAP_KEYING" /> <Detector class="com.mebigfatguy.fbcontrib.detect.ImmatureClass" speed="moderate" reports="IMC_IMMATURE_CLASS_NO_EQUALS,IMC_IMMATURE_CLASS_NO_HASHCODE,IMC_IMMATURE_CLASS_NO_PACKAGE,IMC_IMMATURE_CLASS_NO_TOSTRING,IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES,IMC_IMMATURE_CLASS_PRINTSTACKTRACE,IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER" /> @@ -311,13 +311,13 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.OptionalIssues" speed="fast" reports="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION,OI_OPTIONAL_ISSUES_USES_DELAYED_EXECUTION,OI_OPTIONAL_ISSUES_CHECKING_REFERENCE,OI_OPTIONAL_ISSUES_PRIMITIVE_VARIANT_PREFERRED"/> - <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion" speed="fast" reports="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT"/> + <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion" speed="fast" reports="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT,UAC_UNNECESSARY_API_CONVERSION_FILE_TO_PATH"/> <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources" speed="fast" reports="UTWR_USE_TRY_WITH_RESOURCES"/> - COMMENT OUT FOR POINT RELEASE --> + COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> @@ -561,6 +561,7 @@ <BugPattern abbrev="OPM" type="OPM_OVERLY_PERMISSIVE_METHOD" category="STYLE" /> <BugPattern abbrev="STT" type="STT_STRING_PARSING_A_FIELD" category="STYLE" /> <BugPattern abbrev="STT" type="STT_TOSTRING_STORED_IN_FIELD" category="STYLE" /> + <BugPattern abbrev="STT" type="STT_TOSTRING_MAP_KEYING" category="STYLE" /> <BugPattern abbrev="SLS" type="SLS_SUSPICIOUS_LOOP_SEARCH" category="CORRECTNESS" /> <BugPattern abbrev="CRF" type="CRF_CONFLATING_RESOURCES_AND_FILES" category="CORRECTNESS" /> <BugPattern abbrev="IMC" type="IMC_IMMATURE_CLASS_IDE_GENERATED_PARAMETER_NAMES" category="STYLE" /> @@ -584,7 +585,7 @@ <BugPattern abbrev="SEO" type="SEO_SUBOPTIMAL_EXPRESSION_ORDER" category="PERFORMANCE"/> <BugPattern abbrev="IOI" type="IOI_DOUBLE_BUFFER_COPY" category="PERFORMANCE"/> <BugPattern abbrev="IOI" type="IOI_COPY_WITH_READER" category="PERFORMANCE"/> - <BugPattern abbrev="IOI" type="IOI_USE_OF_FILE_STREAM_CONSTRUCTORS"/> + <BugPattern abbrev="IOI" type="IOI_USE_OF_FILE_STREAM_CONSTRUCTORS" category="PERFORMANCE"/> <BugPattern abbrev="DMC" type="DMC_DUBIOUS_MAP_COLLECTION" category="CORRECTNESS"/> <BugPattern abbrev="BL" type="BL_BURYING_LOGIC" category="STYLE"/> <BugPattern abbrev="WI" type="WI_DUPLICATE_WIRED_TYPES" category="CORRECTNESS"/> Modified: trunk/fb-contrib/etc/findbugsplugin.xsd =================================================================== --- trunk/fb-contrib/etc/findbugsplugin.xsd 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/etc/findbugsplugin.xsd 2017-05-29 20:49:46 UTC (rev 1821) @@ -22,7 +22,7 @@ <xsd:simpleType name="IdentifierType"> <xsd:restriction base="xsd:string"> - <xsd:pattern value="[A-Za-z0-9_]*"/> + <xsd:pattern value="[A-Za-z0-9_]+"/> </xsd:restriction> </xsd:simpleType> Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/etc/messages.xml 2017-05-29 20:49:46 UTC (rev 1821) @@ -5310,6 +5310,36 @@ </Details> </BugPattern> + <BugPattern type="STT_TOSTRING_MAP_KEYING"> + <ShortDescription>This method uses a concatenated String as a map key</ShortDescription> + <LongDescription>This method {1} uses a concatenated String as a map key</LongDescription> + <Details> + <![CDATA[ + <p>This method builds a key for a map, using a StringBuilder, either implicitly or explicitly. This means the type + of the key is something more t han a String constant, it is a properly formatted String. However, there is no + type based verification that all uses of this key will follow this formatting. It is much better to use a proper, simple, + bean class that holds two (or more fields) so that it is clear what is expected for key use. + </p> + <p> + Example<br/> + instead of + {@code + V v = myMap.get(tableName + "-" + columnName); + } + use + {@code + V v = myMap.get(new ColumnSpec(tableName, columnName)); + } + where ColumnSpec is a simple bean-like class of your creation. The advantages, are + <ul> + <li>The ColumnSpec fully describes what is expected, you need a tableName and columnName</li> + <li>There is no guessing by the programmer what the format is, was it tableName + "_" + columnName?</li> + </ul> + </p> + ]]> + </Details> + </BugPattern> + <BugPattern type="SLS_SUSPICIOUS_LOOP_SEARCH"> <ShortDescription>This method continues a loop after finding an equality condition</ShortDescription> <LongDescription>This method {1} continues a loop after finding an equality condition</LongDescription> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/htdocs/index.shtml 2017-05-29 20:49:46 UTC (rev 1821) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.1 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.2 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/htdocs/repository.html 2017-05-29 20:49:46 UTC (rev 1821) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.0.1</td></tr> + <tr><td><b>Version:</b></td><td>7.0.2</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/pom.xml 2017-05-29 20:49:46 UTC (rev 1821) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.0.1</version> + <version>7.0.2</version> <prerequisites> <maven>2.2.1</maven> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -71,6 +71,8 @@ * @param bugReporter * unused, but required by reflection contract */ + // required for reflection + @SuppressWarnings("PMD.UnusedFormalParameter") public CollectStatistics(BugReporter bugReporter) { Statistics.getStatistics().clear(); } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/debug/Debug.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -20,11 +20,12 @@ package com.mebigfatguy.fbcontrib.debug; import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; public final class Debug { @@ -33,7 +34,7 @@ static { try { out = new PrintStream( - new BufferedOutputStream(new FileOutputStream(new File(System.getProperty("java.io.tmpdir"), "fb-contrib.txt").getPath(), true)), false, + new BufferedOutputStream(Files.newOutputStream(Paths.get(System.getProperty("java.io.tmpdir"), "fb-contrib.txt"), StandardOpenOption.APPEND)), false, StandardCharsets.UTF_8.name()); out.println("===== fb-contrib console ====="); } catch (IOException e) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/DeletingWhileIterating.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -446,23 +446,24 @@ } Comparable<?> groupElement = getGroupElement(itm); - if (groupElement != null) { - int numGroups = collectionGroups.size(); - for (int i = 0; i < numGroups; i++) { - GroupPair groupPair = collectionGroups.get(i); - if (groupPair.containsMember(groupElement)) { - return i; - } + if (groupElement == null) { + return -1; + } + int numGroups = collectionGroups.size(); + for (int i = 0; i < numGroups; i++) { + GroupPair groupPair = collectionGroups.get(i); + if (groupPair.containsMember(groupElement)) { + return i; } + } - if (addIfNotFound) { - GroupPair groupPair = new GroupPair(groupElement, itm.getSignature()); - collectionGroups.add(groupPair); - return collectionGroups.size() - 1; - } + if (!addIfNotFound) { + return -1; } - return -1; + GroupPair groupPair = new GroupPair(groupElement, itm.getSignature()); + collectionGroups.add(groupPair); + return collectionGroups.size() - 1; } private void removeFromCollectionGroup(OpcodeStack.Item itm) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/ImmatureClass.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -42,6 +42,7 @@ private BugReporter bugReporter; private FieldStatus fieldStatus = FieldStatus.NONE; + private boolean classIsJPAEntity; public ImmatureClass(BugReporter reporter) { bugReporter = reporter; @@ -66,6 +67,11 @@ try { boolean clsHasRuntimeAnnotation = classHasRuntimeVisibleAnnotation(cls); + if (clsHasRuntimeAnnotation) { + classIsJPAEntity = classIsJPAEntity(cls); + } else { + classIsJPAEntity = false; + } HEStatus heStatus = HEStatus.UNKNOWN; checkIDEGeneratedParmNames(cls); @@ -76,7 +82,7 @@ boolean fieldHasRuntimeAnnotation = fieldHasRuntimeVisibleAnnotation(f); if (!fieldHasRuntimeAnnotation) { /* only report one of these, so as not to flood the report */ - if (!hasMethodInHierarchy(cls, Values.TOSTRING, SignatureBuilder.SIG_VOID_TO_STRING)) { + if (!classIsJPAEntity && !hasMethodInHierarchy(cls, Values.TOSTRING, SignatureBuilder.SIG_VOID_TO_STRING)) { bugReporter.reportBug(new BugInstance(this, BugType.IMC_IMMATURE_CLASS_NO_TOSTRING.name(), LOW_PRIORITY).addClass(cls)); heStatus = HEStatus.NOT_NEEDED; break; @@ -206,6 +212,26 @@ } /** + * returns whether this class is a JPA Entity, as such it shouldn't really have a toString() + * + * @param cls + * the class to check + * @return if the class is a jpa entity + */ + private static boolean classIsJPAEntity(JavaClass cls) { + AnnotationEntry[] annotations = cls.getAnnotationEntries(); + if (annotations != null) { + for (AnnotationEntry annotation : annotations) { + if ("Ljavax/persistence/Entity;".equals(annotation.getAnnotationType())) { + return true; + } + } + } + + return false; + } + + /** * looks to see the field has a runtime visible annotation, if it does it might be autowired or some other mechanism attached that makes them less * interesting for a toString call. * Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -261,6 +261,10 @@ if (invokeCount == 1) { FQMethod method = activeStackOps.getLast().getMethod(); + if (method == null) { + return false; + } + if ("valueOf".equals(method.getMethodName()) && method.getClassName().startsWith("java/lang/")) { return true; } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OverlyPermissiveMethod.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -376,7 +376,9 @@ } } } else { - throw new RuntimeException("Incompatible bcel version"); + throw new RuntimeException( + "Incompatible bcel version, apparently bcel has been upgraded to not use 'Unknown' for 'BootstrapMethods', but uses: " + + a.getName()); } return null; } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossibleConstantAllocationInLoop.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -62,6 +62,7 @@ private Map<Integer, Integer> storedAllocations; private int nextAllocationNumber; private List<SwitchInfo> switchInfos; + private int nextTernaryTarget; public PossibleConstantAllocationInLoop(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -89,6 +90,7 @@ allocations.clear(); storedAllocations.clear(); nextAllocationNumber = 1; + nextTernaryTarget = -1; super.visitCode(obj); for (AllocationInfo info : allocations.values()) { @@ -106,9 +108,30 @@ Integer sawAllocationNumber = null; try { + if ((nextTernaryTarget == getPC()) && (stack.getStackDepth() > 0)) { + OpcodeStack.Item itm = stack.getStackItem(0); + sawAllocationNumber = (Integer) itm.getUserValue(); + sawAllocation = sawAllocationNumber != null; + nextTernaryTarget = -1; + } + stack.precomputation(this); + if ((sawAllocation) && (stack.getStackDepth() > 0)) { + OpcodeStack.Item itm = stack.getStackItem(0); + itm.setUserValue(sawAllocationNumber); + sawAllocationNumber = null; + sawAllocation = false; + } + switch (seen) { + case GOTO: + case GOTO_W: + if ((getBranchOffset() > 0) && (stack.getStackDepth() > 0)) { + // ternary + nextTernaryTarget = getBranchTarget(); + } + // $FALL-THROUGH$ case IFEQ: case IFNE: case IFLT: @@ -125,8 +148,7 @@ case IF_ACMPNE: case IFNULL: case IFNONNULL: - case GOTO: - case GOTO_W: + processBranch(); break; @@ -144,6 +166,7 @@ case INVOKEINTERFACE: case INVOKEVIRTUAL: case INVOKESTATIC: + case INVOKEDYNAMIC: String signature = getSigConstantOperand(); int numParameters = SignatureUtils.getNumParameters(signature); if (stack.getStackDepth() >= numParameters) { @@ -154,7 +177,7 @@ allocations.remove(allocation); } } - if (((seen == INVOKEINTERFACE) || (seen == INVOKEVIRTUAL) || (seen == INVOKESPECIAL)) + if (((seen == INVOKEINTERFACE) || (seen == INVOKEVIRTUAL) || (seen == INVOKESPECIAL) || (seen == INVOKEDYNAMIC)) // ignore possible method chaining && (stack.getStackDepth() > numParameters)) { OpcodeStack.Item item = stack.getStackItem(numParameters); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -34,9 +34,11 @@ import com.mebigfatguy.fbcontrib.collect.MethodInfo; import com.mebigfatguy.fbcontrib.collect.Statistics; import com.mebigfatguy.fbcontrib.utils.BugType; +import com.mebigfatguy.fbcontrib.utils.FQMethod; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; import com.mebigfatguy.fbcontrib.utils.ToString; +import com.mebigfatguy.fbcontrib.utils.UnmodifiableSet; import com.mebigfatguy.fbcontrib.utils.Values; import edu.umd.cs.findbugs.BugInstance; @@ -151,6 +153,27 @@ } } + private static final Set<FQMethod> commonMethods = UnmodifiableSet.create( + // @formatter:off + new FQMethod("java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;"), + new FQMethod("java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;"), + new FQMethod("java/lang/Character", "valueOf", "(C)Ljava/lang/Character;"), + new FQMethod("java/lang/Short", "valueOf", "(S)Ljava/lang/Short;"), + new FQMethod("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;"), + new FQMethod("java/lang/Long", "valueOf", "(J)Ljava/lang/Long;"), + new FQMethod("java/lang/Float", "valueOf", "(F)Ljava/lang/Float;"), + new FQMethod("java/lang/Double", "valueOf", "(D)Ljava/lang/Double;"), + new FQMethod("java/lang/Boolean", "booleanValue", "()Z"), + new FQMethod("java/lang/Byte", "byteValue", "()B"), + new FQMethod("java/lang/Character", "charValue", "()C"), + new FQMethod("java/lang/Short", "shortValue", "()S"), + new FQMethod("java/lang/Integer", "intValue", "()I"), + new FQMethod("java/lang/Long", "longValue", "()J"), + new FQMethod("java/lang/Float", "floatValue", "()F"), + new FQMethod("java/lang/Double", "doubleValue", "()D") + // @formatter:on + ); + private final BugReporter bugReporter; private OpcodeStack stack = null; private Map<Integer, MethodCall> localMethodCalls = null; @@ -347,7 +370,8 @@ if (mc != null) { if (!signature.endsWith(Values.SIG_VOID) && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) - && !isRiskyName(className, methodName)) { + && !isRiskyName(className, methodName) + && !commonMethods.contains(new FQMethod(getClassConstantOperand(), methodName, signature))) { Object[] parms = mc.getParms(); if (Arrays.equals(parms, parmConstants)) { int ln = getLineNumber(pc); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -972,7 +972,7 @@ Object o = item.getConstant(); if (o instanceof Integer) { int parm = ((Integer) o).intValue(); - if ((parm > 32) && (parm < 127) && (parm != 64) && ((parm % 10) != 0) && ((parm % 5) != 0)) { + if ((parm > 32) && (parm < 127) && (parm != 64) && (parm != 48) && ((parm % 5) != 0)) { bugReporter.reportBug(new BugInstance(this, BugType.SPP_NO_CHAR_SB_CTOR.name(), LOW_PRIORITY).addClass(this).addMethod(this) .addSourceLine(this)); } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StringifiedTypes.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StringifiedTypes.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/StringifiedTypes.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -37,6 +37,7 @@ import edu.umd.cs.findbugs.OpcodeStack; import edu.umd.cs.findbugs.OpcodeStack.CustomUserValue; import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.ba.XMethod; /** * looks for string fields that appear to be built with parsing or calling toString() on another object, or from objects that are fields. @@ -88,6 +89,8 @@ } private static final String FROM_FIELD = "FROM_FIELD"; + private static final FQMethod MAP_PUT = new FQMethod(Values.SLASHED_JAVA_UTIL_MAP, "put", SignatureBuilder.SIG_TWO_OBJECTS_TO_OBJECT); + private BugReporter bugReporter; private OpcodeStack stack; private BitSet toStringStringBuilders; @@ -190,7 +193,16 @@ if (checkParms != null) { OpcodeStack.Item item = stack.getStackItem(numParameters); if (item.getXField() == null) { - checkParms = null; + if (MAP_PUT.equals(cm)) { + OpcodeStack.Item itm = stack.getStackItem(1); + XMethod xm = itm.getReturnValueOf(); + if (xm != null) { + if (Values.DOTTED_JAVA_LANG_STRINGBUILDER.equals(xm.getClassName())) { + bugReporter.reportBug(new BugInstance(this, BugType.STT_TOSTRING_MAP_KEYING.name(), NORMAL_PRIORITY).addClass(this) + .addMethod(this).addSourceLine(this)); + } + } + } } else { for (int parm : checkParms) { if ((parm >= 0) && Values.TOSTRING.equals(stack.getStackItem(parm).getUserValue())) { Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnnecessaryApiConversion.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnnecessaryApiConversion.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UnnecessaryApiConversion.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -90,6 +90,9 @@ } } break; + + default: + break; } } finally { stack.sawOpcode(this, seen); Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseEnumCollections.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -223,11 +223,7 @@ // If the cls implements any interface, it's possible the collection // is based on that interface, so ignore - if (cls.getInterfaces().length == 0) { - return true; - } - - return false; + return cls.getInterfaces().length == 0; } /** Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseTryWithResources.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseTryWithResources.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/UseTryWithResources.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -59,6 +59,7 @@ private int lastNullCheckedReg; private int bugPC; private int closePC; + private int suppressedPC; private State state; public UseTryWithResources(BugReporter bugReporter) { @@ -105,12 +106,23 @@ lastNullCheckedReg = -1; bugPC = -1; closePC = -1; + suppressedPC = -1; super.visitCode(obj); + + if ((closePC >= 0) && (suppressedPC < 0)) { + bugReporter.reportBug(new BugInstance(this, BugType.UTWR_USE_TRY_WITH_RESOURCES.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) + .addSourceLine(this, bugPC)); + } } } @Override public void sawOpcode(int seen) { + + if (suppressedPC >= 0) { + return; + } + try { int pc = getPC(); Iterator<TryBlock> it = finallyBlocks.values().iterator(); @@ -127,13 +139,6 @@ } } - if ((closePC >= 0) && (closePC <= pc)) { - bugReporter.reportBug(new BugInstance(this, BugType.UTWR_USE_TRY_WITH_RESOURCES.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) - .addSourceLine(this, bugPC)); - closePC = -1; - bugPC = -1; - } - if (OpcodeUtils.isAStore(seen)) { regStoredPCs.put(Integer.valueOf(getRegisterOperand()), Integer.valueOf(pc)); } @@ -169,11 +174,12 @@ lastNullCheckedReg = -1; } - if ((((bugPC >= 0) && (seen == INVOKEVIRTUAL)) || (seen == INVOKEINTERFACE)) && "addSuppressed".equals(getNameConstantOperand()) + if ((bugPC >= 0) && ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) && "addSuppressed".equals(getNameConstantOperand()) && SignatureBuilder.SIG_THROWABLE_TO_VOID.equals(getSigConstantOperand()) && Repository.lookupClass(getClassConstantOperand()).instanceOf(throwableClass)) { closePC = -1; bugPC = -1; + suppressedPC = getPC(); } } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/BugType.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -266,6 +266,7 @@ STB_STACKED_TRY_BLOCKS, STS_SPURIOUS_THREAD_STATES, STT_STRING_PARSING_A_FIELD, + STT_TOSTRING_MAP_KEYING, STT_TOSTRING_STORED_IN_FIELD, SUA_SUSPICIOUS_UNINITIALIZED_ARRAY, SWCO_SUSPICIOUS_WAIT_ON_CONCURRENT_OBJECT, Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureBuilder.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -122,7 +122,7 @@ public SignatureBuilder withReturnType(String type) { if ((type == null) || (type.length() == 0)) { - throw new IllegalArgumentException("Missing return type; did you mean 'withoutReturnType'?"); + throw new IllegalArgumentException("Missing return type; did you mean 'withoutReturnType'? -- " + this); } returnType = SignatureUtils.classToSignature(type); return this; @@ -130,7 +130,7 @@ public SignatureBuilder withReturnType(Class<?> type) { if (type == null) { - throw new IllegalArgumentException("Missing return type; did you mean 'withoutReturnType'?"); + throw new IllegalArgumentException("Missing return type; did you mean 'withoutReturnType'? -- " + this); } return withReturnType(type.getName()); } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -208,6 +208,7 @@ i = semiPos; } else if (isWonkyEclipseSignature(methodSignature, i)) { sigStart++; + continue; } else { parmSignature = methodSignature.substring(sigStart, i + 1); slotIndexToParms.put(Integer.valueOf(slot), parmSignature); @@ -244,9 +245,7 @@ int semiPos = methodSignature.indexOf(Values.SIG_QUALIFIED_CLASS_SUFFIX_CHAR, i + 1); parmSignatures.add(methodSignature.substring(sigStart, semiPos + 1)); i = semiPos; - } else if (isWonkyEclipseSignature(methodSignature, i)) { - sigStart++; - } else { + } else if (!isWonkyEclipseSignature(methodSignature, i)) { parmSignatures.add(methodSignature.substring(sigStart, i + 1)); } sigStart = i + 1; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/utils/Values.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -75,6 +75,8 @@ public static final String DOTTED_JAVA_LANG_ERROR = "java.lang.Error"; @DottedClassName public static final String DOTTED_JAVA_LANG_INTEGER = "java.lang.Integer"; + @DottedClassName + public static final String DOTTED_JAVA_LANG_STRINGBUILDER = "java.lang.StringBuilder"; @SlashedClassName public static final String SLASHED_JAVA_LANG_OBJECT = "java/lang/Object"; Modified: trunk/fb-contrib/src/samples/java/ex/IMC_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/IMC_Sample.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/samples/java/ex/IMC_Sample.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -9,6 +9,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.persistence.Entity; + import org.junit.Assert; import org.junit.Test; import org.objectweb.asm.AnnotationVisitor; @@ -64,6 +66,12 @@ } } +@Entity +class FPIMCEntity { + private int id; + private String name; +} + class MyVisitor extends AnnotationVisitor { String name; Modified: trunk/fb-contrib/src/samples/java/ex/PCAIL_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/PCAIL_Sample.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/samples/java/ex/PCAIL_Sample.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -1,8 +1,11 @@ package ex; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -154,6 +157,16 @@ fooList.add(foo); } } + + public void fpLambdaWithTernary(Deque<String> stack, Map<String, List<String>> details) { + while (!stack.isEmpty()) { + String s = stack.pop(); + List<String> detail = details.get(s); + detail = detail != null ? detail : new ArrayList<String>(); + Collections.reverse(detail); + detail.forEach(stack::push); + } + } private PCAIL_Sample builder() { return this; Modified: trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/samples/java/ex/PRMC_Sample.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -1,4 +1,5 @@ package ex; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; @@ -140,7 +141,7 @@ System.out.println(foo.toString()); } } - + public void fpWithGenericReturn() { Set<String> s = ImmutableSet.of(); Set<Integer> i = ImmutableSet.of(); @@ -150,6 +151,17 @@ throw new RuntimeException("kaboom!"); } + public void fpIgnoreCommonBoxing(Integer i) { + setTwo(i, i); + setTwo(3.1, 3.1); + } + + public void setTwo(int i, int j) { + } + + public void setTwo(Double d, Double e) { + } + public void setValue(int i) { } Modified: trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/samples/java/ex/SPP_Sample.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -1,4 +1,5 @@ package ex; + import java.io.Serializable; import java.lang.reflect.Array; import java.math.BigDecimal; @@ -31,6 +32,7 @@ private static final double e = 2.72; public static final String FALSE_POSITIVE = "INTERN_OK_HERE".intern(); private static final String LIT = "lit"; + private static final int BIG_SIZE = 48; static enum Flap { Smack, Jack @@ -435,6 +437,10 @@ sqlQuery.setString(1, name + "%"); } } + + public void fpIssue199SBWithNum() { + StringBuilder sb = new StringBuilder(BIG_SIZE); + } } interface FPInterfaceWithSerialVer extends Serializable { Modified: trunk/fb-contrib/src/samples/java/ex/STT_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/STT_Sample.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/samples/java/ex/STT_Sample.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -1,4 +1,5 @@ package ex; + import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -36,6 +37,12 @@ return s.substring(0, colonPos); } + public Map<String, String> testLocalMapKeyedByStringifiedType(String a, String b) { + Map<String, String> s = new HashMap<>(); + s.put(a + b, b + a); + return s; + } + public void fpTestToStringToFieldSB(String s) { val = s + "wow"; } Modified: trunk/fb-contrib/src/test/java/com/mebigfatguy/fbcontrib/utils/SignatureUtilsTest.java =================================================================== --- trunk/fb-contrib/src/test/java/com/mebigfatguy/fbcontrib/utils/SignatureUtilsTest.java 2017-04-22 21:28:01 UTC (rev 1820) +++ trunk/fb-contrib/src/test/java/com/mebigfatguy/fbcontrib/utils/SignatureUtilsTest.java 2017-05-29 20:49:46 UTC (rev 1821) @@ -75,11 +75,24 @@ } @Test + public void shouldGetParameterSlotsAndSignaturesForWonkyEclipseMethod() { + Map<Integer, String> expected = new HashMap<>(2); + expected.put(0, "I"); + expected.put(1, "Ljava/util/List;"); + assertEquals(SignatureUtils.getParameterSlotAndSignatures(true, "add(I!+Ljava/util/List;)Ljava/lang/Object;"), expected); + } + + @Test public void shouldGetParameterSignatures() { assertEquals(SignatureUtils.getParameterSignatures("add(ILjava/lang/Object;)Ljava/lang/Object;"), Arrays.asList("I", "Ljava/lang/Object;")); } @Test + public void shouldGetParameterSignaturesWithWonkyEclipseMethod() { + assertEquals(SignatureUtils.getParameterSignatures("add(I!+Ljava/util/List;)Ljava/lang/Object;"), Arrays.asList("I", "Ljava/util/List;")); + } + + @Test public void shouldCountParameterSignatures() { assertEquals(SignatureUtils.getNumParameters("add(ILjava/lang/Object;)Ljava/lang/Object;"), 2); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-04-22 21:28:03
|
Revision: 1820 http://sourceforge.net/p/fb-contrib/code/1820 Author: dbrosius Date: 2017-04-22 21:28:01 +0000 (Sat, 22 Apr 2017) Log Message: ----------- Version 7.0.1 Added Paths: ----------- tags/v7_0_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-04-22 21:22:21
|
Revision: 1819 http://sourceforge.net/p/fb-contrib/code/1819 Author: dbrosius Date: 2017-04-22 21:22:18 +0000 (Sat, 22 Apr 2017) Log Message: ----------- sync from github Modified Paths: -------------- trunk/fb-contrib/build.xml trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/htdocs/index.shtml trunk/fb-contrib/htdocs/repository.html trunk/fb-contrib/pom.xml trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/RuntimeExceptionDeclared.java trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java trunk/fb-contrib/src/samples/java/ex/IOI_Sample.java Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/build.xml 2017-04-22 21:22:18 UTC (rev 1819) @@ -31,7 +31,7 @@ <property name="javac.debug" value="on" /> <property name="test_reports.dir" value="${target.dir}/reports/test"/> - <property name="fb-contrib.version" value="7.0.0" /> + <property name="fb-contrib.version" value="7.0.1" /> <property name="sonatype.dir" value="${user.home}/.fb-contrib-${fb-contrib.version}-sonatype" /> Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/etc/findbugs.xml 2017-04-22 21:22:18 UTC (rev 1819) @@ -30,7 +30,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.BloatedAssignmentScope" speed="fast" reports="BAS_BLOATED_ASSIGNMENT_SCOPE" hidden="true" /> - COMMENT OUT FOR RELEASE --> + COMMENT OUT FOR RELEASE --> <Detector class="com.mebigfatguy.fbcontrib.collect.CollectStatistics" speed="fast" reports="" hidden="true" /> @@ -313,11 +313,11 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnnecessaryApiConversion" speed="fast" reports="UAC_UNNECESSARY_API_CONVERSION_DATE_TO_INSTANT"/> - <!-- COMMENT OUT FOR POINT RELEASE --> + <!-- COMMENT OUT FOR POINT RELEASE <Detector class="com.mebigfatguy.fbcontrib.detect.UseTryWithResources" speed="fast" reports="UTWR_USE_TRY_WITH_RESOURCES"/> - <!-- COMMENT OUT FOR POINT RELEASE --> + COMMENT OUT FOR POINT RELEASE --> <!-- BugPattern --> Modified: trunk/fb-contrib/htdocs/index.shtml =================================================================== --- trunk/fb-contrib/htdocs/index.shtml 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/htdocs/index.shtml 2017-04-22 21:22:18 UTC (rev 1819) @@ -68,7 +68,7 @@ </li> </ul> </p> - <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.0 available for download + <p style="font-weight: bold;">The latest version of fb-contrib is 7.0.1 available for download <a href="http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22fb-contrib%22">here</a>.</p> <p style="font-weight: bold;">This version requires FindBugs 3.0.1 or better</p> <p style="font-weight: bold;">Please note that active development for this project is now done on Modified: trunk/fb-contrib/htdocs/repository.html =================================================================== --- trunk/fb-contrib/htdocs/repository.html 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/htdocs/repository.html 2017-04-22 21:22:18 UTC (rev 1819) @@ -22,7 +22,7 @@ <table style="margin-left: 40px; background-color: #A0A0FF; padding: 20px; border-width: 1px; border-style: outset; border-color: #000000;"> <tr><td><b>GroupId:</b></td><td>com.mebigfatguy.fb-contrib</td></tr> <tr><td><b>ArtifactId:</b></td><td>fb-contrib</td></tr> - <tr><td><b>Version:</b></td><td>7.0.0</td></tr> + <tr><td><b>Version:</b></td><td>7.0.1</td></tr> </table> </div> Modified: trunk/fb-contrib/pom.xml =================================================================== --- trunk/fb-contrib/pom.xml 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/pom.xml 2017-04-22 21:22:18 UTC (rev 1819) @@ -8,7 +8,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.mebigfatguy.fb-contrib</groupId> <artifactId>fb-contrib</artifactId> - <version>7.0.0</version> + <version>7.0.1</version> <prerequisites> <maven>2.2.1</maven> Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/BloatedSynchronizedBlock.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -45,8 +45,9 @@ * variables, and not member variables, or this. */ public class BloatedSynchronizedBlock extends BytecodeScanningDetector { + private static final String BSB_MIN_SAFE_CODE_SIZE = "fb-contrib.bsb.minsize"; + private final BugReporter bugReporter; - private static final String BSB_MIN_SAFE_CODE_SIZE = "fb-contrib.bsb.minsize"; private OpcodeStack stack; private BitSet unsafeAliases; private Map<Integer, Integer> branchInfo; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/FindClassCircularDependencies.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -233,6 +233,9 @@ return removedClass; } + /** + * finds class dependency loops in a directed graph + */ static class LoopFinder { private Map<String, Set<String>> dGraph = null; Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IOIssues.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -170,6 +170,16 @@ return IOIUserValue.BUFFER; } else if ("java.io.FileInputStream".equals(clsName) || "java.io.FileOutputStream".equals(clsName)) { if (clsVersion >= Constants.MAJOR_1_7) { + if (!getMethod().isStatic()) { + String sig = getSigConstantOperand(); + int numParms = SignatureUtils.getNumParameters(sig); + if (stack.getStackDepth() > numParms) { + OpcodeStack.Item itm = stack.getStackItem(numParms); + if (itm.getRegisterNumber() == 0) { + return null; + } + } + } bugReporter.reportBug(new BugInstance(this, BugType.IOI_USE_OF_FILE_STREAM_CONSTRUCTORS.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addSourceLine(this)); } Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/IncorrectInternalClassUse.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -38,7 +38,6 @@ * looks for classes that use objects from com.sun.xxx packages. As these are internal to sun and subject to change, this should not be done. */ public class IncorrectInternalClassUse implements Detector { - private final BugReporter bugReporter; private static final Set<String> internalPackages = UnmodifiableSet.create( // @formatter:off @@ -77,6 +76,8 @@ // @formatter:on ); + private final BugReporter bugReporter; + /** * constructs a IICU detector given the reporter to report bugs on * Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/OptionalIssues.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -50,7 +50,7 @@ @CustomUserValue public class OptionalIssues extends BytecodeScanningDetector { - private Set<String> BOXED_OPTIONAL_TYPES = UnmodifiableSet.create("Ljava/lang/Integer;", "Ljava/lang/Long;", "Ljava/lang/Double;"); + private static Set<String> BOXED_OPTIONAL_TYPES = UnmodifiableSet.create("Ljava/lang/Integer;", "Ljava/lang/Long;", "Ljava/lang/Double;"); private static final FQMethod OPTIONAL_OR_ELSE_METHOD = new FQMethod("java/util/Optional", "orElse", "(Ljava/lang/Object;)Ljava/lang/Object;"); private static final FQMethod OPTIONAL_OR_ELSE_GET_METHOD = new FQMethod("java/util/Optional", "orElseGet", Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/RuntimeExceptionDeclared.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/RuntimeExceptionDeclared.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/RuntimeExceptionDeclared.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -42,7 +42,6 @@ * code, and not propagated. */ public class RuntimeExceptionDeclared extends PreorderVisitor implements Detector { - private final BugReporter bugReporter; private static JavaClass runtimeExceptionClass; static { @@ -53,6 +52,7 @@ } } + private final BugReporter bugReporter; private final Set<String> runtimeExceptions = new HashSet<>(); /** Modified: trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java =================================================================== --- trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/main/java/com/mebigfatguy/fbcontrib/detect/SyncCollectionIterators.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -46,7 +46,6 @@ * unsafe. When iterators are to be used, synchronization should be done manually. */ public class SyncCollectionIterators extends BytecodeScanningDetector { - private final BugReporter bugReporter; private static final Set<String> synchCollectionNames = UnmodifiableSet.create("synchronizedSet", "synchronizedMap", "synchronizedList", "synchronizedSortedSet", "synchronizedSortedMap"); @@ -56,6 +55,7 @@ SEEN_NOTHING, SEEN_SYNC, SEEN_LOAD } + private final BugReporter bugReporter; private State state; private Set<String> memberCollections; private BitSet localCollections; Modified: trunk/fb-contrib/src/samples/java/ex/IOI_Sample.java =================================================================== --- trunk/fb-contrib/src/samples/java/ex/IOI_Sample.java 2017-04-15 00:00:24 UTC (rev 1818) +++ trunk/fb-contrib/src/samples/java/ex/IOI_Sample.java 2017-04-22 21:22:18 UTC (rev 1819) @@ -44,4 +44,12 @@ } } } + + class FPBofoStream extends FileInputStream { + + public FPBofoStream(File f) throws IOException { + super(f); + } + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2017-04-15 00:00:26
|
Revision: 1818 http://sourceforge.net/p/fb-contrib/code/1818 Author: dbrosius Date: 2017-04-15 00:00:24 +0000 (Sat, 15 Apr 2017) Log Message: ----------- Version 7.0.0 Added Paths: ----------- tags/v7_0_0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |