| Active/Severity | Name [expand / collapse] | Sort by: | ||
|---|---|---|---|---|
|
The following code illustrates this rule:
void doSomething() {
// TODO
}
Repository: squid
Key: S1135
Available since 07 Jan 2014
|
||||
|
Nesting The following code:
try {
try { // Non-Compliant
doSomething();
} catch (RuntimeException e) {
/* Ignore */
}
doSomethingElse();
} catch (Exception e) {
/* ... */
}
should be refactored into:
try {
dedicatedMethod(); // Compliant
doSomethingElse();
} catch (Exception e) {
/* ... */
}
/* ... */
private void dedicatedMethod() {
try { // Compliant
doSomething();
} catch (RuntimeException e) {
/* Ignore */
}
}
Repository: squid
Key: S1141
Available since 07 Jan 2014
|
||||
|
Sharing some naming conventions is a key point to make it possible for a team to efficiently collaborate. This rule allows to check that all type parameter names match a provided regular expression. The following code snippet illustrates this rule when the regular expression value is "^[A-Z]$":
class MyClass<TYPE> { // Non-Compliant
<TYPE> void addAll(Collection<TYPE> c) { // Non-compliant
}
}
public class MyClass<T> { // Compliant
<T> void addAll(Collection<T> c) { // Compliant
}
}
Repository: squid
Key: S00119
Available since 07 Jan 2014
|
||||
|
This code performs an unchecked cast of the return value of a method. The code might be calling the method in such a way that the cast is guaranteed to be safe, but FindBugs is unable to verify that the cast is safe. Check that your program logic ensures that this cast will not fail.
Repository: findbugs
Key: BC_UNCONFIRMED_CAST_OF_RETURN_VALUE
Available since 07 Jan 2014
|
||||
|
Deprecated
Detects when a local variable is declared and/or assigned, but not used. This rule is deprecated, use squid:S1481 instead.
Repository: pmd
Key: UnusedLocalVariable
Available since 07 Jan 2014
|
||||
|
Fields in interfaces are automatically public static final, and methods are public abstract. Classes or interfaces nested in an interface are automatically public and static (all nested interfaces are automatically static). For historical reasons, modifiers which are implied by the context are accepted by the compiler, but are superfluous.
Repository: pmd
Key: UnusedModifier
Available since 07 Jan 2014
|
||||
|
Deprecated
Detects when a private field is declared and/or assigned a value, but not used. This rule is deprecated, use squid:S1068 instead.
Repository: pmd
Key: UnusedPrivateField
Available since 07 Jan 2014
|
||||
|
Private methods that are never executed are dead code. Dead code means unnecessary, inoperative code that should be removed. This helps in maintenance by decreasing the maintained code size, making it easier to understand the program and preventing bugs from being introduced. In the following two cases, private methods are not considered as dead code by SonarQube :
Repository: squid
Key: UnusedPrivateMethod
Available since 07 Jan 2014
|
||||
|
The imports part of a file should be handled by the Integrated Development Environment (IDE), not manually by the developer. Unused and useless imports should not occur if that is the case. Leaving them in reduces the code's readability, since their presence can be confusing. The following code snippet illustrates this rule:
package my.company;
import java.lang.String; // Non-Compliant - java.lang classes are always implicitly imported
import my.company.SomeClass; // Non-Compliant - same package files are always implicitly imported
import java.io.File; // Non-Compliant - File is not used
import my.company2.SomeType;
import my.company2.SomeType; // Non-Compliant - 'SomeType' is already imported
class ExampleClass {
public String someString;
public SomeType something;
}
Repository: squid
Key: UselessImportCheck
Available since 07 Jan 2014
|
||||
|
Useless parentheses can sometimes be misleading and so should be removed. The following code snippet illustrates this rule: return 3; // Compliant return (x); // Non-Compliant return (x + 1); // Non-Compliant int x = (y / 2 + 1); // Non-Compliant int y = (4+X) * y; // Compliant
Repository: squid
Key: UselessParenthesesCheck
Available since 07 Jan 2014
|
||||
|
This method calls
Repository: findbugs
Key: JML_JSR166_CALLING_WAIT_RATHER_THAN_AWAIT
Available since 07 Jan 2014
|
||||
|
Utility classes, which are a collection of static members, are not meant to be instantiated. They should therefore not have public constructors. Java adds an implicit public constructor to every class which does not define at least one explicitly. Hence, at least one non-public constructor should be defined. The following code:
class StringUtils { // Non-Compliant
public static String concatenate(String s1, String s2) {
return s1 + s2;
}
}
should be refactored into:
class StringUtils { // Compliant
private StringUtils {
}
public static String concatenate(String s1, String s2) {
return s1 + s2;
}
}
Repository: squid
Key: S1118
Available since 07 Jan 2014
|
||||