Package edu.umd.cs.findbugs.detect
Class Naming
- java.lang.Object
-
- edu.umd.cs.findbugs.visitclass.BetterVisitor
-
- edu.umd.cs.findbugs.visitclass.PreorderVisitor
-
- edu.umd.cs.findbugs.detect.Naming
-
- All Implemented Interfaces:
Detector
,Priorities
,org.apache.bcel.classfile.Visitor
public class Naming extends PreorderVisitor implements Detector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Naming.NamingProperty
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
baseClassName
private BugReporter
bugReporter
(package private) java.util.HashMap<java.lang.String,java.util.TreeSet<XMethod>>
canonicalToXMethod
(package private) boolean
classIsPublicOrProtected
(package private) boolean
hasBadFieldNames
(package private) boolean
hasBadMethodNames
private boolean
isEclipseNLS
Eclipse uses reflection to initialize NLS message bundles.private static java.util.regex.Pattern
sigType
(package private) java.util.HashSet<java.lang.String>
visited
-
Fields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description Naming(BugReporter bugReporter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
allAbstract(java.util.Set<XMethod> overrides)
private boolean
badFieldName(org.apache.bcel.classfile.Field obj)
private boolean
badMethodName(java.lang.String mName)
private boolean
checkNonSuper(XMethod m, java.util.Set<XMethod> others)
private boolean
checkSuper(XMethod m, java.util.Set<XMethod> others)
private boolean
codeDoesSomething(org.apache.bcel.classfile.Code code)
static boolean
confusingMethodNamesWrongCapitalization(XMethod m1, XMethod m2)
static boolean
confusingMethodNamesWrongPackage(XMethod m1, XMethod m2)
static XMethod
definedIn(org.apache.bcel.classfile.JavaClass clazz, XMethod m)
private static org.apache.bcel.classfile.Method
findVoidConstructor(org.apache.bcel.classfile.JavaClass clazz)
private static java.lang.String
getSignatureOfOuterClass(org.apache.bcel.classfile.JavaClass obj)
private static boolean
isVoidConstructor(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Method m)
private boolean
markedAsNotUsable(org.apache.bcel.classfile.Method obj)
private static boolean
mightInheritFromException(ClassDescriptor d)
Determine whether the class descriptor ultimately inherits from java.lang.Exceptionprivate static java.lang.String
removePackageNamesFromSignature(java.lang.String sig)
void
report()
This method is called after all classes to be visited.boolean
sameSimpleName(java.lang.String class1, java.lang.String class2)
java.lang.String
stripPackageName(java.lang.String className)
void
visit(org.apache.bcel.classfile.Field obj)
void
visit(org.apache.bcel.classfile.JavaClass obj)
void
visit(org.apache.bcel.classfile.Method obj)
void
visitClassContext(ClassContext classContext)
Visit the ClassContext for a class which should be analyzed for instances of bug patterns.void
visitJavaClass(org.apache.bcel.classfile.JavaClass obj)
-
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, visitLineNumberTable, visitLocalVariableTable, visitMethodParameters, visitParameterAnnotation, visitParameterAnnotationEntry, visitStackMap, visitStackMapEntry
-
Methods 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, visitCodeException, visitConstantClass, visitConstantDouble, visitConstantFieldref, visitConstantFloat, visitConstantInteger, visitConstantInterfaceMethodref, visitConstantLong, visitConstantMethodref, visitConstantNameAndType, visitConstantString, visitConstantUtf8, visitConstantValue, visitDeprecated, visitExceptionTable, visitField, visitInnerClass, visitLineNumber, visitLocalVariable, visitLocalVariableTypeTable, visitMethod, visitSignature, visitSourceFile, visitSynthetic, visitUnknown
-
-
-
-
Field Detail
-
baseClassName
java.lang.String baseClassName
-
classIsPublicOrProtected
boolean classIsPublicOrProtected
-
canonicalToXMethod
java.util.HashMap<java.lang.String,java.util.TreeSet<XMethod>> canonicalToXMethod
-
visited
java.util.HashSet<java.lang.String> visited
-
bugReporter
private final BugReporter bugReporter
-
hasBadMethodNames
boolean hasBadMethodNames
-
hasBadFieldNames
boolean hasBadFieldNames
-
isEclipseNLS
private boolean isEclipseNLS
Eclipse uses reflection to initialize NLS message bundles. Classes which using this mechanism are usually extending org.eclipse.osgi.util.NLS class and contains lots of public static String fields which are used as message Constants. Unfortunately these fields often has bad names which does not follow Java code convention, so FB reports tons of warnings for such Eclipse message fields.- See Also:
MutableStaticFields
-
sigType
private static final java.util.regex.Pattern sigType
-
-
Constructor Detail
-
Naming
public Naming(BugReporter bugReporter)
-
-
Method Detail
-
definedIn
@CheckForNull public static XMethod definedIn(org.apache.bcel.classfile.JavaClass clazz, XMethod m)
-
confusingMethodNamesWrongCapitalization
public static boolean confusingMethodNamesWrongCapitalization(XMethod m1, XMethod m2)
-
confusingMethodNamesWrongPackage
public static boolean confusingMethodNamesWrongPackage(XMethod m1, XMethod m2)
-
visitClassContext
public void visitClassContext(ClassContext classContext)
Description copied from interface:Detector
Visit the ClassContext for a class which should be analyzed for instances of bug patterns.- Specified by:
visitClassContext
in interfaceDetector
- Parameters:
classContext
- the ClassContext
-
allAbstract
private boolean allAbstract(java.util.Set<XMethod> overrides)
-
report
public void report()
Description copied from interface:Detector
This method is called after all classes to be visited. It should be used by any detectors which accumulate information over all visited classes to generate results.
-
stripPackageName
public java.lang.String stripPackageName(java.lang.String className)
-
sameSimpleName
public boolean sameSimpleName(java.lang.String class1, java.lang.String class2)
-
visitJavaClass
public void visitJavaClass(org.apache.bcel.classfile.JavaClass obj)
- Specified by:
visitJavaClass
in interfaceorg.apache.bcel.classfile.Visitor
- Overrides:
visitJavaClass
in classPreorderVisitor
-
mightInheritFromException
private static boolean mightInheritFromException(ClassDescriptor d)
Determine whether the class descriptor ultimately inherits from java.lang.Exception- Parameters:
d
- class descriptor we want to check- Returns:
- true iff the descriptor ultimately inherits from Exception
-
visit
public void visit(org.apache.bcel.classfile.JavaClass obj)
- Overrides:
visit
in classBetterVisitor
-
visit
public void visit(org.apache.bcel.classfile.Field obj)
- Overrides:
visit
in classBetterVisitor
-
badFieldName
private boolean badFieldName(org.apache.bcel.classfile.Field obj)
-
getSignatureOfOuterClass
@CheckForNull private static java.lang.String getSignatureOfOuterClass(org.apache.bcel.classfile.JavaClass obj)
-
markedAsNotUsable
private boolean markedAsNotUsable(org.apache.bcel.classfile.Method obj)
-
findVoidConstructor
@CheckForNull private static org.apache.bcel.classfile.Method findVoidConstructor(org.apache.bcel.classfile.JavaClass clazz)
-
visit
public void visit(org.apache.bcel.classfile.Method obj)
- Overrides:
visit
in classBetterVisitor
-
isVoidConstructor
private static boolean isVoidConstructor(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Method m)
-
badMethodName
private boolean badMethodName(java.lang.String mName)
-
codeDoesSomething
private boolean codeDoesSomething(org.apache.bcel.classfile.Code code)
-
removePackageNamesFromSignature
private static java.lang.String removePackageNamesFromSignature(java.lang.String sig)
-
-