Package com.mebigfatguy.fbcontrib.detect
Class UnboundMethodTemplateParameter
java.lang.Object
edu.umd.cs.findbugs.visitclass.BetterVisitor
edu.umd.cs.findbugs.visitclass.PreorderVisitor
com.mebigfatguy.fbcontrib.detect.UnboundMethodTemplateParameter
- All Implemented Interfaces:
edu.umd.cs.findbugs.Detector,edu.umd.cs.findbugs.Priorities,org.apache.bcel.classfile.Visitor
public class UnboundMethodTemplateParameter
extends edu.umd.cs.findbugs.visitclass.PreorderVisitor
implements edu.umd.cs.findbugs.Detector
Looks for methods that declare method level template parameter(s) that are
not bound to any of the method's parameters, and thus is not adding any
validation/type safety to the method, and is just confusing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static classa simple data only class for holding the template parameters and method signature -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final edu.umd.cs.findbugs.BugReporterprivate static final Patternprivate static final PatternFields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanisTemplateParent(String templateType, UnboundMethodTemplateParameter.TemplateItem... items) looks to see if this templateType is a parent of another template typeprivate static UnboundMethodTemplateParameter.TemplateSignatureparseSignatureAttribute(org.apache.bcel.classfile.Signature signatureAttribute) builds a template signature object based on the signature attribute of the methodvoidreport()voidvisitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) implements the visitor to accept the class for visitingvoidvisitMethod(org.apache.bcel.classfile.Method obj) implements the visitor to find methods that declare template parameters that are not bound to any parameter.Methods 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, visitAnnotation, visitAnnotationDefault, visitAnnotationEntry, visitBootstrapMethods, visitCode, visitConstantInvokeDynamic, visitConstantMethodHandle, visitConstantMethodType, visitConstantModule, visitConstantPackage, visitConstantPool, visitEnclosingMethod, visitingField, visitingMethod, visitInnerClasses, visitJavaClass, visitLineNumberTable, visitLocalVariableTable, visitMethodParameters, visitParameterAnnotation, 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, visit, visitCodeException, visitConstantClass, visitConstantDouble, visitConstantFieldref, visitConstantFloat, visitConstantInteger, visitConstantInterfaceMethodref, visitConstantLong, visitConstantMethodref, visitConstantNameAndType, visitConstantString, visitConstantUtf8, visitConstantValue, visitDeprecated, visitExceptionTable, visitField, visitInnerClass, visitLineNumber, visitLocalVariable, visitLocalVariableTypeTable, 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
-
TEMPLATED_SIGNATURE
-
TEMPLATE
-
bugReporter
private final edu.umd.cs.findbugs.BugReporter bugReporter
-
-
Constructor Details
-
UnboundMethodTemplateParameter
public UnboundMethodTemplateParameter(edu.umd.cs.findbugs.BugReporter bugReporter)
-
-
Method Details
-
visitClassContext
public void visitClassContext(edu.umd.cs.findbugs.ba.ClassContext classContext) implements the visitor to accept the class for visiting- Specified by:
visitClassContextin interfaceedu.umd.cs.findbugs.Detector- Parameters:
classContext- the context object of the currently parsed class
-
visitMethod
public void visitMethod(org.apache.bcel.classfile.Method obj) implements the visitor to find methods that declare template parameters that are not bound to any parameter.- Specified by:
visitMethodin interfaceorg.apache.bcel.classfile.Visitor- Overrides:
visitMethodin classedu.umd.cs.findbugs.visitclass.BetterVisitor- Parameters:
obj- the context object of the currently parsed method
-
report
public void report()- Specified by:
reportin interfaceedu.umd.cs.findbugs.Detector
-
isTemplateParent
private boolean isTemplateParent(String templateType, UnboundMethodTemplateParameter.TemplateItem... items) looks to see if this templateType is a parent of another template type- Parameters:
templateType- the type to look foritems- the items to search- Returns:
- whether this template type is something another template type extends
-
parseSignatureAttribute
@Nullable private static UnboundMethodTemplateParameter.TemplateSignature parseSignatureAttribute(org.apache.bcel.classfile.Signature signatureAttribute) builds a template signature object based on the signature attribute of the method- Parameters:
signatureAttribute- the signature attribute- Returns:
- a template signature if there are templates defined, otherwise null
-