Class Naming

All Implemented Interfaces:
Detector, Priorities, org.apache.bcel.classfile.Visitor

public class Naming extends PreorderVisitor implements Detector
  • Field Details

    • baseClassName

      String baseClassName
    • classIsPublicOrProtected

      boolean classIsPublicOrProtected
    • canonicalToXMethod

      HashMap<String,TreeSet<XMethod>> canonicalToXMethod
    • visited

      HashSet<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:
    • sigType

      private static final Pattern sigType
  • Constructor Details

  • Method Details

    • 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 interface Detector
      Parameters:
      classContext - the ClassContext
    • checkSuper

      private boolean checkSuper(XMethod m, Set<XMethod> others)
    • allAbstract

      private boolean allAbstract(Set<XMethod> overrides)
    • checkNonSuper

      private boolean checkNonSuper(XMethod m, Set<XMethod> others)
    • 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.
      Specified by:
      report in interface Detector
    • stripPackageName

      public String stripPackageName(String className)
    • sameSimpleName

      public boolean sameSimpleName(String class1, String class2)
    • visitJavaClass

      public void visitJavaClass(org.apache.bcel.classfile.JavaClass obj)
      Specified by:
      visitJavaClass in interface org.apache.bcel.classfile.Visitor
      Overrides:
      visitJavaClass in class PreorderVisitor
    • 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 class BetterVisitor
    • visit

      public void visit(org.apache.bcel.classfile.Field obj)
      Overrides:
      visit in class BetterVisitor
    • badFieldName

      private boolean badFieldName(org.apache.bcel.classfile.Field obj)
    • getSignatureOfOuterClass

      @CheckForNull private static 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 class BetterVisitor
    • isVoidConstructor

      private static boolean isVoidConstructor(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Method m)
    • badMethodName

      private boolean badMethodName(String mName)
    • codeDoesSomething

      private boolean codeDoesSomething(org.apache.bcel.classfile.Code code)
    • removePackageNamesFromSignature

      private static String removePackageNamesFromSignature(String sig)