| Home >> All >> com >> puppycrawl >> tools >> checkstyle >> checks >> [ design Javadoc ] |
com.puppycrawl.tools.checkstyle.checks.design: Javadoc index of package com.puppycrawl.tools.checkstyle.checks.design.
Package Samples:
com.puppycrawl.tools.checkstyle.checks.design
Classes:
DesignForExtensionCheck: Checks that classes are designed for inheritance. More specifically, it enforces a programming style where superclasses provide empty "hooks" that can be implemented by subclasses. The exact rule is that nonprivate, nonstatic methods in nonfinal classes (or classes that do not only have private constructors) must either be abstract or final or have an empty implementation This protects superclasses against beeing broken by subclasses. The downside is that subclasses are limited in their flexibility, in particular they cannot prevent execution of code in the superclass, but that also means that ...
ThrowsCountCheck: Restricts throws statements to a specified count (default = 1). Rationale: Exceptions form part of a methods interface. Declaring a method to throw too many differently rooted exceptions makes exception handling onerous and leads to poor programming practices such as catch (Exception). This check forces developers to put exceptions into a heirachy such that in the simplest case, only one type of exception need be checked for by a caller but allows any sub-classes to be caught specifically if necessary.
MutableExceptionCheck: Ensures that exceptions (defined as any class name conforming to some regular expression) are immutable. That is, have only final fields. Rationale: Exception instances should represent an error condition. Having non final fields not only allows the state to be modified by accident and therefore mask the original condition but also allows developers to accidentally forget to initialise state thereby leading to code catching the exception to draw incorrect conclusions based on the state.
InterfaceIsTypeCheck: Implements Bloch, Effective Java, Item 17 - Use Interfaces only to define types. An interface should describe a type , it is therefore inappropriate to define an interface that does not contain any methods but only constants. The check can be configured to also disallow marker interfaces like java.io.Serializable , that do not contain methods or constants at all.
VisibilityModifierCheck: Checks visibility of class members. Only static final members may be public, other class members must be private unless allowProtected/Package is set. Public members are not flagged if the name matches the public member regular expression (contains "^serialVersionUID$" by default). Rationale: Enforce encapsulation.
HideUtilityClassConstructorCheck: Make sure that utility classes (classes that contain only static methods) do not have a public constructor. Rationale: Instantiating utility classes does not make sense. A common mistake is forgetting to hide the default constructor.
FinalClassCheck: Checks that class which has only private ctors is declared as final. An example of how to configure the check is: <module name="FinalClass"/>
InputNonUtilityClass: Not a util class because it's not directly derived from java.lang.Object.
InputMutableException
InputThrowsCount
DesignForExtensionCheckTest
FinalClassCheckTest
HideUtilityClassConstructorCheckTest
InterfaceIsTypeCheckTest
MutableExceptionCheckTest
ThrowsCountCheckTest
VisibilityModifierCheckTest
| Home | Contact Us | Privacy Policy | Terms of Service |