fb-contrib-commit Mailing List for fb-contrib (Page 27)
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-05-09 20:58:38
|
Revision: 1191 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1191&view=rev Author: dbrosius Date: 2009-05-09 20:58:29 +0000 (Sat, 09 May 2009) Log Message: ----------- add SMA Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/samples/UNNC_Sample.java Added Paths: ----------- trunk/fb-contrib/samples/SMA_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-05-09 20:21:13 UTC (rev 1190) +++ trunk/fb-contrib/etc/findbugs.xml 2009-05-09 20:58:29 UTC (rev 1191) @@ -344,6 +344,10 @@ speed="fast" reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments" + speed="fast" + reports="SMA_STUTTERED_METHOD_ARGUMENTS" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -463,4 +467,5 @@ <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="UNNC" type="UNNC_UNNECESSARY_NEW_NULL_CHECK" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="DTEP" type="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" category="STYLE" experimental="true" /> + <BugPattern abbrev="SMA" type="SMA_STUTTERED_METHOD_ARGUMENTS" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-05-09 20:21:13 UTC (rev 1190) +++ trunk/fb-contrib/etc/messages.xml 2009-05-09 20:58:29 UTC (rev 1191) @@ -956,6 +956,17 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.StutteredMethodArguments"> + <Details> + <![CDATA[ + <p>looks for method calls that pass the same value for two separate parameters, where + those arguments are not constants. Often this is a cut/paste mistake, but if not, it is + confusing why you would pass the same value for two arguments.</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> <!-- BugPattern --> @@ -2503,6 +2514,19 @@ </Details> </BugPattern> + <BugPattern type="SMA_STUTTERED_METHOD_ARGUMENTS"> + <ShortDescription>code calls a method passing the same value to two different arguments</ShortDescription> + <LongDescription>code {1} calls a method passing the same value to two different arguments</LongDescription> + <Details> + <![CDATA[ + <p>This method calls a method passing the same value for two or more of the parameters. + Often this is a cut/paste bug, but if not, it is confusing why you would pass the same value for two + different parameters. Perhaps an alternative method that just takes one parameter should be overridden + in this case.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2583,4 +2607,5 @@ <BugCode abbrev="BED">Bogus Exception Declaration</BugCode> <BugCode abbrev="UNNC">Unnecessary New Null Check</BugCode> <BugCode abbrev="DTEP">Deprecated Typesafe Enum Pattern</BugCode> + <BugCode abbrev="SMA">Stuttered Method Arguments</BugCode> </MessageCollection> \ No newline at end of file Added: trunk/fb-contrib/samples/SMA_Sample.java =================================================================== --- trunk/fb-contrib/samples/SMA_Sample.java (rev 0) +++ trunk/fb-contrib/samples/SMA_Sample.java 2009-05-09 20:58:29 UTC (rev 1191) @@ -0,0 +1,14 @@ + +public class SMA_Sample +{ + public void testSMA(SMA_Sample s1, SMA_Sample s2) + { + if (!s1.equals(s2)) + testSMA(s1, s1); + } + + public void testNonReport(int a, int b) + { + testNonReport(4, 4); + } +} Property changes on: trunk/fb-contrib/samples/SMA_Sample.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/fb-contrib/samples/UNNC_Sample.java =================================================================== --- trunk/fb-contrib/samples/UNNC_Sample.java 2009-05-09 20:21:13 UTC (rev 1190) +++ trunk/fb-contrib/samples/UNNC_Sample.java 2009-05-09 20:58:29 UTC (rev 1191) @@ -1,5 +1,6 @@ + public class UNNC_Sample { public void testPosNEW() { @@ -51,5 +52,21 @@ System.out.println("OK"); } + public void testFPFinally() throws Exception + { + StringBuilder sb = null; + try + { + sb = new StringBuilder(); + sb.append("False Positive"); + } + finally + { + if (sb != null) + sb.setLength(0); + } + + } + } Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.java 2009-05-09 20:58:29 UTC (rev 1191) @@ -0,0 +1,148 @@ +/* + * 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.HashSet; +import java.util.Set; + +import org.apache.bcel.classfile.Code; + +import com.sun.org.apache.bcel.internal.generic.Type; + +import edu.umd.cs.findbugs.BugInstance; +import edu.umd.cs.findbugs.BugReporter; +import edu.umd.cs.findbugs.BytecodeScanningDetector; +import edu.umd.cs.findbugs.OpcodeStack; +import edu.umd.cs.findbugs.ba.ClassContext; +import edu.umd.cs.findbugs.ba.XField; + +/** + * looks for method calls that passes the same argument to two different parameters of the same + * method. It doesn't report method calls where the arguments are constants. + */ +public class StutteredMethodArguments extends BytecodeScanningDetector { + private final BugReporter bugReporter; + private OpcodeStack stack; + + /** + * constructs a SMA detector given the reporter to report bugs on. + + * @param bugReporter the sync of bug reports + */ + public StutteredMethodArguments(BugReporter bugReporter) + { + this.bugReporter = bugReporter; + } + + /** + * overrides 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(); + super.visitClassContext(classContext); + } finally { + stack = null; + } + } + + /** + * overrides the visitor to reset the stack object + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + stack.resetForMethodEntry(this); + super.visitCode(obj); + } + + /** + * overrides the visitor to look for method calls that pass the same value + * for two different arguments + * + * @param seen the currently parsed op code + */ + @Override + public void sawOpcode(int seen) { + try { + switch (seen) { + case INVOKEVIRTUAL: + case INVOKESTATIC: + case INVOKEINTERFACE: + case INVOKESPECIAL: + String signature = getSigConstantOperand(); + Type[] args = Type.getArgumentTypes(signature); + if (args.length > 1) { + if (stack.getStackDepth() > args.length) { + if (duplicateArguments(stack, args.length)) { + bugReporter.reportBug(new BugInstance(this, "SMA_STUTTERED_METHOD_ARGUMENTS", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } + break; + } + } finally { + stack.sawOpcode(this, seen); + } + } + + /** + * looks for duplicate arguments that are not constants + * + * @param stack the stack to look thru + * @param length the number of arguments + * @return if there are duplicates + */ + private boolean duplicateArguments(OpcodeStack stack, int length) + { + Set<String> args = new HashSet<String>(); + for (int i = 0; i < length; i++) { + OpcodeStack.Item item = stack.getStackItem(i); + + if (item.getConstant() == null) { + String arg = null; + int reg = item.getRegisterNumber(); + if (reg >= 0) { + arg = String.valueOf(reg); + } else { + XField f = item.getXField(); + if (f != null) { + arg = f.getName(); + } + } + + if (arg != null) { + if (args.contains(arg)) + return true; + args.add(arg); + } + } + } + + return false; + } +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/StutteredMethodArguments.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-05-09 20:21:21
|
Revision: 1190 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1190&view=rev Author: dbrosius Date: 2009-05-09 20:21:13 +0000 (Sat, 09 May 2009) Log Message: ----------- add copyright Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java 2009-05-03 13:08:47 UTC (rev 1189) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java 2009-05-09 20:21:13 UTC (rev 1190) @@ -1,3 +1,21 @@ +/* + * 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.HashSet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-05-03 13:08:48
|
Revision: 1189 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1189&view=rev Author: dbrosius Date: 2009-05-03 13:08:47 +0000 (Sun, 03 May 2009) Log Message: ----------- use the right 'Type' Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-05-03 04:33:59 UTC (rev 1188) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-05-03 13:08:47 UTC (rev 1189) @@ -24,9 +24,8 @@ import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.ConstantUtf8; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; -import com.sun.org.apache.bcel.internal.generic.Type; - import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-05-03 04:34:03
|
Revision: 1188 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1188&view=rev Author: dbrosius Date: 2009-05-03 04:33:59 +0000 (Sun, 03 May 2009) Log Message: ----------- embellish LO with LO_SUSPECT_LOG_PARAMETER Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-05-03 04:33:44 UTC (rev 1187) +++ trunk/fb-contrib/etc/findbugs.xml 2009-05-03 04:33:59 UTC (rev 1188) @@ -322,7 +322,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities" speed="fast" - reports="LO_SUSPECT_LOG_CLASS" /> + reports="LO_SUSPECT_LOG_CLASS,LO_SUSPECT_LOG_PARAMETER" /> <Detector class="com.mebigfatguy.fbcontrib.detect.IncorrectInternalClassUse" speed="fast" @@ -457,6 +457,7 @@ <BugPattern abbrev="WEM" type="WEM_WEAK_EXCEPTION_MESSAGING" category="STYLE" /> <BugPattern abbrev="SCSS" type="SCSS_SUSPICIOUS_CLUSTERED_SESSION_SUPPORT" category="CORRECTNESS" /> <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_CLASS" category="CORRECTNESS" /> + <BugPattern abbrev="LO" type="LO_SUSPECT_LOG_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" experimental="true" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-05-03 04:33:53
|
Revision: 1187 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1187&view=rev Author: dbrosius Date: 2009-05-03 04:33:44 +0000 (Sun, 03 May 2009) Log Message: ----------- embellish LO with LO_SUSPECT_LOG_PARAMETER Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-05-03 04:33:29 UTC (rev 1186) +++ trunk/fb-contrib/etc/messages.xml 2009-05-03 04:33:44 UTC (rev 1187) @@ -883,8 +883,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.LoggerOddities"> <Details> <![CDATA[ - <p>looks for code that allocates a Logger object by passing a specification of a class that - is not related to the class in which the logger is used.</p> + <p>looks for odd patterns of use of Logger classes from either log4j or slf4j.</p> <p>It is a fast detector</p> ]]> </Details> @@ -2418,6 +2417,18 @@ </Details> </BugPattern> + <BugPattern type="LO_SUSPECT_LOG_PARAMETER"> + <ShortDescription>constructor declares a Logger parameter</ShortDescription> + <LongDescription>constructor {1} declares a Logger parameter</LongDescription> + <Details> + <![CDATA[ + <p>This constructor declares a parameter that is a Logger. As loggers are meant to be + created statically per class, it doesn't make sense that you would pass a Logger from one + class to another. Declare the Logger static in each class instead.</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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-05-03 04:33:44
|
Revision: 1186 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1186&view=rev Author: dbrosius Date: 2009-05-03 04:33:29 +0000 (Sun, 03 May 2009) Log Message: ----------- embellish LO with LO_SUSPECT_LOG_PARAMETER Modified Paths: -------------- trunk/fb-contrib/samples/LO_Sample.java Modified: trunk/fb-contrib/samples/LO_Sample.java =================================================================== --- trunk/fb-contrib/samples/LO_Sample.java 2009-05-03 04:33:15 UTC (rev 1185) +++ trunk/fb-contrib/samples/LO_Sample.java 2009-05-03 04:33:29 UTC (rev 1186) @@ -5,4 +5,9 @@ { private static Logger l1 = Logger.getLogger(String.class); private static Logger l2 = Logger.getLogger("com.foo.LO_Sample"); + + public LO_Sample(Logger l3) + { + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-05-03 04:33:24
|
Revision: 1185 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1185&view=rev Author: dbrosius Date: 2009-05-03 04:33:15 +0000 (Sun, 03 May 2009) Log Message: ----------- embellish LO with LO_SUSPECT_LOG_PARAMETER Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-04-25 05:19:58 UTC (rev 1184) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2009-05-03 04:33:15 UTC (rev 1185) @@ -23,7 +23,10 @@ import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.ConstantUtf8; +import org.apache.bcel.classfile.Method; +import com.sun.org.apache.bcel.internal.generic.Type; + import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -82,6 +85,21 @@ @Override public void visitCode(Code obj) { stack.resetForMethodEntry(this); + Method m = getMethod(); + if ("<init>".equals(m.getName())) { + Type[] types = Type.getArgumentTypes(m.getSignature()); + for (Type t : types) + { + String parmSig = t.getSignature(); + if ("Lorg/slf4j/Logger;".equals(parmSig) + || "Lorg/apache/log4j/Logger;".equals(parmSig)) { + bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_PARAMETER", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } super.visitCode(obj); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-25 05:20:07
|
Revision: 1184 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1184&view=rev Author: dbrosius Date: 2009-04-25 05:19:58 +0000 (Sat, 25 Apr 2009) Log Message: ----------- add check for .size() <= 0 Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2009-04-25 05:19:45 UTC (rev 1183) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2009-04-25 05:19:58 UTC (rev 1184) @@ -186,7 +186,7 @@ } } - if ((seen == IFEQ) || (seen == IFNE)) { + if ((seen == IFEQ) || (seen == IFNE) || (seen == IFGT)) { if (stack.getStackDepth() == 1) { OpcodeStack.Item item = stack.getStackItem(0); if ("size".equals(item.getUserValue())) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-25 05:19:54
|
Revision: 1183 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1183&view=rev Author: dbrosius Date: 2009-04-25 05:19:45 +0000 (Sat, 25 Apr 2009) Log Message: ----------- add check for .size() <= 0 Modified Paths: -------------- trunk/fb-contrib/samples/SPP_Sample.java Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2009-04-25 02:30:44 UTC (rev 1182) +++ trunk/fb-contrib/samples/SPP_Sample.java 2009-04-25 05:19:45 UTC (rev 1183) @@ -251,6 +251,11 @@ { System.out.println("empty"); } + + if (s.size() <= 0) + { + System.out.println("empty"); + } } public boolean testDerivedGregorianCalendar() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-25 02:30:54
|
Revision: 1182 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1182&view=rev Author: dbrosius Date: 2009-04-25 02:30:44 +0000 (Sat, 25 Apr 2009) Log Message: ----------- document UNNC Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-04-25 02:29:19 UTC (rev 1181) +++ trunk/fb-contrib/htdocs/index.html 2009-04-25 02:30:44 UTC (rev 1182) @@ -60,6 +60,11 @@ Looks for classes that appear to implement the old style type safe enum pattern that was used before java added Enum support to the language. Since this class is compiled with java 1.5 or later, it would be simpler to just use java enums.</li> + <li><b>[UNNC] Unnecessary New Null Check</b><br/> + Looks for construction of new objects, and then the immediate testing + whether the object is null or not. As the new operator will always succeed, + or through an exception, this test is unnecessary and represents a misunderstanding + as to how the jvm works.</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-04-25 02:29:21
|
Revision: 1181 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1181&view=rev Author: dbrosius Date: 2009-04-25 02:29:19 +0000 (Sat, 25 Apr 2009) Log Message: ----------- really fix it Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java 2009-04-25 02:24:10 UTC (rev 1180) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java 2009-04-25 02:29:19 UTC (rev 1181) @@ -67,8 +67,8 @@ int lineNo = lineNumbers[mid].getLineNumber(); - for (int i = mid + 1; i < lineNumbers.length; i++) { - if (lineNumbers[i].getLineNumber() == lineNo) + for (int i = 0; i < lineNumbers.length; i++) { + if ((mid != i) && (lineNumbers[i].getLineNumber() == lineNo)) return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-25 02:24:18
|
Revision: 1180 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1180&view=rev Author: dbrosius Date: 2009-04-25 02:24:10 +0000 (Sat, 25 Apr 2009) Log Message: ----------- add check for isValidLineNumber Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-25 02:23:54 UTC (rev 1179) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-25 02:24:10 UTC (rev 1180) @@ -26,6 +26,7 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.CodeException; +import com.mebigfatguy.fbcontrib.utils.AttributesUtils; import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; @@ -128,10 +129,12 @@ if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); if (item.getUserValue() != null) { - bugReporter.reportBug(new BugInstance(this, "UNNC_UNNECESSARY_NEW_NULL_CHECK", NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); + if (AttributesUtils.isValidLineNumber(getCode(), getPC())) { + bugReporter.reportBug(new BugInstance(this, "UNNC_UNNECESSARY_NEW_NULL_CHECK", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } } } transitionPoints.add(Integer14.valueOf(getBranchTarget())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-25 02:24:08
|
Revision: 1179 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1179&view=rev Author: dbrosius Date: 2009-04-25 02:23:54 +0000 (Sat, 25 Apr 2009) Log Message: ----------- fix isValidLineNumber Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java 2009-04-25 01:44:44 UTC (rev 1178) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/AttributesUtils.java 2009-04-25 02:23:54 UTC (rev 1179) @@ -31,9 +31,9 @@ } /** - * returns whether the pc is at a user defined line or whether it's in a compiler - * generated section of code based on the line number table. If the Line number table - * doesn't exist, then assume it's ok. + * returns whether the pc is at a line number that also appears for a another byte code offset + * later on in the method. If this occurs we are in a jdk6 finally replicated block, and so don't + * report this. If the code has no line number table, then just report it. * * @param obj the code object to find line number attributes from * @param pc the pc to check @@ -50,14 +50,28 @@ if (lineNumbers == null) return true; - for (LineNumber lineNumber : lineNumbers) { - int linePC = lineNumber.getStartPC(); - if (linePC >= pc) - { - return linePC == pc; - } + int lo = 0; + int hi = lineNumbers.length - 1; + int mid = 0; + int linePC = 0; + while (lo <= hi) { + mid = (lo + hi) / 2; + linePC = lineNumbers[mid].getStartPC(); + if (linePC == pc) + break; + if (linePC < pc) + lo = mid + 1; + else + hi = mid - 1; } - return false; + int lineNo = lineNumbers[mid].getLineNumber(); + + for (int i = mid + 1; i < lineNumbers.length; i++) { + if (lineNumbers[i].getLineNumber() == lineNo) + return false; + } + + return true; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-25 01:45:23
|
Revision: 1178 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1178&view=rev Author: dbrosius Date: 2009-04-25 01:44:44 +0000 (Sat, 25 Apr 2009) Log Message: ----------- document DTEP Modified Paths: -------------- trunk/fb-contrib/htdocs/index.html Modified: trunk/fb-contrib/htdocs/index.html =================================================================== --- trunk/fb-contrib/htdocs/index.html 2009-04-24 06:51:13 UTC (rev 1177) +++ trunk/fb-contrib/htdocs/index.html 2009-04-25 01:44:44 UTC (rev 1178) @@ -48,20 +48,24 @@ <a href="bugdescriptions.html">Bug Descriptions</a> <hr/> - <img id="svn_image" src="flip1.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> + <img id="svn_image" src="flip2.gif" onClick="toggleBlock('svn', 'svn_image');" align="top"/> Detectors added in SVN<br/> - <div id="svn" style="display:none;"> + <div id="svn" style="display:block;"> <ul> <li><b>[BED] Bogus Exception Declaration</b><br/> Looks for constructors, private methods or static methods that declare that they throw specific checked exceptions, but that do not. This just causes callers of these methods to do extra work to handle an exception that will never be thrown.</li> + <li><b>[DTEP] Deprecated Typesafe Enum Pattern</b><br/> + Looks for classes that appear to implement the old style type safe enum pattern + that was used before java added Enum support to the language. Since this class is + compiled with java 1.5 or later, it would be simpler to just use java enums.</li> </ul> </div> <hr/> - <img id="v3_8_0_image" src="flip2.gif" onClick="toggleBlock('v3_8_0', 'v3_8_0_image');" align="top"/> + <img id="v3_8_0_image" src="flip1.gif" onClick="toggleBlock('v3_8_0', 'v3_8_0_image');" align="top"/> Detectors added in v3.8.0<br/> - <div id="v3_8_0" style="display:block;"> + <div id="v3_8_0" style="display:none;"> <ul> <li><b>[DSOC] Dubious Set of Collections</b><br/> Looks for sets or keySets of maps that contain other collections. As typically collections calculate This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-24 06:51:14
|
Revision: 1177 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1177&view=rev Author: dbrosius Date: 2009-04-24 06:51:13 +0000 (Fri, 24 Apr 2009) Log Message: ----------- new DTEP detector Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2009-04-24 06:51:00 UTC (rev 1176) +++ trunk/fb-contrib/etc/findbugs.xml 2009-04-24 06:51:13 UTC (rev 1177) @@ -340,6 +340,10 @@ speed="fast" reports="UNNC_UNNECESSARY_NEW_NULL_CHECK" /> + <Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern" + speed="fast" + reports="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" /> + <!-- BugPattern --> <BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" /> @@ -457,4 +461,5 @@ <BugPattern abbrev="DSOC" type="DSOC_DUBIOUS_SET_OF_COLLECTIONS" category="PERFORMANCE" /> <BugPattern abbrev="BED" type="BED_BOGUS_EXCEPTION_DECLARATION" category="CORRECTNESS" experimental="true" /> <BugPattern abbrev="UNNC" type="UNNC_UNNECESSARY_NEW_NULL_CHECK" category="CORRECTNESS" experimental="true" /> + <BugPattern abbrev="DTEP" type="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN" category="STYLE" 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-04-24 06:51:01
|
Revision: 1176 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1176&view=rev Author: dbrosius Date: 2009-04-24 06:51:00 +0000 (Fri, 24 Apr 2009) Log Message: ----------- new DTEP detector Modified Paths: -------------- trunk/fb-contrib/etc/messages.xml Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2009-04-24 06:50:38 UTC (rev 1175) +++ trunk/fb-contrib/etc/messages.xml 2009-04-24 06:51:00 UTC (rev 1176) @@ -946,6 +946,18 @@ ]]> </Details> </Detector> + + <Detector class="com.mebigfatguy.fbcontrib.detect.DeprecatedTypesafeEnumPattern"> + <Details> + <![CDATA[ + <p>looks for classes that appear to implement the old style type safe enum pattern + that was used before java added Enum support to the language. Since this class is + compiled with java 1.5 or later, it would be simpler to just use java enums</p> + <p>It is a fast detector</p> + ]]> + </Details> + </Detector> + <!-- BugPattern --> @@ -2468,6 +2480,18 @@ </Details> </BugPattern> + <BugPattern type="DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN"> + <ShortDescription>class appears to implement the old style type safe enum pattern</ShortDescription> + <LongDescription>class {0} appears to implement the old style type safe enum pattern</LongDescription> + <Details> + <![CDATA[ + <p>This class appears to implement the old style type safe enum pattern that was used in place of + real enums. Since this class is compiled with java 1.5 or better, it would be simpler and more + easy to understand if it was just switched over to an enum.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> @@ -2547,4 +2571,5 @@ <BugCode abbrev="DSOC">Dubious Set of Collections</BugCode> <BugCode abbrev="BED">Bogus Exception Declaration</BugCode> <BugCode abbrev="UNNC">Unnecessary New Null Check</BugCode> + <BugCode abbrev="DTEP">Deprecated Typesafe Enum Pattern</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-04-24 06:50:40
|
Revision: 1175 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1175&view=rev Author: dbrosius Date: 2009-04-24 06:50:38 +0000 (Fri, 24 Apr 2009) Log Message: ----------- new DTEP detector Added Paths: ----------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java (rev 0) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.java 2009-04-24 06:50:38 UTC (rev 1175) @@ -0,0 +1,145 @@ +package com.mebigfatguy.fbcontrib.detect; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.bcel.Constants; +import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.Field; +import org.apache.bcel.classfile.JavaClass; +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.ba.ClassContext; + +/** + * looks for classes that appear to implement the old style type safe enum pattern that was + * used before java added Enum support to the language. Since this class is compiled with + * java 1.5 or later, it would be simpler to just use java enums + */ +public class DeprecatedTypesafeEnumPattern extends BytecodeScanningDetector +{ + private static final int SAW_NOTHING = 0; + private static final int SAW_INVOKESPECIAL = 1; + private static final int SAW_BUG = 2; + + private final BugReporter bugReporter; + private int firstEnumPC; + private int enumCount; + private Set<String> enumConstNames; + int state; + + /** + * constructs a DTEP detector given the reporter to report bugs on. + + * @param bugReporter the sync of bug reports + */ + public DeprecatedTypesafeEnumPattern(BugReporter bugReporter) { + this.bugReporter = bugReporter; + } + + /** + * implements the visitor to look for classes compiled with 1.5 or better + * that have all constructors that are private + * + * @param context the currently parsed class context object + */ + @Override + public void visitClassContext(ClassContext context) { + try { + JavaClass cls = context.getJavaClass(); + if (!cls.isEnum()) { + if (cls.getMajor() >= Constants.MAJOR_1_5) { + Method[] methods = cls.getMethods(); + for (Method m : methods) { + if ("<init>".equals(m.getName())) { + if ((m.getAccessFlags() & Constants.ACC_PRIVATE) == 0) + return; + } + } + firstEnumPC = 0; + enumCount = 0; + enumConstNames = new HashSet<String>(); + super.visitClassContext(context); + } + } + } finally { + enumConstNames = null; + } + } + + /** + * implements the visitor to look for fields that are public static final and + * are the same type as the owning class. it collects these object names for later + * + * @param obj the context object of the currently parsed field + */ + @Override + public void visitField(Field obj) { + int accessFlags = obj.getAccessFlags(); + if (((accessFlags & Constants.ACC_STATIC) != 0) + && ((accessFlags & Constants.ACC_PUBLIC) != 0) + && ((accessFlags & Constants.ACC_FINAL) != 0)) { + JavaClass cls = getClassContext().getJavaClass(); + if (!obj.isEnum()) { + String fieldClass = obj.getSignature(); + if (fieldClass.startsWith("L")) { + fieldClass = fieldClass.substring(1, fieldClass.length() - 1); + String clsClass = cls.getClassName(); + if (fieldClass.equals(clsClass)) { + enumConstNames.add(obj.getName()); + super.visitField(obj); + } + } + } + } + } + + /** + * implements the visitor to look for static initializers to find enum generation + * + * @param obj the context object of the currently parsed code block + */ + @Override + public void visitCode(Code obj) { + if ("<clinit>".equals(getMethod().getName())) { + state = SAW_NOTHING; + super.visitCode(obj); + } + } + + /** + * implements the visitor to find allocations of TypesafeEnum constants + * + * @param seen the currently parsed opcode + */ + @Override + public void sawOpcode(int seen) { + if (state == SAW_NOTHING) { + if (seen == INVOKESPECIAL) { + state = SAW_INVOKESPECIAL; + } + } else if (state == SAW_INVOKESPECIAL) { + if (seen == PUTSTATIC) { + String fieldName = getNameConstantOperand(); + if (enumConstNames.contains(fieldName)) { + if (enumCount == 0) + firstEnumPC = getPC(); + enumCount++; + if (enumCount >= 2) { + bugReporter.reportBug(new BugInstance(this, "DTEP_DEPRECATED_TYPESAFE_ENUM_PATTERN", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this, firstEnumPC)); + state = SAW_BUG; + } + } + } + if (state != SAW_BUG) + state = SAW_NOTHING; + } + } + +} Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/DeprecatedTypesafeEnumPattern.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-04-24 06:50:11
|
Revision: 1174 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1174&view=rev Author: dbrosius Date: 2009-04-24 06:50:10 +0000 (Fri, 24 Apr 2009) Log Message: ----------- new DTEP detector Added Paths: ----------- trunk/fb-contrib/samples/DTEP_Sample.java Added: trunk/fb-contrib/samples/DTEP_Sample.java =================================================================== --- trunk/fb-contrib/samples/DTEP_Sample.java (rev 0) +++ trunk/fb-contrib/samples/DTEP_Sample.java 2009-04-24 06:50:10 UTC (rev 1174) @@ -0,0 +1,11 @@ + +public class DTEP_Sample +{ + public static final DTEP_Sample SAMPLE1 = new DTEP_Sample(); + public static final DTEP_Sample SAMPLE2 = new DTEP_Sample(); + + private DTEP_Sample() + { + + } +} Property changes on: trunk/fb-contrib/samples/DTEP_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-04-24 05:50:57
|
Revision: 1173 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1173&view=rev Author: dbrosius Date: 2009-04-24 05:50:50 +0000 (Fri, 24 Apr 2009) Log Message: ----------- add copyright Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-24 05:49:35 UTC (rev 1172) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnnecessaryNewNullCheck.java 2009-04-24 05:50:50 UTC (rev 1173) @@ -1,3 +1,21 @@ +/* + * 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-24 05:49:45
|
Revision: 1172 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1172&view=rev Author: dbrosius Date: 2009-04-24 05:49:35 +0000 (Fri, 24 Apr 2009) Log Message: ----------- add copyright Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java 2009-04-24 05:47:57 UTC (rev 1171) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MisleadingOverloadModel.java 2009-04-24 05:49:35 UTC (rev 1172) @@ -1,3 +1,21 @@ +/* + * 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.HashMap; @@ -25,7 +43,7 @@ private static final Integer STATIC = Integer14.valueOf(1); private static final Integer BOTH = Integer14.valueOf(2); - private BugReporter bugReporter; + private final BugReporter bugReporter; /** * constructs a MOM detector given the reporter to report bugs on This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-24 05:48:00
|
Revision: 1171 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1171&view=rev Author: dbrosius Date: 2009-04-24 05:47:57 +0000 (Fri, 24 Apr 2009) Log Message: ----------- add copyright 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-04-18 23:43:29 UTC (rev 1170) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/BogusExceptionDeclaration.java 2009-04-24 05:47:57 UTC (rev 1171) @@ -1,3 +1,21 @@ +/* + * 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.HashSet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-18 23:43:31
|
Revision: 1170 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1170&view=rev Author: dbrosius Date: 2009-04-18 23:43:29 +0000 (Sat, 18 Apr 2009) Log Message: ----------- add fp on readObject(ObjectInputStream) Modified Paths: -------------- trunk/fb-contrib/samples/OCP_Sample.java Modified: trunk/fb-contrib/samples/OCP_Sample.java =================================================================== --- trunk/fb-contrib/samples/OCP_Sample.java 2009-04-18 23:40:54 UTC (rev 1169) +++ trunk/fb-contrib/samples/OCP_Sample.java 2009-04-18 23:43:29 UTC (rev 1170) @@ -4,6 +4,8 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; @@ -17,7 +19,7 @@ import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; -public class OCP_Sample extends Z implements ActionListener +public class OCP_Sample extends Z implements ActionListener, Serializable { public String getDisplay(HashSet<String> s, String a, String b) { @@ -92,6 +94,11 @@ { Color[] cc = new Color[] { c, c }; } + + private void readObject(ObjectInputStream ois) + { + + } } class Z This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-18 23:41:09
|
Revision: 1169 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1169&view=rev Author: dbrosius Date: 2009-04-18 23:40:54 +0000 (Sat, 18 Apr 2009) Log Message: ----------- don't report serializable's readObject(ObjectInputStream) 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-04-17 08:54:55 UTC (rev 1168) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2009-04-18 23:40:54 UTC (rev 1169) @@ -107,16 +107,20 @@ if (!"<init>".equals(methodName) && !"<clinit>".equals(methodName)) { String methodSig = obj.getSignature(); - String parms = methodSig.split("\\(|\\)")[1]; - if (parms.indexOf(';') >= 0) { - outer:for (JavaClass cls : constrainingClasses) { - Method[] methods = cls.getMethods(); - for (Method m : methods) { - if (methodName.equals(m.getName())) { - if (methodSig.equals(m.getSignature())) { - methodSignatureIsConstrained = true; - break outer; + methodSignatureIsConstrained = methodIsSpecial(methodName, methodSig); + if (!methodSignatureIsConstrained) { + String parms = methodSig.split("\\(|\\)")[1]; + if (parms.indexOf(';') >= 0) { + + outer:for (JavaClass cls : constrainingClasses) { + Method[] methods = cls.getMethods(); + for (Method m : methods) { + if (methodName.equals(m.getName())) { + if (methodSig.equals(m.getSignature())) { + methodSignatureIsConstrained = true; + break outer; + } } } } @@ -245,6 +249,14 @@ } } + private boolean methodIsSpecial(String methodName, String methodSig) { + if ("readObject".equals(methodName) && "(Ljava/io/ObjectInputStream;)V".equals(methodSig)) { + return true; + } + + return false; + } + private void reportBugs() { Iterator<Map.Entry<Integer, Map<JavaClass, List<MethodInfo>>>> it = parameterDefiners.entrySet().iterator(); while (it.hasNext()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-17 08:54:56
|
Revision: 1168 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1168&view=rev Author: dbrosius Date: 2009-04-17 08:54:55 +0000 (Fri, 17 Apr 2009) Log Message: ----------- better exception handling Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2009-04-17 08:49:44 UTC (rev 1167) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SuspiciousJDKVersionUse.java 2009-04-17 08:54:55 UTC (rev 1168) @@ -70,14 +70,14 @@ private static final Pattern jarPattern = Pattern.compile("jar:file:/*([^!]*)"); private static final String SJVU_JDKHOME = "fb-contrib.sjvu.jdkhome"; - private Map<String, File> versionPaths; - private Map<Integer, Map<String, Set<String>>> validMethodsByVersion; - private Map<String, String> superNames; + private final Map<String, File> versionPaths; + private final Map<Integer, Map<String, Set<String>>> validMethodsByVersion; + private final Map<String, String> superNames; private File jdksRoot = null; private ZipFile jdkZip; private JavaClass cls; private Integer clsMajorVersion; - private BugReporter bugReporter; + private final BugReporter bugReporter; public SuspiciousJDKVersionUse(BugReporter bugReporter) { this.bugReporter = bugReporter; @@ -108,8 +108,8 @@ cnfe.fillInStackTrace(); bugReporter.reportMissingClass(cnfe); } - } catch (Exception ze) { - // Hmm what to do? + } catch (IOException ioe) { + //Hmm What to do } finally { cls = null; clsMajorVersion = null; @@ -126,7 +126,6 @@ public void sawOpcode(int seen) { String clsName; - try { if ((seen == INVOKEVIRTUAL) //Interfaces are more difficult, ignore for now || (seen == INVOKESTATIC) @@ -153,8 +152,10 @@ } } } - } catch (Exception e) { - // Hmm what to do + } catch (ClassNotFoundException cnfe) { + bugReporter.reportMissingClass(cnfe); + } catch (IOException ioe) { + //Hmm what do do. } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2009-04-17 08:49:45
|
Revision: 1167 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1167&view=rev Author: dbrosius Date: 2009-04-17 08:49:44 +0000 (Fri, 17 Apr 2009) Log Message: ----------- UNNC Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2009-04-17 08:45:31 UTC (rev 1166) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/Section508Compliance.java 2009-04-17 08:49:44 UTC (rev 1167) @@ -74,7 +74,7 @@ accessibleClass = null; } } - private BugReporter bugReporter; + private final BugReporter bugReporter; private OpcodeStack stack; private Set<XField> fieldLabels; private Map<Integer, SourceLineAnnotation> localLabels; @@ -184,8 +184,7 @@ OpcodeStack.Item item = stack.getStackItem(0); if (item.getUserValue() == null) { FieldAnnotation fa = new FieldAnnotation(getClassName(), getNameConstantOperand(), getSigConstantOperand(), false); - if (fa != null) - fieldLabels.remove(XFactory.createXField(fa)); + fieldLabels.remove(XFactory.createXField(fa)); } } } else if (seen == INVOKESPECIAL) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |