[Fb-contrib-commit] SF.net SVN: fb-contrib:[1594] trunk/fb-contrib
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-08-29 06:15:14
|
Revision: 1594
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1594&view=rev
Author: dbrosius
Date: 2010-08-29 06:15:07 +0000 (Sun, 29 Aug 2010)
Log Message:
-----------
remove javadoc from svn
Modified Paths:
--------------
trunk/fb-contrib/etc/findbugs.xml
trunk/fb-contrib/etc/messages.xml
Added Paths:
-----------
trunk/fb-contrib/samples/SEC_Sample.java
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java
Removed Paths:
-------------
trunk/fb-contrib/javadoc/
Modified: trunk/fb-contrib/etc/findbugs.xml
===================================================================
--- trunk/fb-contrib/etc/findbugs.xml 2010-08-29 05:31:24 UTC (rev 1593)
+++ trunk/fb-contrib/etc/findbugs.xml 2010-08-29 06:15:07 UTC (rev 1594)
@@ -211,6 +211,8 @@
<Detector class="com.mebigfatguy.fbcontrib.detect.PossibleUnsuspectedSerialization" speed="fast" reports="PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION" />
+ <Detector class="com.mebigfatguy.fbcontrib.detect.SideEffectConstructor" speed="fast" reports="SEC_SIDE_EFFECT_CONSTRUCTOR" />
+
<!-- BugPattern -->
<BugPattern abbrev="ISB" type="ISB_INEFFICIENT_STRING_BUFFERING" category="PERFORMANCE" />
@@ -369,5 +371,6 @@
<BugPattern abbrev="WOC" type="WOC_WRITE_ONLY_COLLECTION_LOCAL" category="CORRECTNESS" />
<BugPattern abbrev="WOC" type="WOC_WRITE_ONLY_COLLECTION_FIELD" category="CORRECTNESS" />
<BugPattern abbrev="UVA" type="UVA_USE_VAR_ARGS" category="STYLE" />
- <BugPattern abbrev="PUS" type="PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION" category="CORRECTNESS" />
+ <BugPattern abbrev="PUS" type="PUS_POSSIBLE_UNSUSPECTED_SERIALIZATION" category="CORRECTNESS" experimental="true" />
+ <BugPattern abbrev="SEC" type="SEC_SIDE_EFFECT_CONSTRUCTOR" category="STYLE" experimental="true" />
</FindbugsPlugin>
\ No newline at end of file
Modified: trunk/fb-contrib/etc/messages.xml
===================================================================
--- trunk/fb-contrib/etc/messages.xml 2010-08-29 05:31:24 UTC (rev 1593)
+++ trunk/fb-contrib/etc/messages.xml 2010-08-29 06:15:07 UTC (rev 1594)
@@ -1167,6 +1167,17 @@
]]>
</Details>
</Detector>
+
+ <Detector class="com.mebigfatguy.fbcontrib.detect.SideEffectConstructor">
+ <Details>
+ <![CDATA[
+ <p>This detector looks for object creation where the object isn't assigned to any variable or
+ field. This implies that the class operates through side effects in the constructor, which makes
+ for difficult to maintain code.</p>
+ <p>It is a fast detector</p>
+ ]]>
+ </Details>
+ </Detector>
<!-- BugPattern -->
@@ -3188,6 +3199,19 @@
]]>
</Details>
</BugPattern>
+
+ <BugPattern type="SEC_SIDE_EFFECT_CONSTRUCTOR">
+ <ShortDescription>Method uses a Side Effect Constructor</ShortDescription>
+ <LongDescription>Method {1} uses a Side Effect Constructor</LongDescription>
+ <Details>
+ <![CDATA[
+ <p>This method creates an object but does not assign this object to any variable or field.
+ This implies that the class operations through side effects in the constructor, which is a
+ pattern to use. Consider pull the side effect out of the constructor, into a separate method,
+ of into the calling method.
+ ]]>
+ </Details>
+ </BugPattern>
<!-- BugCode -->
@@ -3287,4 +3311,5 @@
<BugCode abbrev="WOC">Write Only Collection</BugCode>
<BugCode abbrev="UVA">Use Var Args</BugCode>
<BugCode abbrev="PUS">Possible Unsuspected Serialization</BugCode>
+ <BugCode abbrev="SEC">Side Effect Constructor</BugCode>
</MessageCollection>
Added: trunk/fb-contrib/samples/SEC_Sample.java
===================================================================
--- trunk/fb-contrib/samples/SEC_Sample.java (rev 0)
+++ trunk/fb-contrib/samples/SEC_Sample.java 2010-08-29 06:15:07 UTC (rev 1594)
@@ -0,0 +1,17 @@
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class SEC_Sample
+{
+ public SEC_Sample(List<SEC_Sample> l)
+ {
+ l.add(this);
+ }
+
+ public static void main(String[] args)
+ {
+ List<SEC_Sample> l = new ArrayList<SEC_Sample>();
+ new SEC_Sample(l);
+ }
+}
Property changes on: trunk/fb-contrib/samples/SEC_Sample.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java (rev 0)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.java 2010-08-29 06:15:07 UTC (rev 1594)
@@ -0,0 +1,85 @@
+/*
+ * fb-contrib - Auxiliary detectors for Java programs
+ * Copyright (C) 2005-2010 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 org.apache.bcel.classfile.Code;
+
+import edu.umd.cs.findbugs.BugInstance;
+import edu.umd.cs.findbugs.BugReporter;
+import edu.umd.cs.findbugs.BytecodeScanningDetector;
+
+/**
+ * looks for constructors that operate through side effects, specifically
+ * constructors that aren't assigned to any variable or field.
+ */
+public class SideEffectConstructor extends BytecodeScanningDetector {
+
+ private enum State {SAW_NOTHING, SAW_CTOR};
+ private final BugReporter bugReporter;
+ private State state;
+
+ /**
+ * constructs a SEC detector given the reporter to report bugs on
+ *
+ * @param bugReporter the sync of bug reports
+ */
+ public SideEffectConstructor(BugReporter bugReporter) {
+ this.bugReporter = bugReporter;
+ }
+
+ /**
+ * overrides the visitor to reset the state
+ *
+ * @param obj the context object of the currently parsed code
+ */
+ @Override
+ public void visitCode(Code obj) {
+ state = State.SAW_NOTHING;
+ super.visitCode(obj);
+ }
+ /**
+ * overrides the visitor to look for constructors who's value is
+ * popped off the stack, and not assigned.
+ *
+ * @param seen the opcode of the currently parse opcode
+ */
+ @Override
+ public void sawOpcode(int seen) {
+ switch (state) {
+ case SAW_NOTHING:
+ if (seen == INVOKESPECIAL) {
+ String name = getNameConstantOperand();
+ if ("<init>".equals(name)) {
+ state = State.SAW_CTOR;
+ }
+ }
+ break;
+
+ case SAW_CTOR:
+ if (seen == POP) {
+ bugReporter.reportBug(new BugInstance(this, "SEC_SIDE_EFFECT_CONSTRUCTOR", NORMAL_PRIORITY)
+ .addClass(this)
+ .addMethod(this)
+ .addSourceLine(this));
+ }
+ state = State.SAW_NOTHING;
+ break;
+ }
+ }
+}
Property changes on: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SideEffectConstructor.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.
|