Package com.mebigfatguy.fbcontrib.detect
Class SillynessPotPourri
java.lang.Object
edu.umd.cs.findbugs.visitclass.BetterVisitor
edu.umd.cs.findbugs.visitclass.PreorderVisitor
edu.umd.cs.findbugs.visitclass.AnnotationVisitor
edu.umd.cs.findbugs.visitclass.DismantleBytecode
edu.umd.cs.findbugs.BytecodeScanningDetector
com.mebigfatguy.fbcontrib.detect.SillynessPotPourri
- All Implemented Interfaces:
edu.umd.cs.findbugs.Detector,edu.umd.cs.findbugs.Priorities,org.apache.bcel.classfile.Visitor
@CustomUserValue
public class SillynessPotPourri
extends edu.umd.cs.findbugs.BytecodeScanningDetector
looks for silly bugs that are simple but do not fit into one large pattern.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static enum(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternbranch targets, to a set of branch instructionsprivate final edu.umd.cs.findbugs.BugReporterprivate static org.apache.bcel.classfile.JavaClassprivate Stringprivate booleanprivate booleanprivate booleanprivate booleanprivate intprivate int[]private intprivate static final Stringprivate edu.umd.cs.findbugs.OpcodeStackprivate Map<SillynessPotPourri.SPPUserValue, Integer> Fields inherited from class edu.umd.cs.findbugs.visitclass.DismantleBytecode
codeBytes, lineNumberTable, M_BR, M_CP, M_INT, M_PAD, M_R, M_UINTFields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionSillynessPotPourri(edu.umd.cs.findbugs.BugReporter bugReporter) constructs a SPP detector given the reporter to report bugs on -
Method Summary
Modifier and TypeMethodDescriptionprivate voidbitSetSilliness(String methodName) private voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidcheckForArrayParameter(edu.umd.cs.findbugs.OpcodeStack.Item item) private voidcheckForEmptyStringAndNullChecks(int seen) private voidcheckForTrim(edu.umd.cs.findbugs.OpcodeStack.Item item) private voidprivate voidcheckImmutableUsageOfStringBuilder(int reg) private voidprivate voidprivate voidprivate voidprivate voidprivate voidcheckStutterdAssignment(int seen, int reg) private voidchecks to see if the object that the method is being called on is also passed as a parameter.private voiddetermines whether this operation is storing the result of a trim() call, where the trimmed string was duplicated on the stack.private voidprivate voidprivate voidequalsSilliness(String className) private SillynessPotPourri.SPPUserValueprivate booleanhasRuntimeAnnotation(org.apache.bcel.classfile.Field field) private booleanhasToString(org.apache.bcel.classfile.JavaClass cls) private static booleanisBranchByteCode(int seen) private booleanlooksLikeStaticFieldValue(String constant) private voidpropertiesSilliness(String methodName) private SillynessPotPourri.SPPUserValueprivate SillynessPotPourri.SPPUserValueprivate voidprivate SillynessPotPourri.SPPUserValueprivate SillynessPotPourri.SPPUserValueprivate voidsawLoad(int seen) voidsawOpcode(int seen) implements the visitor to look for various silly bugsprivate SillynessPotPourri.SPPUserValuestringBufferSilliness(String methodName) private SillynessPotPourri.SPPUserValuestringSilliness(String methodName, String signature) voidvisitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) voidvisitCode(org.apache.bcel.classfile.Code obj) implements the visitor to reset the opcode stackvoidvisitField(org.apache.bcel.classfile.Field field) Methods inherited from class edu.umd.cs.findbugs.BytecodeScanningDetector
getClassContext, report, shouldVisitCodeMethods inherited from class edu.umd.cs.findbugs.visitclass.DismantleBytecode
afterOpcode, areOppositeBranches, atCatchBlock, beforeOpcode, getBranchFallThrough, getBranchOffset, getBranchTarget, getClassConstantOperand, getClassDescriptorOperand, getCodeByte, getConstantRefOperand, getDefaultSwitchOffset, getDottedClassConstantOperand, getFieldDescriptorOperand, getIntConstant, getLongConstant, getMaxPC, getMethodDescriptorOperand, getNameConstantOperand, getNextCodeByte, getNextOpcode, getNextPC, getOpcode, getPC, getPrevOpcode, getRefConstantOperand, getRefFieldIsStatic, getRegisterOperand, getSigConstantOperand, getStringConstantOperand, getSwitchLabels, getSwitchOffsets, getXClassOperand, getXFieldOperand, getXMethodOperand, isBranch, isMethodCall, isRegisterLoad, isRegisterStore, isRegisterStore, isReturn, isShift, isSwitch, isWideOpcode, printOpCode, sawBranchTo, sawClass, sawDouble, sawField, sawFloat, sawIMethod, sawInt, sawLong, sawMethod, sawRegister, sawString, visitMethods inherited from class edu.umd.cs.findbugs.visitclass.AnnotationVisitor
getAnnotationParameterAsEnum, getAnnotationParameterAsString, getAnnotationParameterAsStringArray, visitAnnotation, visitAnnotation, visitParameterAnnotation, visitParameterAnnotation, visitSyntheticParameterAnnotationMethods inherited from class edu.umd.cs.findbugs.visitclass.PreorderVisitor
amVisitingMainMethod, asUnsignedByte, doVisitMethod, getClassDescriptor, getClassName, getCode, getConstantPool, getDottedClassName, getDottedFieldSig, getDottedMethodSig, getDottedSuperclassName, getField, getFieldDescriptor, getFieldIsStatic, getFieldName, getFieldSig, getFullyQualifiedFieldName, getFullyQualifiedMethodName, getMethod, getMethodDescriptor, getMethodName, getMethodSig, getMethodVisitOrder, getNumberArguments, getNumberMethodArguments, getPackageName, getSizeOfSurroundingTryBlock, getSizeOfSurroundingTryBlock, getSourceFile, getStringFromIndex, getSuperclassName, getSurroundingCaughtExceptions, getSurroundingCaughtExceptions, getSurroundingCaughtExceptionTypes, getSurroundingTryBlock, getSurroundingTryBlock, getThisClass, getXClass, getXField, getXMethod, hasInterestingClass, hasInterestingMethod, isVisitMethodsInCallOrder, setupVisitorForClass, setVisitMethodsInCallOrder, shouldVisit, toString, visitAfter, visitAfter, visitAnnotationDefault, visitAnnotationEntry, visitBootstrapMethods, visitConstantInvokeDynamic, visitConstantMethodHandle, visitConstantMethodType, visitConstantModule, visitConstantPackage, visitConstantPool, visitEnclosingMethod, visitingField, visitingMethod, visitInnerClasses, visitJavaClass, visitLineNumberTable, visitLocalVariableTable, visitMethodParameters, visitParameterAnnotationEntry, visitStackMap, visitStackMapEntryMethods inherited from class edu.umd.cs.findbugs.visitclass.BetterVisitor
clone, report, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitCodeException, visitConstantClass, visitConstantDouble, visitConstantFieldref, visitConstantFloat, visitConstantInteger, visitConstantInterfaceMethodref, visitConstantLong, visitConstantMethodref, visitConstantNameAndType, visitConstantString, visitConstantUtf8, visitConstantValue, visitDeprecated, visitExceptionTable, visitInnerClass, visitLineNumber, visitLocalVariable, visitLocalVariableTypeTable, visitMethod, visitSignature, visitSourceFile, visitSynthetic, visitUnknownMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.bcel.classfile.Visitor
visitConstantDynamic, visitMethodParameter, visitModule, visitModuleExports, visitModuleMainClass, visitModuleOpens, visitModulePackages, visitModuleProvides, visitModuleRequires, visitNestHost, visitNestMembers, visitRecord, visitRecordComponent, visitStackMapType
-
Field Details
-
collectionInterfaces
-
oddMissingEqualsClasses
-
LITERAL
- See Also:
-
APPEND_PATTERN
-
calendarClass
private static org.apache.bcel.classfile.JavaClass calendarClass -
POSSIBLE_STATIC_FIELD_CLASSES
-
methodsThatAreSillyOnStringLiterals
-
bugReporter
private final edu.umd.cs.findbugs.BugReporter bugReporter -
toStringClasses
-
stack
private edu.umd.cs.findbugs.OpcodeStack stack -
lastPCs
private int[] lastPCs -
lastOpcode
private int lastOpcode -
lastReg
private int lastReg -
lastIfEqWasBoolean
private boolean lastIfEqWasBoolean -
lastLoadWasString
private boolean lastLoadWasString -
branchTargets
branch targets, to a set of branch instructions -
staticConstants
-
trimLocations
-
possibleStatics
-
clsName
-
isInterface
private boolean isInterface -
isCtor
private boolean isCtor
-
-
Constructor Details
-
SillynessPotPourri
public SillynessPotPourri(edu.umd.cs.findbugs.BugReporter bugReporter) constructs a SPP detector given the reporter to report bugs on- Parameters:
bugReporter- the sync of bug reports
-
-
Method Details
-
visitField
public void visitField(org.apache.bcel.classfile.Field field) - Specified by:
visitFieldin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitFieldin classedu.umd.cs.findbugs.visitclass.BetterVisitor
-
visitClassContext
public void visitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) - Specified by:
visitClassContextin interfaceedu.umd.cs.findbugs.Detector- Overrides:
visitClassContextin classedu.umd.cs.findbugs.BytecodeScanningDetector
-
visitCode
public void visitCode(org.apache.bcel.classfile.Code obj) implements the visitor to reset the opcode stack- Specified by:
visitCodein interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitCodein classedu.umd.cs.findbugs.visitclass.PreorderVisitor- Parameters:
obj- the context object for the currently parsed Code
-
sawOpcode
public void sawOpcode(int seen) implements the visitor to look for various silly bugs- Overrides:
sawOpcodein classedu.umd.cs.findbugs.visitclass.DismantleBytecode- Parameters:
seen- the opcode of the currently parsed instruction
-
checkImproperToCharArrayUse
private void checkImproperToCharArrayUse() -
sawIntConst
-
sawLoad
private void sawLoad(int seen) -
checkTrimDupStore
private void checkTrimDupStore()determines whether this operation is storing the result of a trim() call, where the trimmed string was duplicated on the stack. If it was, it clears any trim uservalue that was left behind in the dupped stack object -
checkStutterdAssignment
private void checkStutterdAssignment(int seen, int reg) -
checkImmutableUsageOfStringBuilder
private void checkImmutableUsageOfStringBuilder(int reg) -
checkCompareToNaNFloat
private void checkCompareToNaNFloat() -
checkCompareToNaNDouble
private void checkCompareToNaNDouble() -
checkApproximationsOfMathConstants
private void checkApproximationsOfMathConstants() -
checkForUselessTernaryReturn
private void checkForUselessTernaryReturn() -
checkEqualsStringBufferLength
private void checkEqualsStringBufferLength() -
checkNotEqualsStringBuilderLength
private void checkNotEqualsStringBuilderLength() -
checkNullAndInstanceOf
private void checkNullAndInstanceOf() -
checkSizeEquals0
private void checkSizeEquals0() -
checkForEmptyStringAndNullChecks
private void checkForEmptyStringAndNullChecks(int seen) -
checkPossibleStatic
private void checkPossibleStatic() -
isBranchByteCode
private static boolean isBranchByteCode(int seen) -
sawInvokeStatic
-
checkForArrayParameter
private void checkForArrayParameter(edu.umd.cs.findbugs.OpcodeStack.Item item) -
sawInvokeVirtual
- Throws:
ClassNotFoundException
-
bitSetSilliness
-
stringBufferSilliness
-
stringSilliness
-
checkForTrim
private void checkForTrim(edu.umd.cs.findbugs.OpcodeStack.Item item) -
equalsSilliness
-
booleanSilliness
private void booleanSilliness() -
calendarBeforeAfterSilliness
private void calendarBeforeAfterSilliness() -
defaultToStringSilliness
- Throws:
ClassNotFoundException
-
propertiesSilliness
-
sawInvokeInterface
-
checkThisParm
private void checkThisParm()checks to see if the object that the method is being called on is also passed as a parameter. To rule out simple mathish like calls like a.mul(a); only check two plus parameter calls. -
sawInvokeSpecial
private void sawInvokeSpecial() -
looksLikeStaticFieldValue
-
hasToString
- Throws:
ClassNotFoundException
-
getTrimUserValue
-
checkTrimLocations
private void checkTrimLocations() -
hasRuntimeAnnotation
private boolean hasRuntimeAnnotation(org.apache.bcel.classfile.Field field)
-