text
stringlengths
41
445
<s>[INST] UselessOverridingMethod [/INST] Overriding method merely calls super</s>
<s>[INST] UselessOperationOnImmutable [/INST] An operation on an Immutable object (String, BigDecimal or BigInteger) won't change the object itself</s>
<s>[INST] UnusedNullCheckInEquals [/INST] Invoke equals() on the object you''ve already ensured is not null</s>
<s>[INST] UselessParentheses [/INST] Useless parentheses.</s>
<s>[INST] UselessQualifiedThis [/INST] Useless qualified this usage in the same class.</s>
<s>[INST] UnusedPrivateField [/INST] Avoid unused private fields such as ''{0}''.</s>
<s>[INST] UnusedLocalVariable [/INST] Avoid unused local variables such as ''{0}''.</s>
<s>[INST] UnusedPrivateMethod [/INST] Avoid unused private methods such as ''{0}''.</s>
<s>[INST] UnusedFormalParameter [/INST] Avoid unused {0} parameters such as ''{1}''.</s>
<s>[INST] UnusedModifier [/INST] Avoid modifiers which are implied by the context</s>
<s>[INST] UnsynchronizedStaticFormatter [/INST] Instances of java.text.Format are generally not synchronized. Sun recommends using separate format instances for each thread. If multiple threads must access a static formatter, the formatter must be synchronized on block level.</s>
<s>[INST] InvalidLogMessageFormat [/INST] Check for messages in slf4j and log4j2 (since 6.19.0) loggers with non matching number of arguments and placeholders.</s>
<s>[INST] AvoidUncheckedExceptionsInSignatures [/INST] A method or constructor should not explicitly declare unchecked exceptions in its throws clause. Java doesn’t force the caller to handle an unchecked exception, so it’s unnecessary except for documentation. A better practice is to document the exceptional cases with a @throws Javadoc tag, which allows being more descriptive.</s>
<s>[INST] DataClass [/INST] Data Classes are simple data holders, which reveal most of their state, and without complex functionality</s>
<s>[INST] NcssCount [/INST] This rule uses the NCSS (Non-Commenting Source Statements) metric to determine the number of lines of code in a class, method or constructor</s>
<s>[INST] ControlStatementBraces [/INST] Enforce a policy for braces on control statements. It is recommended to use braces on ‘if … else’ statements and loop statements, even if they are optional.</s>
<s>[INST] FieldNamingConventions [/INST] Configurable naming conventions for field declarations.</s>
<s>[INST] FormalParameterNamingConventions [/INST] Configurable naming conventions for formal parameters of methods and lambdas</s>
<s>[INST] IdenticalCatchBranches [/INST] Identical catch branches use up vertical space and increase the complexity of code without adding functionality. It’s better style to collapse identical branches into a single multi-catch branch.</s>
<s>[INST] LinguisticNaming [/INST] This rule finds Linguistic Naming Antipatterns. It checks for fields, that are named, as if they should be boolean but have a different type. It also checks for methods, that according to their name, should return a boolean, but don’t.</s>
<s>[INST] LocalVariableNamingConventions [/INST] Configurable naming conventions for local variable declarations and other locally-scoped variables.</s>
<s>[INST] UnnecessaryAnnotationValueElement [/INST] Avoid the use of value in annotations when it’s the only element.</s>
<s>[INST] UnnecessaryCast [/INST] This rule detects when a cast is unnecessary while accessing collection elements. This rule is mostly useful for old java code before generics where introduced with java 1.5.</s>
<s>[INST] UseDiamondOperator [/INST] Use the diamond operator to let the type be inferred automatically.</s>
<s>[INST] DetachedTestCase [/INST] The method appears to be a test case since it has public or default visibility, non-static access, no arguments, no return value, has no annotations, but is a member of a class that has one or more JUnit test cases. If it is a utility method, it should likely have private visibility. If it is an ignored test, it should be annotated with @Test and @Ignore.</s>
<s>[INST] DoNotExtendJavaLangThrowable [/INST] Extend Exception or RuntimeException instead of Throwable.</s>
<s>[INST] AccessorMethodGeneration [/INST] When accessing a private field / method from another class, the Java compiler will generate a accessor methods with package-private visibility.</s>
<s>[INST] AvoidMessageDigestField [/INST] Declaring a MessageDigest instance as a field make this instance directly available to multiple threads. Such sharing of MessageDigest instances should be avoided if possible since it leads to wrong results if the access is not synchronized correctly. Just create a new instance and use it locally, where you need it. Creating a new instance is easier than synchronizing access to a shared instance.</s>
<s>[INST] AvoidReassigningLoopVariables [/INST] Reassigning loop variables can lead to hard-to-find bugs. Prevent or limit how these variables can be changed.</s>
<s>[INST] DoubleBraceInitialization [/INST] Double brace initialisation is a pattern to initialise eg collections concisely.</s>
<s>[INST] ForLoopCanBeForeach [/INST] Reports loops that can be safely replaced with the foreach syntax.</s>
<s>[INST] ForLoopVariableCount [/INST] Having a lot of control variables in a ‘for’ loop makes it harder to see what range of values the loop iterates over. By default this rule allows a regular ‘for’ loop with only one variable.</s>
<s>[INST] LiteralsFirstInComparisons [/INST] Position literals first in all String comparisons, if the second argument is null then NullPointerExceptions can be avoided, they will just return false. Note that switching literal positions for compareTo and compareToIgnoreCase may change the result, see examples.</s>
<s>[INST] MissingOverride [/INST] Annotating overridden methods with @Override ensures at compile time that the method really overrides one, which helps refactoring and clarifies intent.</s>
<s>[INST] UseTryWithResources [/INST] Java 7 introduced the try-with-resources statement. This statement ensures that each resource is closed at the end of the statement.</s>
<s>[INST] WhileLoopWithLiteralBoolean [/INST] do {} while (true); requires reading the end of the statement before it is apparent that it loops forever, whereas while (true) {} is easier to understand.do {} while (false); is redundant, and if an inner variable scope is required, a block {} is sufficient.while (false) {} will never execute the block and can be removed in its entirety.</s>
<s>[INST] UseUnderscoresInNumericLiterals [/INST] Since Java 1.7, numeric literals can use underscores to separate digits.</s>
<s>[INST] AvoidCalendarDateCreation [/INST] A Calendar is a heavyweight object and expensive to create.</s>
<s>[INST] AvoidFileStream [/INST] The FileInputStream and FileOutputStream classes contains a finalizer method which will cause garbage collection pauses.</s>
<s>[INST] UseIOStreamsWithApacheCommonsFileItem [/INST] Use of FileItem.get() and FileItem.getString() could exhaust memory since they load the entire file into memory.</s>
<s>[INST] HardCodedCryptoKey [/INST] Do not use hard coded values for cryptographic operations. Please store keys outside of source code.</s>
<s>[INST] InsecureCryptoIv [/INST] Do not use hard coded initialization vector in cryptographic operations. Please use a randomly generated IV.</s>
<s>[INST] UseShortArrayInitializer [/INST] When declaring and initializing array fields or variables, it is not necessary to explicitly create a new array using new.</s>
<s>[INST] UnnecessaryModifier [/INST] Fields in interfaces and annotations are automatically public static final, and methods are public abstract.</s>
<s>[INST] CallSuperLast [/INST] Super should be called at the end of the method.</s>
<s>[INST] CallSuperFirst [/INST] Super should be called at the start of the method.</s>
<s>[INST] AvoidReassigningCatchVariables [/INST] Avoid Reassigning Catch Variables</s>
<s>[INST] DoNotTerminateVM [/INST] Do Not Terminate VM</s>
<s>[INST] UseStandardCharsets [/INST] Use Standard Charsets</s>
<s>[INST] UnusedAssignment [/INST] Reports assignments to variables that are never used before the variable is overwritten, or goes out of scope</s>
<s>[INST] UnnecessaryImport [/INST] Unnecessary Import</s>
<s>[INST] JUnit5TestShouldBePackagePrivate [/INST] JUnit5 Test Should Be Package Private</s>
<s>[INST] MutableStaticState [/INST] Mutable Static State</s>
<s>[INST] ComparisonWithNaN [/INST] Comparison With NaN</s>
<s>[INST] PrimitiveWrapperInstantiation [/INST] Primitive Wrapper Instantiation</s>
<s>[INST] SimplifiableTestAssertion [/INST] Simplifiable Test Assertion</s>
<s>[INST] ReturnEmptyCollectionRatherThanNull [/INST] Return Empty Collection Rather Than Null</s>
<s>[INST] ImplicitSwitchFallThrough [/INST] Implicit Switch Fall Through</s>