Package com.github.sevntu.checkstyle.checks.coding
Contains the Coding checks that
are bundled with the main distribution.
-
Class Summary Class Description AvoidConstantAsFirstOperandInConditionCheck Checks that constants do not appear in the first operand of any condition.AvoidDefaultSerializableInInnerClassesCheck This check prevents the default implementation Serializable interface in inner classes (Serializable interface are default if methods readObject() or writeObject() are not override in class).AvoidHidingCauseExceptionCheck This check prevents new exception throwing inside try/catch blocks without providing current exception cause.AvoidModifiersForTypesCheck Disallow some set of modifiers for Java types specified by regexp.AvoidNotShortCircuitOperatorsForBooleanCheck This check limits using of not short-circuit operators ("|", "&", "|=", "&=") in boolean expressions.ConfusingConditionCheck This check prevents negation within an "if" expression if "else" is present.CustomDeclarationOrderCheck Checks that the parts of a class(main, nested, member inner) declaration appear in the rules order set by user using regular expressions.DiamondOperatorForVariableDefinitionCheck This Check highlights variable definition statements where diamond operator could be used.
Rationale: using diamond operator (introduced in Java 1.7) leads to shorter code
and better code readability.EitherLogOrThrowCheck Either log the exception, or throw it, but never do both.EmptyPublicCtorInClassCheck This Check looks for useless empty public constructors.FinalizeImplementationCheck Validates finalize method implementation.ForbidCCommentsInMethodsCheck This check forbid to use C style comments into the method body.ForbidCertainImportsCheck Forbids certain imports usage in certain packages.ForbidCertainMethodCheck Check that forbidden method is not used.ForbidInstantiationCheck Forbids instantiation of certain object types by their full classname.ForbidReturnInFinallyBlockCheck The finally block is always executed unless there is abnormal program termination, either resulting from a JVM crash or from a call to System.exit(0).ForbidThrowAnonymousExceptionsCheck This Check warns on throwing anonymous exception.IllegalCatchExtendedCheck Catching java.lang.Exception, java.lang.Error or java.lang.RuntimeException is almost never acceptable.Jsr305AnnotationsCheck The Jsr305 annotations (annotations for software defect detection) contain a subset of "nullness" annotations that can be used to mark parameters as possibly null (@Nullable
) or always non-null (@Nonnull
), function return values as to be checked for null (@CheckForNull
) or always non-null (@Nonnull
) including defaults on class level (@ParametersAreNonnullByDefault
,@ParametersAreNullableByDefault
,@ReturnValuesAreNonnullByDefault
).LogicConditionNeedOptimizationCheck This check prevents the placement of local variables and fields after calling methods and instanceof in '&&' and '||' conditions.MapIterationInForEachLoopCheck This check can help you to write the whole for-each map iteration more correctly.MoveVariableInsideIfCheck Checks if a variable is only used inside if statements and asks for its declaration to be moved there too.MultipleStringLiteralsExtendedCheck Checks for multiple occurrences of the same string literal within a single file.MultipleVariableDeclarationsExtendedCheck Checks that each variable declaration is in its own statement and on its own line.NameConventionForJunit4TestClassesCheck This check verifies the name of JUnit4 test class for compliance with user defined naming convention(by default Check expects test classes names matching ".+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*" regex).NoNullForCollectionReturnCheck This check report you, when method, that must return array or collection, return null value instead of empty collection or empty array.NumericLiteralNeedsUnderscoreCheck This check verifies that large numeric literals are spaced by underscores.OverridableMethodInConstructorCheck Detects overridable methods in constructors.PreferMethodReferenceCheck Checks that lambda usage can be replaced with method reference.RedundantReturnCheck Highlights usage of redundant returns inside constructors and methods with void result.RequireFailForTryCatchInJunitCheck Checks if a try/catch block has a fail assertion at the end of a try block in a JUnit test method.ReturnBooleanFromTernaryCheck It is a bad practice to return boolean values from ternary operations.ReturnCountExtendedCheck Checks that method/ctor "return" literal count is not greater than the given value ("maxReturnCount" property).
Rationale:
One return per method is a good practice as its ease understanding of method logic.ReturnNullInsteadOfBooleanCheck It is a bad practice to useBoolean
type for ternary logic.SimpleAccessorNameNotationCheck This check verify incorrect name of setter and getter methods if it used field with other name.SingleBreakOrContinueCheck This check restricts the number of break and continue statements inside cycle body (only one is allowed).TernaryPerExpressionCountCheck Restricts the number of ternary operators in expression to a specific limit.
Rationale: This Check helps to improve code readability by pointing developer on
expressions which contain more than user-defined count of ternary operators.
It points to complicated ternary expressions.UnnecessaryParenthesesExtendedCheck Checks if unnecessary parentheses are used in a statement or expression.UselessSingleCatchCheck Checks for the presence of useless single catch blocks.UselessSuperCtorCallCheck Checks for useless "super()" calls in ctors.WhitespaceBeforeArrayInitializerCheck This checks enforces whitespace before array initializer. -
Enum Summary Enum Description NumericLiteralNeedsUnderscoreCheck.NumericType Type of numeric literal.