Skip to content

Commit

Permalink
Add findbugs configuration, and fix a few of the simpler problems
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfl committed Sep 23, 2011
1 parent 69665e7 commit fe50a0c
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 31 deletions.
129 changes: 129 additions & 0 deletions .fbprefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#FindBugs User Preferences
#Tue Sep 20 20:18:08 EDT 2011
detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
detectorBadAppletConstructor=BadAppletConstructor|false
detectorBadResultSetAccess=BadResultSetAccess|true
detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
detectorBadUseOfReturnValue=BadUseOfReturnValue|true
detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
detectorBooleanReturnNull=BooleanReturnNull|true
detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
detectorCheckTypeQualifiers=CheckTypeQualifiers|true
detectorCloneIdiom=CloneIdiom|true
detectorComparatorIdiom=ComparatorIdiom|true
detectorConfusedInheritance=ConfusedInheritance|true
detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
detectorCrossSiteScripting=CrossSiteScripting|true
detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
detectorDontUseEnum=DontUseEnum|true
detectorDroppedException=DroppedException|true
detectorDumbMethodInvocations=DumbMethodInvocations|true
detectorDumbMethods=DumbMethods|true
detectorDuplicateBranches=DuplicateBranches|true
detectorEmptyZipFileEntry=EmptyZipFileEntry|true
detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
detectorFinalizerNullsFields=FinalizerNullsFields|true
detectorFindBadCast2=FindBadCast2|true
detectorFindBadForLoop=FindBadForLoop|true
detectorFindCircularDependencies=FindCircularDependencies|false
detectorFindDeadLocalStores=FindDeadLocalStores|true
detectorFindDoubleCheck=FindDoubleCheck|true
detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
detectorFindFinalizeInvocations=FindFinalizeInvocations|true
detectorFindFloatEquality=FindFloatEquality|true
detectorFindHEmismatch=FindHEmismatch|true
detectorFindInconsistentSync2=FindInconsistentSync2|true
detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
detectorFindMaskedFields=FindMaskedFields|true
detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
detectorFindNakedNotify=FindNakedNotify|true
detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true
detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true
detectorFindNonShortCircuit=FindNonShortCircuit|true
detectorFindNullDeref=FindNullDeref|true
detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
detectorFindOpenStream=FindOpenStream|true
detectorFindPuzzlers=FindPuzzlers|true
detectorFindRefComparison=FindRefComparison|true
detectorFindReturnRef=FindReturnRef|true
detectorFindRunInvocations=FindRunInvocations|true
detectorFindSelfComparison=FindSelfComparison|true
detectorFindSelfComparison2=FindSelfComparison2|true
detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
detectorFindSpinLoop=FindSpinLoop|true
detectorFindSqlInjection=FindSqlInjection|true
detectorFindTwoLockWait=FindTwoLockWait|true
detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
detectorFindUnconditionalWait=FindUnconditionalWait|true
detectorFindUninitializedGet=FindUninitializedGet|true
detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
detectorFindUnreleasedLock=FindUnreleasedLock|true
detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
detectorFindUnsyncGet=FindUnsyncGet|true
detectorFindUselessControlFlow=FindUselessControlFlow|true
detectorFormatStringChecker=FormatStringChecker|true
detectorHugeSharedStringConstants=HugeSharedStringConstants|true
detectorIDivResultCastToDouble=IDivResultCastToDouble|true
detectorIncompatMask=IncompatMask|true
detectorInconsistentAnnotations=InconsistentAnnotations|true
detectorInefficientMemberAccess=InefficientMemberAccess|false
detectorInefficientToArray=InefficientToArray|true
detectorInfiniteLoop=InfiniteLoop|true
detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false
detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
detectorInitializationChain=InitializationChain|true
detectorInstantiateStaticClass=InstantiateStaticClass|true
detectorInvalidJUnitTest=InvalidJUnitTest|true
detectorIteratorIdioms=IteratorIdioms|true
detectorLazyInit=LazyInit|true
detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
detectorMethodReturnCheck=MethodReturnCheck|true
detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
detectorMutableLock=MutableLock|true
detectorMutableStaticFields=MutableStaticFields|true
detectorNaming=Naming|true
detectorNumberConstructor=NumberConstructor|true
detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
detectorPublicSemaphores=PublicSemaphores|false
detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
detectorRedundantInterfaces=RedundantInterfaces|true
detectorRepeatedConditionals=RepeatedConditionals|true
detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
detectorSerializableIdiom=SerializableIdiom|true
detectorStartInConstructor=StartInConstructor|true
detectorStaticCalendarDetector=StaticCalendarDetector|true
detectorStringConcatenation=StringConcatenation|true
detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
detectorSwitchFallthrough=SwitchFallthrough|true
detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
detectorURLProblems=URLProblems|true
detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
detectorUnnecessaryMath=UnnecessaryMath|true
detectorUnreadFields=UnreadFields|true
detectorUseObjectEquals=UseObjectEquals|false
detectorUselessSubclassMethod=UselessSubclassMethod|false
detectorVarArgsProblems=VarArgsProblems|true
detectorVolatileUsage=VolatileUsage|true
detectorWaitInLoop=WaitInLoop|true
detectorWrongMapIterator=WrongMapIterator|true
detectorXMLFactoryBypass=XMLFactoryBypass|true
detector_threshold=2
effort=default
excludefilter0=FindBugsExcludeFilter.xml
filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false
filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL|
includefilter0=FindBugsIncludeFilter.xml
run_at_full_build=false
13 changes: 13 additions & 0 deletions FindBugsExcludeFilter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<FindBugsFilter>

<Match>
<Package name="~org\.jdom2\.test\..*" />
</Match>
<Match>
<Class name="~Test.*" />
</Match>
<Match>
<Package name="~.*\.contrib\..*" />
</Match>

</FindBugsFilter>
11 changes: 11 additions & 0 deletions FindBugsIncludeFilter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<FindBugsFilter>

<Match>
<Package name="org.jdom2" />
</Match>
<Match>
<Package name="~org\.jdom2\..*" />
</Match>


</FindBugsFilter>
1 change: 0 additions & 1 deletion core/src/java/org/jdom2/JDOMException.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ private static Throwable getNestedExceptionFromField(
Class objectClass = parent.getClass();
if (testClass.isAssignableFrom(objectClass)) {
// Use reflection to call the specified method.
Class[] argClasses = new Class[0];
Field field = testClass.getField(fieldName);
return (Throwable)field.get(parent);
}
Expand Down
17 changes: 0 additions & 17 deletions core/src/java/org/jdom2/input/DOMBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
*/
public class DOMBuilder {

/** Adapter class to use */
private String adapterClass;

/** The factory for creating new JDOM objects */
private JDOMFactory factory = new DefaultJDOMFactory();

Expand All @@ -91,20 +88,6 @@ public class DOMBuilder {
public DOMBuilder() {
}

/**
* This creates a new DOMBuilder using the specified DOMAdapter
* implementation as a way to choose the underlying parser.
* The underlying parser will not validate.
*
* @param adapterClass <code>String</code> name of class
* to use for DOM building.
* @deprecated
*/
@Deprecated
public DOMBuilder(String adapterClass) {
this.adapterClass = adapterClass;
}

/*
* This sets a custom JDOMFactory for the builder. Use this to build
* the tree with your own subclasses of the JDOM classes.
Expand Down
2 changes: 1 addition & 1 deletion core/src/java/org/jdom2/output/XMLOutputter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ private NamespaceStack createNamespaceStack() {
* declare a NamespaceStack parameter, but we don't want to
* declare the parent NamespaceStack class as public.
*/
protected class NamespaceStack
protected static class NamespaceStack
extends org.jdom2.output.NamespaceStack
{
}
Expand Down
4 changes: 3 additions & 1 deletion core/src/java/org/jdom2/xpath/jaxen/JDOMXPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ public void addNamespace(Namespace namespace) {
try {
xPath.addNamespace(namespace.getPrefix(), namespace.getURI());
}
catch (JaxenException ex1) { /* Can't happen here. */ }
catch (JaxenException ex1) {
/* Can't happen here. */
}
}

/**
Expand Down
16 changes: 5 additions & 11 deletions test/src/java/org/jdom2/test/cases/input/TestDOMBuilder.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.jdom2.test.cases.input;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.CharArrayWriter;
import java.io.IOException;
import java.util.List;
import java.util.TreeMap;

import org.jdom2.Attribute;
import org.jdom2.DefaultJDOMFactory;
import org.jdom2.DocType;
import org.jdom2.Document;
Expand All @@ -27,13 +28,6 @@ public void testDOMBuilder() {
assertNotNull(db);
}

@Test
public void testDOMBuilderString() {
@SuppressWarnings("deprecation")
DOMBuilder db = new DOMBuilder("doesnothing");
assertNotNull(db);
}

@Test
public void testFactory() {
DOMBuilder db = new DOMBuilder();
Expand Down

0 comments on commit fe50a0c

Please sign in to comment.