Class MethodNameCheck

All Implemented Interfaces:
Configurable, Contextualizable

Checks that method names conform to a specified pattern.

Also, checks if a method name has the same name as the residing class. The default is false (it is not allowed). It is legal in Java to have method with the same name as a class. As long as a return type is specified it is a method and not a constructor which it could be easily confused as. Does not check-style the name of an overridden methods because the developer does not have a choice in renaming such methods.

Since:
3.0
  • Field Details

    • MSG_KEY

      public static final String MSG_KEY
      A key is pointing to the warning message text in "messages.properties" file.
      See Also:
    • allowClassName

      private boolean allowClassName
      Control whether to allow a method name to have the same name as the enclosing class name. Setting this property false helps to avoid confusion between constructors and methods.
  • Constructor Details

    • MethodNameCheck

      public MethodNameCheck()
      Creates a new MethodNameCheck instance.
  • Method Details