[Fb-contrib-commit] SF.net SVN: fb-contrib:[1660] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2011-03-25 23:27:20
|
Revision: 1660
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1660&view=rev
Author: dbrosius
Date: 2011-03-25 23:27:14 +0000 (Fri, 25 Mar 2011)
Log Message:
-----------
formatting
Modified Paths:
--------------
trunk/fb-contrib/samples/BAS_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
Modified: trunk/fb-contrib/samples/BAS_Sample.java
===================================================================
--- trunk/fb-contrib/samples/BAS_Sample.java 2011-03-25 23:26:22 UTC (rev 1659)
+++ trunk/fb-contrib/samples/BAS_Sample.java 2011-03-25 23:27:14 UTC (rev 1660)
@@ -1,10 +1,14 @@
import java.util.Calendar;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
@SuppressWarnings("all")
public class BAS_Sample
{
+ private final Map<String, String> m = new HashMap<String, String>();
+
public void testIfScope(String s)
{
Object o = new Object();
@@ -147,5 +151,4 @@
System.out.println(delta);
}
}
-
}
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2011-03-25 23:26:22 UTC (rev 1659)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/MethodReturnsConstant.java 2011-03-25 23:27:14 UTC (rev 1660)
@@ -1,17 +1,17 @@
/*
* fb-contrib - Auxiliary detectors for Java programs
* Copyright (C) 2005-2011 Dave Brosius
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -29,12 +29,12 @@
import edu.umd.cs.findbugs.ba.ClassContext;
/**
- * looks for private methods that can only return one constant value.
+ * looks for private methods that can only return one constant value.
* either the class should not return a value, or perhaps a branch was missed.
*/
-public class MethodReturnsConstant extends BytecodeScanningDetector
+public class MethodReturnsConstant extends BytecodeScanningDetector
{
- private BugReporter bugReporter;
+ private final BugReporter bugReporter;
private OpcodeStack stack;
private Object returnConstant;
private boolean methodSuspect;
@@ -47,20 +47,20 @@
public MethodReturnsConstant(BugReporter bugReporter) {
this.bugReporter = bugReporter;
}
-
+
@Override
public void visitClassContext(ClassContext classContext) {
- try {
+ try {
stack = new OpcodeStack();
super.visitClassContext(classContext);
} finally {
stack = null;
}
}
-
+
/**
* implements the visitor to reset the stack and proceed for private methods
- *
+ *
* @param obj the context object of the currently parsed code block
*/
@Override
@@ -79,27 +79,29 @@
BugInstance bi = new BugInstance(this, "MRC_METHOD_RETURNS_CONSTANT", ((aFlags & Constants.ACC_PRIVATE) != 0) ? NORMAL_PRIORITY : LOW_PRIORITY)
.addClass(this)
.addMethod(this);
- if (returnPC >= 0)
+ if (returnPC >= 0) {
bi.addSourceLine(this, returnPC);
-
+ }
+
bi.addString(returnConstant.toString());
bugReporter.reportBug(bi);
}
}
}
-
+
/**
* implements the visitor to look for methods that return a constant
- *
+ *
* @param seen the opcode of the currently parsed instruction
*/
@Override
public void sawOpcode(int seen) {
boolean sawSBToString = false;
try {
- if (!methodSuspect)
+ if (!methodSuspect) {
return;
-
+ }
+
if ((seen >= IRETURN) && (seen <= ARETURN)) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item item = stack.getStackItem(0);
@@ -117,12 +119,12 @@
methodSuspect = false;
return;
}
-
+
returnConstant = constant;
}
} else if ((seen == GOTO) || (seen == GOTO_W)) {
if (stack.getStackDepth() > 0) {
- methodSuspect = false; //Trinaries confuse us to much, if the code has a trinary well - oh well
+ methodSuspect = false; //Trinaries confuse us too much, if the code has a trinary well - oh well
}
} else if (seen == INVOKEVIRTUAL) {
String clsName = getClassConstantOperand();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|