fb-contrib-commit Mailing List for fb-contrib (Page 20)
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...> - 2009-10-08 12:58:53
|
Revision: 1366 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1366&view=rev Author: dbrosius Date: 2009-10-08 12:58:39 +0000 (Thu, 08 Oct 2009) Log Message: ----------- don't report OCP for abstract classes Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2009-10-06 16:35:24 UTC (rev 1365) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2009-10-08 12:58:39 UTC (rev 1366) @@ -135,10 +135,6 @@ if (methodSignatureIsConstrained) return; - parameterDefiners.clear(); - usedParameters.clear(); - stack.resetForMethodEntry(this); - if (obj.getCode() == null) return; Method m = getMethod(); @@ -151,6 +147,10 @@ if (parmCount == 0) return; + parameterDefiners.clear(); + usedParameters.clear(); + stack.resetForMethodEntry(this); + if (buildParameterDefiners()) { super.visitCode(obj); reportBugs(); @@ -315,7 +315,7 @@ continue; JavaClass cls = Repository.lookupClass(clsName); - if (cls.isClass()) { + if (cls.isClass() && (!cls.isAbstract())) { Map<JavaClass, List<MethodInfo>> definers = getClassDefiners(cls); if (definers.size() > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 16:35:31
|
Revision: 1365 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1365&view=rev Author: dbrosius Date: 2009-10-06 16:35:24 +0000 (Tue, 06 Oct 2009) Log Message: ----------- remove space Modified Paths: -------------- trunk/fb-contrib/etc/bugrank.txt Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2009-10-06 05:18:16 UTC (rev 1364) +++ trunk/fb-contrib/etc/bugrank.txt 2009-10-06 16:35:24 UTC (rev 1365) @@ -123,5 +123,4 @@ 0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING 0 BugPattern OC_OVERZEALOUS_CASTING 0 BugPattern PDP_POORLY_DEFINED_PARAMETER -0 BugPattern NSE_NON_SYMMETRIC_EQUALS - +0 BugPattern NSE_NON_SYMMETRIC_EQUALS \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 05:18:22
|
Revision: 1364 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1364&view=rev Author: dbrosius Date: 2009-10-06 05:18:16 +0000 (Tue, 06 Oct 2009) Log Message: ----------- @Override Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2009-10-06 05:12:58 UTC (rev 1363) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/CollectStatistics.java 2009-10-06 05:18:16 UTC (rev 1364) @@ -28,7 +28,7 @@ { private int numMethodCalls; - public CollectStatistics(BugReporter bugReporter) { + public CollectStatistics(@SuppressWarnings("unused") BugReporter bugReporter) { Statistics.getStatistics().clear(); } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java 2009-10-06 05:12:58 UTC (rev 1363) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentKeyNameCasing.java 2009-10-06 05:18:16 UTC (rev 1364) @@ -58,6 +58,7 @@ * implements the visitor to create the opcode stack * @param classContext the context object of the currently parsed class */ + @Override public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); @@ -71,6 +72,7 @@ * implements the visitor to reset the opcode stack for a new method * @param obj the context object of the currently parsed code block */ + @Override public void visitCode(Code obj) { stack.resetForMethodEntry(this); super.visitCode(obj); @@ -81,6 +83,7 @@ * and collect what the name of the key is. * @param seen the opcode of the currently parsed instruction */ + @Override public void sawOpcode(int seen) { try { if (seen == INVOKEINTERFACE) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java 2009-10-06 05:12:58 UTC (rev 1363) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java 2009-10-06 05:18:16 UTC (rev 1364) @@ -58,6 +58,7 @@ * implements the visitor to create the stack object * @param classContext the context object of the currently parsed class */ + @Override public void visitClassContext(ClassContext classContext) { try { stack = new OpcodeStack(); @@ -71,6 +72,7 @@ * implements the visitor to see if this method is equals(Object o) * @param obj the context object of the currently parsed code block */ + @Override public void visitCode(Code obj) { Method m = getMethod(); String name = m.getName(); @@ -98,6 +100,7 @@ * enter instances in a map for further processing in doReport. * @param seen the opcode of the currently parsed instruction */ + @Override public void sawOpcode(int seen) { try { if (seen == CHECKCAST) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 05:13:05
|
Revision: 1363 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1363&view=rev Author: dbrosius Date: 2009-10-06 05:12:58 +0000 (Tue, 06 Oct 2009) Log Message: ----------- javadoc copyright to 2009 Modified Paths: -------------- trunk/fb-contrib/build.xml Modified: trunk/fb-contrib/build.xml =================================================================== --- trunk/fb-contrib/build.xml 2009-10-06 05:08:44 UTC (rev 1362) +++ trunk/fb-contrib/build.xml 2009-10-06 05:12:58 UTC (rev 1363) @@ -152,7 +152,7 @@ destdir="${javadoc.dir}" windowtitle="fb-contrib api"> <doctitle><![CDATA[<h1>fb-contrib javadoc</h1>]]></doctitle> - <bottom><![CDATA[<i>Copyright © 2005-2008 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> + <bottom><![CDATA[<i>Copyright © 2005-2009 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom> </javadoc> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 05:08:50
|
Revision: 1362 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1362&view=rev Author: dbrosius Date: 2009-10-06 05:08:44 +0000 (Tue, 06 Oct 2009) Log Message: ----------- javadoc for collect package Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/package.html Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/package.html =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/package.html (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/package.html 2009-10-06 05:08:44 UTC (rev 1362) @@ -0,0 +1,5 @@ +<html> + <body> + provides first pass detector global statistics gathering + </body> +</html> \ No newline at end of file Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/collect/package.html ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 04:45:39
|
Revision: 1361 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1361&view=rev Author: dbrosius Date: 2009-10-06 04:45:26 +0000 (Tue, 06 Oct 2009) Log Message: ----------- use Integer14 Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-10-06 04:44:47 UTC (rev 1360) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-10-06 04:45:26 UTC (rev 1361) @@ -27,6 +27,7 @@ import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.generic.Type; +import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import com.mebigfatguy.fbcontrib.utils.SignatureUtils; @@ -164,7 +165,7 @@ || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); - Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)); + Integer reg = Integer14.valueOf(RegisterUtils.getAStoreReg(this, seen)); if (item.getUserValue() != null) { XMethod xm = item.getReturnValueOf(); if (xm != null) { @@ -178,7 +179,7 @@ } } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { - Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)); + Integer reg = Integer14.valueOf(RegisterUtils.getAStoreReg(this, seen)); methodPackage = toStringRegisters.get(reg); } } catch (ClassNotFoundException cnfe) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 04:44:52
|
Revision: 1360 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1360&view=rev Author: dbrosius Date: 2009-10-06 04:44:47 +0000 (Tue, 06 Oct 2009) Log Message: ----------- use Integer14 Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-10-06 04:42:35 UTC (rev 1359) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BloatedAssignmentScope.java 2009-10-06 04:44:47 UTC (rev 1360) @@ -386,7 +386,7 @@ int reg = caller.getRegisterNumber(); if (reg >= 0) { - return Integer.valueOf(reg); + return Integer14.valueOf(reg); } /* We ignore the possibility of two fields with the same name in different classes */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 04:42:43
|
Revision: 1359 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1359&view=rev Author: dbrosius Date: 2009-10-06 04:42:35 +0000 (Tue, 06 Oct 2009) Log Message: ----------- add NSE Modified Paths: -------------- trunk/fb-contrib/etc/bugrank.txt Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2009-10-06 04:41:21 UTC (rev 1358) +++ trunk/fb-contrib/etc/bugrank.txt 2009-10-06 04:42:35 UTC (rev 1359) @@ -123,4 +123,5 @@ 0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING 0 BugPattern OC_OVERZEALOUS_CASTING 0 BugPattern PDP_POORLY_DEFINED_PARAMETER +0 BugPattern NSE_NON_SYMMETRIC_EQUALS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 04:41:28
|
Revision: 1358 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1358&view=rev Author: dbrosius Date: 2009-10-06 04:41:21 +0000 (Tue, 06 Oct 2009) Log Message: ----------- Modified Paths: -------------- trunk/fb-contrib/etc/bugrank.txt Modified: trunk/fb-contrib/etc/bugrank.txt =================================================================== --- trunk/fb-contrib/etc/bugrank.txt 2009-10-06 04:40:55 UTC (rev 1357) +++ trunk/fb-contrib/etc/bugrank.txt 2009-10-06 04:41:21 UTC (rev 1358) @@ -122,4 +122,5 @@ 0 BugPattern ITU_INAPPROPRIATE_TOSTRING_USE 0 BugPattern IKNC_INCONSISTENT_HTTP_PARAM_CASING 0 BugPattern OC_OVERZEALOUS_CASTING -0 BugPattern PDP_POORLY_DEFINED_PARAMETER \ No newline at end of file +0 BugPattern PDP_POORLY_DEFINED_PARAMETER + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 04:41:03
|
Revision: 1357 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1357&view=rev Author: dbrosius Date: 2009-10-06 04:40:55 +0000 (Tue, 06 Oct 2009) Log Message: ----------- hmmm, changes unknown Modified Paths: -------------- trunk/fb-contrib/samples/BED_Sample.java trunk/fb-contrib/samples/JAO_Sample.java trunk/fb-contrib/samples/OC_Sample.java trunk/fb-contrib/samples/samples.fb trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java Removed Paths: ------------- trunk/fb-contrib/samples/IPNC_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentParameterNameCasing.java Modified: trunk/fb-contrib/samples/BED_Sample.java =================================================================== --- trunk/fb-contrib/samples/BED_Sample.java 2009-10-06 04:39:43 UTC (rev 1356) +++ trunk/fb-contrib/samples/BED_Sample.java 2009-10-06 04:40:55 UTC (rev 1357) @@ -1,6 +1,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.File; +import java.io.IOException; import java.sql.SQLException; import java.util.Hashtable; import java.util.zip.DataFormatException; @@ -43,4 +45,17 @@ { InputStream is = new FileInputStream("c:\\temp.txt"); } + + public Object iAmCreatingAnObject() { + return new Object() { + private byte[] iHaveToThrowAnException() throws IOException { + return BED_Sample.this.iThrowAnException(); + } + }; + } + + private byte[] iThrowAnException() throws IOException { + File.createTempFile("foo", "bar"); + return "Test".getBytes("UTF-8"); + } } Deleted: trunk/fb-contrib/samples/IPNC_Sample.java =================================================================== --- trunk/fb-contrib/samples/IPNC_Sample.java 2009-10-06 04:39:43 UTC (rev 1356) +++ trunk/fb-contrib/samples/IPNC_Sample.java 2009-10-06 04:40:55 UTC (rev 1357) @@ -1,16 +0,0 @@ - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public class IPNC_Sample -{ - public void doGet(HttpServletRequest req, HttpServletResponse resp) - { - String id = req.getParameter("id"); - } - - public void doPost(HttpServletRequest req, HttpServletResponse resp) - { - String id = req.getParameter("ID"); - } -} Modified: trunk/fb-contrib/samples/JAO_Sample.java =================================================================== --- trunk/fb-contrib/samples/JAO_Sample.java 2009-10-06 04:39:43 UTC (rev 1356) +++ trunk/fb-contrib/samples/JAO_Sample.java 2009-10-06 04:40:55 UTC (rev 1357) @@ -2,6 +2,7 @@ import junit.framework.TestCase; + public class JAO_Sample extends TestCase { @@ -30,4 +31,9 @@ Assert.assertNotNull(i); Assert.assertNotNull(i == 3); } + + public void test3ArgNP(float foo) + { + Assert.assertEquals(1.0f, foo, 0.1); + } } Modified: trunk/fb-contrib/samples/OC_Sample.java =================================================================== --- trunk/fb-contrib/samples/OC_Sample.java 2009-10-06 04:39:43 UTC (rev 1356) +++ trunk/fb-contrib/samples/OC_Sample.java 2009-10-06 04:40:55 UTC (rev 1357) @@ -3,8 +3,15 @@ public class OC_Sample { - public void castList(Object o) + private java.util.Date ud; + + public void castListInReg(Object o) { Collection<String> c = (ArrayList<String>)o; } + + public void castDateInField(Object o) + { + ud = (java.sql.Date)o; + } } \ No newline at end of file Modified: trunk/fb-contrib/samples/samples.fb =================================================================== --- trunk/fb-contrib/samples/samples.fb 2009-10-06 04:39:43 UTC (rev 1356) +++ trunk/fb-contrib/samples/samples.fb 2009-10-06 04:40:55 UTC (rev 1357) @@ -3,8 +3,8 @@ [Source dirs] . [Aux classpath entries] -.\lib\jsp-api.jar -.\lib\junit.jar -.\lib\servlet-api.jar +./lib/jsp-api.jar +./lib/junit.jar +./lib/servlet-api.jar [Options] relative_paths=true Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-10-06 04:39:43 UTC (rev 1356) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InappropriateToStringUse.java 2009-10-06 04:40:55 UTC (rev 1357) @@ -37,6 +37,12 @@ import edu.umd.cs.findbugs.ba.ClassContext; import edu.umd.cs.findbugs.ba.XMethod; +/** + * looks for methods that rely on the format of the string fetched from another object's toString + * method, when that method appears not to be owned by the author of the calling method. + * As the implementation of toString() is often considered a private implementation detail of a class, + * and not something that should be relied on, depending on it's format is dangerous. + */ public class InappropriateToStringUse extends BytecodeScanningDetector { private static final Set<String> validToStringClasses = new HashSet<String>(); Deleted: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentParameterNameCasing.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentParameterNameCasing.java 2009-10-06 04:39:43 UTC (rev 1356) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InconsistentParameterNameCasing.java 2009-10-06 04:40:55 UTC (rev 1357) @@ -1,140 +0,0 @@ -/* - * fb-contrib - Auxiliary detectors for Java programs - * Copyright (C) 2005-2009 Dave Brosius - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package com.mebigfatguy.fbcontrib.detect; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.apache.bcel.classfile.Code; - -import edu.umd.cs.findbugs.BugInstance; -import edu.umd.cs.findbugs.BugReporter; -import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.OpcodeStack; -import edu.umd.cs.findbugs.SourceLineAnnotation; -import edu.umd.cs.findbugs.ba.ClassContext; - -/** - * looks for calls to HttpRequest.getParameter with parameters of the same - * name with different cases like 'id' and 'Id'. - */ -public class InconsistentParameterNameCasing extends BytecodeScanningDetector -{ - private static final String HTTP_SERVLET_REQUEST = "javax/servlet/http/HttpServletRequest"; - private static final String GET_PARAMETER = "getParameter"; - private static final String GET_PARAMETER_SIG = "(Ljava/lang/String;)Ljava/lang/String;"; - BugReporter bugReporter; - OpcodeStack stack; - Map<String, Map<String, List<SourceInfo>>> parmInfo = new HashMap<String, Map<String, List<SourceInfo>>>(); - - public InconsistentParameterNameCasing(BugReporter reporter) { - bugReporter = reporter; - } - - public void visitClassContext(ClassContext classContext) { - try { - stack = new OpcodeStack(); - super.visitClassContext(classContext); - } finally { - stack = null; - } - } - - public void visitCode(Code obj) { - stack.resetForMethodEntry(this); - super.visitCode(obj); - } - - public void sawOpcode(int seen) { - try { - if (seen == INVOKEINTERFACE) { - String clsName = getClassConstantOperand(); - if (HTTP_SERVLET_REQUEST.equals(clsName)) { - String methodName = getNameConstantOperand(); - if (GET_PARAMETER.equals(methodName)) { - String signature = getSigConstantOperand(); - if (GET_PARAMETER_SIG.equals(signature)) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item item = stack.getStackItem(0); - String parmName = (String)item.getConstant(); - String upperParmName = parmName.toUpperCase(Locale.getDefault()); - Map<String, List<SourceInfo>> parmCaseInfo = parmInfo.get(upperParmName); - if (parmCaseInfo == null) { - parmCaseInfo = new HashMap<String, List<SourceInfo>>(); - parmInfo.put(upperParmName, parmCaseInfo); - } - - List<SourceInfo> annotations = parmCaseInfo.get(parmName); - if (annotations == null) { - annotations = new ArrayList<SourceInfo>(); - parmCaseInfo.put(parmName, annotations); - } - - annotations.add(new SourceInfo(getClassName(), getMethodName(), getMethodSig(), getMethod().isStatic(), SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this, getPC()))); - } - } - } - } - } - } finally { - stack.sawOpcode(this, seen); - } - } - - @Override - public void report() { - for (Map<String, List<SourceInfo>> parmCaseInfo : parmInfo.values()) { - if (parmCaseInfo.size() > 1) { - BugInstance bi = new BugInstance(this, "IPNC_INCONSISTENT_HTTP_PARAM_CASING", NORMAL_PRIORITY); - - for (Map.Entry<String, List<SourceInfo>> sourceInfos :parmCaseInfo.entrySet()) { - for (SourceInfo sourceInfo : sourceInfos.getValue()) { - bi.addClass(sourceInfo.clsName); - bi.addMethod(sourceInfo.clsName, sourceInfo.methodName, sourceInfo.signature, sourceInfo.isStatic); - bi.addSourceLine(sourceInfo.srcLine); - bi.addString(sourceInfos.getKey()); - } - } - - bugReporter.reportBug(bi); - } - } - parmInfo.clear(); - } - - static class SourceInfo - { - String clsName; - String methodName; - String signature; - boolean isStatic; - SourceLineAnnotation srcLine; - - public SourceInfo(String cls, String method, String sig, boolean mStatic, SourceLineAnnotation annotation) { - clsName = cls; - methodName = method; - signature = sig; - isStatic = mStatic; - srcLine = annotation; - } - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-06 04:39:52
|
Revision: 1356 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1356&view=rev Author: dbrosius Date: 2009-10-06 04:39:43 +0000 (Tue, 06 Oct 2009) Log Message: ----------- check for 2 parms Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2009-10-04 18:54:22 UTC (rev 1355) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JUnitAssertionOddities.java 2009-10-06 04:39:43 UTC (rev 1356) @@ -142,36 +142,38 @@ if ("assertEquals".equals(methodName)) { String signature = getSigConstantOperand(); Type[] argTypes = Type.getArgumentTypes(signature); - if (argTypes[0].equals(Type.STRING) && argTypes[1].equals(Type.STRING)) - return; - - if (stack.getStackDepth() >= 2) { - OpcodeStack.Item item1 = stack.getStackItem(1); - Object cons1 = item1.getConstant(); - if ((cons1 != null) && (argTypes[argTypes.length-1].equals(Type.BOOLEAN)) && (argTypes[argTypes.length-2].equals(Type.BOOLEAN))) { - bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - return; - } - OpcodeStack.Item item0 = stack.getStackItem(0); - if (item0.getConstant() != null) { - bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - return; - } - if (argTypes[0].equals(Type.OBJECT) && argTypes[1].equals(Type.OBJECT)) { - if ("Ljava/lang/Double;".equals(item0.getSignature()) && "Ljava/lang/Double;".equals(item1.getSignature())) { - bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - return; - } - } + if (argTypes.length == 2) { + if (argTypes[0].equals(Type.STRING) && argTypes[1].equals(Type.STRING)) + return; + + if (stack.getStackDepth() >= 2) { + OpcodeStack.Item item1 = stack.getStackItem(1); + Object cons1 = item1.getConstant(); + if ((cons1 != null) && (argTypes[argTypes.length-1].equals(Type.BOOLEAN)) && (argTypes[argTypes.length-2].equals(Type.BOOLEAN))) { + bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_BOOLEAN_ASSERT", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + return; + } + OpcodeStack.Item item0 = stack.getStackItem(0); + if (item0.getConstant() != null) { + bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_ACTUAL_CONSTANT", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + return; + } + if (argTypes[0].equals(Type.OBJECT) && argTypes[1].equals(Type.OBJECT)) { + if ("Ljava/lang/Double;".equals(item0.getSignature()) && "Ljava/lang/Double;".equals(item1.getSignature())) { + bugReporter.reportBug(new BugInstance(this, "JAO_JUNIT_ASSERTION_ODDITIES_INEXACT_DOUBLE", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + return; + } + } + } } } else if ("assertNotNull".equals(methodName)) { if (stack.getStackDepth() > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-04 18:54:31
|
Revision: 1355 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1355&view=rev Author: dbrosius Date: 2009-10-04 18:54:22 +0000 (Sun, 04 Oct 2009) Log Message: ----------- make 1.6 compatible Modified Paths: -------------- trunk/fb-contrib/samples/JVR_Sample.java Modified: trunk/fb-contrib/samples/JVR_Sample.java =================================================================== --- trunk/fb-contrib/samples/JVR_Sample.java 2009-10-03 16:21:07 UTC (rev 1354) +++ trunk/fb-contrib/samples/JVR_Sample.java 2009-10-04 18:54:22 UTC (rev 1355) @@ -62,4 +62,13 @@ public void truncate(long arg0) throws SQLException { } + + @Override + public void free() throws SQLException { + } + + @Override + public InputStream getBinaryStream(long arg0, long arg1) throws SQLException { + return null; + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-03 16:21:17
|
Revision: 1354 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1354&view=rev Author: dbrosius Date: 2009-10-03 16:21:07 +0000 (Sat, 03 Oct 2009) Log Message: ----------- report inheritance equals relations as LOW Modified Paths: -------------- trunk/fb-contrib/samples/NSE_Sample.java Modified: trunk/fb-contrib/samples/NSE_Sample.java =================================================================== --- trunk/fb-contrib/samples/NSE_Sample.java 2009-10-03 16:20:52 UTC (rev 1353) +++ trunk/fb-contrib/samples/NSE_Sample.java 2009-10-03 16:21:07 UTC (rev 1354) @@ -27,4 +27,32 @@ return false; } } + + class Parent + { + private int o; + + public boolean equals(Object that) { + if (that instanceof Parent) { + return o == ((Parent) that).o; + } else if (that instanceof Two) { + return o == ((Child) that).t; + } + + return false; + } + } + + class Child extends Parent + { + public int t; + + public boolean equals(Object that) { + if (that instanceof Child) { + return t == ((Child) that).t; + } + + return false; + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-03 16:20:59
|
Revision: 1353 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1353&view=rev Author: dbrosius Date: 2009-10-03 16:20:52 +0000 (Sat, 03 Oct 2009) Log Message: ----------- report inheritance equals relations as LOW Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java 2009-10-03 15:45:18 UTC (rev 1352) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java 2009-10-03 16:20:52 UTC (rev 1353) @@ -24,7 +24,9 @@ import org.apache.bcel.Constants; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; +import org.apache.bcel.Repository; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -105,7 +107,12 @@ String thisCls = getClassName(); String equalsCls = getClassConstantOperand(); if (!thisCls.equals(equalsCls)) { - BugInstance bug = new BugInstance(this, "NSE_NON_SYMMETRIC_EQUALS", NORMAL_PRIORITY) + JavaClass thisJavaClass = getClassContext().getJavaClass(); + JavaClass equalsJavaClass = Repository.lookupClass(equalsCls); + boolean inheritance = thisJavaClass.instanceOf(equalsJavaClass) + || equalsJavaClass.instanceOf(thisJavaClass); + + BugInstance bug = new BugInstance(this, "NSE_NON_SYMMETRIC_EQUALS", inheritance ? LOW_PRIORITY:NORMAL_PRIORITY) .addClass(this) .addMethod(this) .addSourceLine(this) @@ -120,6 +127,8 @@ } } } + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); } finally { stack.sawOpcode(this, seen); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-03 15:45:24
|
Revision: 1352 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1352&view=rev Author: dbrosius Date: 2009-10-03 15:45:18 +0000 (Sat, 03 Oct 2009) Log Message: ----------- new detector NSE Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-10-03 15:43:50 UTC (rev 1351) +++ trunk/fb-contrib/htdocs/index.html 2009-10-03 15:45:18 UTC (rev 1352) @@ -64,6 +64,11 @@ <li><b>[IKNC] Inconsistent Key Name Casing</b><br/> Looks for calls to HttpRequest.getParameter with parameters of the same name with different cases like 'id' and 'Id'.</li> + <li><b>[NSE] Non Symmetric Equals</b><br/> + Looks for classes that break the fundamental rule of equivalence, which is + symmetry. If a equals b, then b equals a. While it is usually wrong to allow + equals to compare different types, at the very least you should make sure that + each class knows about each other and is able to compare themselves with each other.</li> </ul> </div> <hr/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-03 15:43:57
|
Revision: 1351 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1351&view=rev Author: dbrosius Date: 2009-10-03 15:43:50 +0000 (Sat, 03 Oct 2009) Log Message: ----------- new detector NSE Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-10-03 15:43:35 UTC (rev 1350) +++ trunk/fb-contrib/etc/messages.xml 2009-10-03 15:43:50 UTC (rev 1351) @@ -1035,6 +1035,18 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals"> + <Details> + <![CDATA[ + <p>looks for classes that break the fundamental rule of equivalence, which is + symmetry. If a equals b, then b equals a. While it is usually wrong to allow + equals to compare different types, at the very least you should make sure that + each class knows about each other and is able to compare themselves with each other.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -2680,6 +2692,20 @@ </Details> </BugPattern> + <BugPattern type="NSE_NON_SYMMETRIC_EQUALS"> + <ShortDescription>Equals method compares this object against other types in a non symmetric way</ShortDescription> + <LongDescription>Equals method {1} compares this object against other types in a non symmetric way</LongDescription> + <Details> + <![CDATA[ + <p>This class implements an equals method that compares this object against another type of object. + This is almost always a bad thing to do, but if it is to be done, you must make sure that the basic + symmetry rule of equivalence is maintained, that being if a equals b, then b equals a. It does not + appear that the class that is being compared to this class knows about this class, and doesn't compare itself + to this.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2767,4 +2793,5 @@ <BugCode abbrev="IKNC">Inconsistent Key Name Casing</BugCode> <BugCode abbrev="OC">Overzealous Casting</BugCode> <BugCode abbrev="PDP">Poorly Defined Parameter</BugCode> + <BugCode abbrev="NSE">Non Symmetric Equals</BugCode> </MessageCollection> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-03 15:43:47
|
Revision: 1350 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1350&view=rev Author: dbrosius Date: 2009-10-03 15:43:35 +0000 (Sat, 03 Oct 2009) Log Message: ----------- new detector NSE Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-10-03 15:43:19 UTC (rev 1349) +++ trunk/fb-contrib/etc/findbugs.xml 2009-10-03 15:43:35 UTC (rev 1350) @@ -373,6 +373,10 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.PoorlyDefinedParameter" speed="fast" reports="PDP_POORLY_DEFINED_PARAMETER" /> + + <Detector class="com.mebigfatguy.fbcontrib.detect.NonSymmetricEquals" + speed="fast" + reports="NSE_NON_SYMMETRIC_EQUALS" /> <!-- BugPattern --> @@ -501,4 +505,5 @@ <BugPattern abbrev="IKNC" type="IKNC_INCONSISTENT_HTTP_PARAM_CASING" category="STYLE" experimental="true" /> <BugPattern abbrev="OC" type="OC_OVERZEALOUS_CASTING" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="PDP" type="PDP_POORLY_DEFINED_PARAMETER" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="NSE" type="NSE_NON_SYMMETRIC_EQUALS" category="CORRECTNESS" experimental="true" /> </FindbugsPlugin> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-03 15:43:29
|
Revision: 1349 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1349&view=rev Author: dbrosius Date: 2009-10-03 15:43:19 +0000 (Sat, 03 Oct 2009) Log Message: ----------- new detector NSE Added Paths: ----------- trunk/fb-contrib/samples/NSE_Sample.java Added: trunk/fb-contrib/samples/NSE_Sample.java =================================================================== --- trunk/fb-contrib/samples/NSE_Sample.java (rev 0) +++ trunk/fb-contrib/samples/NSE_Sample.java 2009-10-03 15:43:19 UTC (rev 1349) @@ -0,0 +1,30 @@ +public class NSE_Sample +{ + class One + { + private int o; + + public boolean equals(Object that) { + if (that instanceof One) { + return o == ((One) that).o; + } else if (that instanceof Two) { + return o == ((Two) that).t; + } + + return false; + } + } + + class Two + { + public int t; + + public boolean equals(Object that) { + if (that instanceof Two) { + return t == ((Two) that).t; + } + + return false; + } + } +} \ No newline at end of file Property changes on: trunk/fb-contrib/samples/NSE_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-03 15:43:07
|
Revision: 1348 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1348&view=rev Author: dbrosius Date: 2009-10-03 15:42:59 +0000 (Sat, 03 Oct 2009) Log Message: ----------- new detector NSE Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java 2009-10-03 15:42:59 UTC (rev 1348) @@ -0,0 +1,150 @@ +/* + * fb-contrib - Auxiliary detectors for Java programs + * Copyright (C) 2005-2009 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.BitSet; +import java.util.HashMap; +import java.util.Map; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Method; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.ba.ClassContext; + +/** + * looks for classes that break the fundamental rule of equivalence, which is + * symmetry. If a equals b, then b equals a. While it is usually wrong to allow + * equals to compare different types, at the very least you should make sure that + * each class knows about each other and is able to compare themselves with each other. + */ +public class NonSymmetricEquals extends BytecodeScanningDetector { + + private BugReporter bugReporter; + private OpcodeStack stack; + private Map<String, Map<String, BugInstance>> possibleBugs = new HashMap<String, Map<String, BugInstance>>(); + + /** + * constructs a NSE detector given the reporter to report bugs on + * @param bugReporter the sync of bug reports + */ + public NonSymmetricEquals(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to create the stack object + * @param classContext the context object of the currently parsed class + */ + public void visitClassContext(ClassContext classContext) { + try { + stack = new OpcodeStack(); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } + + /** + * implements the visitor to see if this method is equals(Object o) + * @param obj the context object of the currently parsed code block + */ + public void visitCode(Code obj) { + Method m = getMethod(); + String name = m.getName(); + String signature = m.getSignature(); + + if ("equals".equals(name) && "(Ljava/lang/Object;)Z".equals(signature) && prescreen(m)) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + } + + /** + * looks for methods that contain a checkcast instruction + * + * @param method the context object of the current method + * @return if the class does checkcast instructions + */ + public boolean prescreen(Method method) { + BitSet bytecodeSet = getClassContext().getBytecodeSet(method); + return (bytecodeSet != null) && (bytecodeSet.get(Constants.CHECKCAST)); + } + + /** + * implements the visitor to look for checkcasts of the parameter to other types, and + * enter instances in a map for further processing in doReport. + * @param seen the opcode of the currently parsed instruction + */ + public void sawOpcode(int seen) { + try { + if (seen == CHECKCAST) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if (item.getRegisterNumber() == 1) { + String thisCls = getClassName(); + String equalsCls = getClassConstantOperand(); + if (!thisCls.equals(equalsCls)) { + BugInstance bug = new BugInstance(this, "NSE_NON_SYMMETRIC_EQUALS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this) + .addString(equalsCls); + Map<String, BugInstance> bugs = possibleBugs.get(thisCls); + if (bugs == null) { + bugs = new HashMap<String, BugInstance>(); + possibleBugs.put(thisCls, bugs); + } + bugs.put(equalsCls, bug); + } + } + } + } + } finally { + stack.sawOpcode(this, seen); + } + } + + @Override + public void report() { + for (Map.Entry<String, Map<String, BugInstance>> thisEntry : possibleBugs.entrySet()) { + + Map<String, BugInstance> equalsClassesMap = thisEntry.getValue(); + for (Map.Entry<String, BugInstance> equalsEntry : equalsClassesMap.entrySet()) { + String equalsCls = equalsEntry.getKey(); + + Map<String, BugInstance> reverseEqualsClassMap = possibleBugs.get(equalsCls); + if (reverseEqualsClassMap == null) { + bugReporter.reportBug(equalsClassesMap.values().iterator().next()); + break; + } + + if (!reverseEqualsClassMap.containsKey(thisEntry.getKey())) { + bugReporter.reportBug(equalsClassesMap.values().iterator().next()); + break; + } + } + } + possibleBugs.clear(); + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonSymmetricEquals.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-02 03:07:22
|
Revision: 1347 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1347&view=rev Author: dbrosius Date: 2009-10-02 03:07:12 +0000 (Fri, 02 Oct 2009) Log Message: ----------- Bug: 2868799 don't report instance based anonymous inner class constructors that have Bogus declarations as JDK1.5 in some cases generated default ctor incorrectly. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-10-01 00:43:44 UTC (rev 1346) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-10-02 03:07:12 UTC (rev 1347) @@ -86,7 +86,7 @@ public void visitCode(Code obj) { declaredCheckedExceptions.clear(); Method method = getMethod(); - if (method.isStatic() || method.isPrivate() || "<init>".equals(method.getName())) { + if (method.isStatic() || method.isPrivate() || (("<init>".equals(method.getName()) && !isAnonymousInnerCtor(method, getThisClass())))) { ExceptionTable et = method.getExceptionTable(); if (et != null) { String[] exNames = et.getExceptionNames(); @@ -118,6 +118,26 @@ } /** + * checks to see if this method is constructor of an instance based inner class, as jdk1.5 compiler + * has a bug where it attaches bogus exception declarations to this constructors in some cases. + * @param m the method to check + * @param cls the cls that owns the method + * @return whether this method is a ctor of an instance based anonymous inner class + */ + private boolean isAnonymousInnerCtor(Method m, JavaClass cls) { + if (!"<init>".equals(m.getName())) + return false; + + String clsName = cls.getClassName(); + int dollarPos = clsName.lastIndexOf('$'); + if (dollarPos <0) + return false; + + String signature = m.getSignature(); + return ("(L" + clsName.substring(0, dollarPos).replace('.', '/') + ";)V").equals(signature); + } + + /** * implements the visitor to look for method calls that could throw the exceptions * that are listed in the declaration. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-10-01 00:44:02
|
Revision: 1346 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1346&view=rev Author: dbrosius Date: 2009-10-01 00:43:44 +0000 (Thu, 01 Oct 2009) Log Message: ----------- final methods from Directly derived from Object still won't work because of infs Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-30 05:57:16 UTC (rev 1345) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-10-01 00:43:44 UTC (rev 1346) @@ -35,7 +35,6 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; -import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for non derivable method that declare parameters and then cast those @@ -56,7 +55,6 @@ String parmSig; int state; String castClass; - boolean derivedFromObject; /** * constructs a PDP detector given the reporter to report bugs on @@ -67,16 +65,6 @@ } /** - * implements the visitor to see if this class is directly derived from Object - * - * @param classContext the context object of the currently parsed class - */ - public void visitClassContext(ClassContext classContext) { - derivedFromObject = "java.lang.Object".equals(classContext.getJavaClass().getSuperclassName()); - super.visitClassContext(classContext); - } - - /** * implements the visitor to see if the method has parameters * * @param obj the context object of the currently parsed code block @@ -85,7 +73,7 @@ public void visitCode(Code obj) { try { Method m = getMethod(); - if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName()) || (m.isFinal() && derivedFromObject)) { + if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName())) { parmSigs = SignatureUtils.getParameterSignatures(m); if ((parmSigs.size() > 0) && prescreen(m)) { state = SAW_NOTHING; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-30 05:57:24
|
Revision: 1345 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1345&view=rev Author: dbrosius Date: 2009-09-30 05:57:16 +0000 (Wed, 30 Sep 2009) Log Message: ----------- report PDP on final methods of classes directly derived from Object, as well. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-29 04:31:13 UTC (rev 1344) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PoorlyDefinedParameter.java 2009-09-30 05:57:16 UTC (rev 1345) @@ -35,6 +35,7 @@ import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for non derivable method that declare parameters and then cast those @@ -55,6 +56,7 @@ String parmSig; int state; String castClass; + boolean derivedFromObject; /** * constructs a PDP detector given the reporter to report bugs on @@ -65,6 +67,16 @@ } /** + * implements the visitor to see if this class is directly derived from Object + * + * @param classContext the context object of the currently parsed class + */ + public void visitClassContext(ClassContext classContext) { + derivedFromObject = "java.lang.Object".equals(classContext.getJavaClass().getSuperclassName()); + super.visitClassContext(classContext); + } + + /** * implements the visitor to see if the method has parameters * * @param obj the context object of the currently parsed code block @@ -73,7 +85,7 @@ public void visitCode(Code obj) { try { Method m = getMethod(); - if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName())) { + if (m.isStatic() || m.isPrivate() || "<init>".equals(m.getName()) || (m.isFinal() && derivedFromObject)) { parmSigs = SignatureUtils.getParameterSignatures(m); if ((parmSigs.size() > 0) && prescreen(m)) { state = SAW_NOTHING; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-29 04:31:22
|
Revision: 1344 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1344&view=rev Author: dbrosius Date: 2009-09-29 04:31:13 +0000 (Tue, 29 Sep 2009) Log Message: ----------- no need for old notes Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-09-29 04:29:18 UTC (rev 1343) +++ trunk/fb-contrib/htdocs/index.html 2009-09-29 04:31:13 UTC (rev 1344) @@ -238,7 +238,6 @@ <hr/> <img id="v2_8_0_image" src="flip1.gif" onClick="toggleBlock('v2_8_0', 'v2_8_0_image');" align="top"/> Detectors added in v2.8.0<br/> - Note: This version of fb-contrib requires FindBugs v1.0.0<br/> <div id="v2_8_0" style="display:none;"> <ul> <li><b>[NMCS] Needless Member Collection Synchronization</b><br/> @@ -261,7 +260,6 @@ <hr/> <img id="v2_6_0_image" src="flip1.gif" onClick="toggleBlock('v2_6_0', 'v2_6_0_image');" align="top"/> Detectors added in v2.6.0<br/> - Note: This version of fb-contrib requires FindBugs v0.9.7.<br/> <div id="v2_6_0" style="display:none;"> <ul> <li><b>[FCBL] Field could be Local</b><br/> @@ -309,7 +307,6 @@ <hr/> <img id="v2_2_0_image" src="flip1.gif" onClick="toggleBlock('v2_2_0', 'v2_2_0_image');" align="top"/> Detectors added in v2.2.0<br/> - Note: fb-contrib v2.2.0 requires FindBugs™ v0.95 or later<br/> <div id="v2_2_0" style="display:none;"> <ul> <li><b>[CLI] Constant List Index</b><br/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-29 04:29:32
|
Revision: 1343 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1343&view=rev Author: dbrosius Date: 2009-09-29 04:29:18 +0000 (Tue, 29 Sep 2009) Log Message: ----------- document PDP Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-09-29 04:06:27 UTC (rev 1342) +++ trunk/fb-contrib/htdocs/index.html 2009-09-29 04:29:18 UTC (rev 1343) @@ -52,6 +52,11 @@ Detectors added in svn<br/> <div id="svn" style="display:block;"> <ul> + <li><b>[PDP] Poorly Defined Parameter</b><br/> + Looks for non derivable methods that declare parameters and then cast those + parameters to more specific types in the method. This is misleading and dangerous + as you are not documenting through parameter types what is necessary for these + parameters to function correctly.</li> <li><b>[OC] Overzealous Casting</b><br/> Looks for manual casts of objects that are more specific then needed as the value is assigned to a class or interface higher up in the inheritance chain. You only need to cast to that class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-09-29 04:06:38
|
Revision: 1342 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1342&view=rev Author: dbrosius Date: 2009-09-29 04:06:27 +0000 (Tue, 29 Sep 2009) Log Message: ----------- engrish Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-09-29 03:59:41 UTC (rev 1341) +++ trunk/fb-contrib/etc/messages.xml 2009-09-29 04:06:27 UTC (rev 1342) @@ -2564,7 +2564,7 @@ <![CDATA[ <p>This method declares that it throws a checked exception that it does not throw. As this method is either a constructor, static method or private method, there is no reason for this method to declare - the exception in it's throws clause, and just causes calling methods to unnecessarily handle an exception + the exception in its throws clause, and just causes calling methods to unnecessarily handle an exception that will never be thrown. The exception in question should be removed from the throws clause.</p> ]]> </Details> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |