[Fb-contrib-commit] SF.net SVN: fb-contrib:[1357] trunk/fb-contrib
Brought to you by:
dbrosius
|
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.
|