[Fb-contrib-commit] SF.net SVN: fb-contrib: [629] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-09-04 04:54:27
|
Revision: 629 http://svn.sourceforge.net/fb-contrib/?rev=629&view=rev Author: dbrosius Date: 2006-09-03 21:54:14 -0700 (Sun, 03 Sep 2006) Log Message: ----------- add another URV bug pattern to be more clear Modified Paths: -------------- trunk/fb-contrib/etc/findbugs.xml trunk/fb-contrib/etc/messages.xml trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java Modified: trunk/fb-contrib/etc/findbugs.xml =================================================================== --- trunk/fb-contrib/etc/findbugs.xml 2006-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/etc/findbugs.xml 2006-09-04 04:54:14 UTC (rev 629) @@ -244,7 +244,7 @@ <Detector class="com.mebigfatguy.fbcontrib.detect.UnrelatedReturnValues" speed="fast" - reports="URV_UNRELATED_RETURN_VALUES,URV_CHANGE_RETURN_TYPE" /> + reports="URV_UNRELATED_RETURN_VALUES,URV_CHANGE_RETURN_TYPE,URV_INHERITED_METHOD_WITH_RELATED_TYPES" /> <!-- BugPattern --> @@ -308,5 +308,5 @@ <BugPattern abbrev="TR" type="TR_TAIL_RECURSION" category="PERFORMANCE" experimental="true" /> <BugPattern abbrev="URV" type="URV_UNRELATED_RETURN_VALUES" category="STYLE" experimental="true" /> <BugPattern abbrev="URV" type="URV_CHANGE_RETURN_TYPE" category="STYLE" experimental="true" /> - + <BugPattern abbrev="URV" type="URV_INHERITED_METHOD_WITH_RELATED_TYPES" category="STYLE" experimental="true" /> </FindbugsPlugin> \ No newline at end of file Modified: trunk/fb-contrib/etc/messages.xml =================================================================== --- trunk/fb-contrib/etc/messages.xml 2006-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/etc/messages.xml 2006-09-04 04:54:14 UTC (rev 629) @@ -1422,20 +1422,19 @@ </BugPattern> <BugPattern type="URV_UNRELATED_RETURN_VALUES"> - <ShortDescription>Derived method returns different types of unrelated Objects</ShortDescription> - <LongDescription>Derived method {1} returns different types of unrelated Objects</LongDescription> + <ShortDescription>Method returns different types of unrelated Objects</ShortDescription> + <LongDescription>Method {1} returns different types of unrelated Objects</LongDescription> <Details> <![CDATA[ - <p>This method, which is derived from a superclass, or interface, returns two or - more unrelated types of objects. This will be very confusing to the code that must - call it.</p> + <p>This method returns two or more unrelated types of objects (Related only through java.lang.Object). + This will be very confusing to the code that must call it.</p> ]]> </Details> </BugPattern> <BugPattern type="URV_CHANGE_RETURN_TYPE"> - <ShortDescription>Method returns different types of unrelated Objects</ShortDescription> - <LongDescription>Method {1} returns different types of unrelated Objects</LongDescription> + <ShortDescription>Method returns more specific type of object than declared</ShortDescription> + <LongDescription>Method {1} returns more specific type of object than declared</LongDescription> <Details> <![CDATA[ <p>This method is defined to return a java.lang.Object. However, the return types @@ -1445,6 +1444,20 @@ ]]> </Details> </BugPattern> + + <BugPattern type="URV_INHERITED_METHOD_WITH_RELATED_TYPES"> + <ShortDescription>Inherited method returns more specific type of object than declared</ShortDescription> + <LongDescription>Inherited method {1} returns more specific type of object than declared</LongDescription> + <Details> + <![CDATA[ + <p>This inherited method is defined to return a java.lang.Object. However, the return types returned + from this method can be defined by a more specific class or interface. If possible consider changing the + return type in the inheritance hierarchy of this method, otherwise the caller of this method will be brittle + in handling of the return type.</p> + ]]> + </Details> + </BugPattern> + <!-- BugCode --> <BugCode abbrev="ISB">Inefficient String Buffering</BugCode> Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/UnrelatedReturnValues.java 2006-09-04 04:54:14 UTC (rev 629) @@ -95,10 +95,14 @@ .addClass(this) .addMethod(this); bug.addString(cls.getClassName()); - } else { + } else if (!isInherited) { bug = new BugInstance(this, "URV_UNRELATED_RETURN_VALUES", NORMAL_PRIORITY) .addClass(this) .addMethod(this); + } else { + bug = new BugInstance(this, "URV_INHERITED_METHOD_WITH_RELATED_TYPES", NORMAL_PRIORITY) + .addClass(this) + .addMethod(this); } if (bug != null) { for (Integer pc : returnTypes.values()) { Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2006-09-04 04:29:23 UTC (rev 628) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/utils/SignatureUtils.java 2006-09-04 04:54:14 UTC (rev 629) @@ -31,7 +31,7 @@ JavaClass[] supers = cls.getSuperClasses(); for (int i = 0; i < supers.length; i++) { - if (supers[i].getClassName().equals("java/lang/Object")) { + if (supers[i].getClassName().equals("java.lang.Object")) { supers[i] = null; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |