Skip to content

Commit

Permalink
green-code-initiative#63 - refactor: removes duplicate information ab…
Browse files Browse the repository at this point in the history
  • Loading branch information
jycr committed Apr 12, 2023
1 parent d8e4d5e commit 875be9f
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@
* @author Aubay
* @formatter:off
*/
@Rule(key = "EC27",
name = "Developpement",
description = ArrayCopyCheck.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC27")
public class ArrayCopyCheck extends IssuableSubscriptionVisitor {

//@formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
import org.sonar.plugins.java.api.tree.ExpressionTree;
import org.sonar.plugins.java.api.tree.Tree;

@Rule(
key = "EC75",
name = "Developpement",
description = AvoidConcatenateStringsInLoop.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC75")
public class AvoidConcatenateStringsInLoop extends IssuableSubscriptionVisitor {

public static final String MESSAGE_RULE = "Don't concatenate Strings in loop, use StringBuilder instead.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;

@Rule(
key = "EC74",
name = "Developpement",
description = AvoidFullSQLRequest.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC74")
public class AvoidFullSQLRequest extends IssuableSubscriptionVisitor {

protected static final String MESSAGERULE = "Don't use the query SELECT * FROM";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
import org.sonar.plugins.java.api.tree.Tree.Kind;
import org.sonar.plugins.java.api.tree.WhileStatementTree;

@Rule(key = "EC3",
name = "Developpement",
description = AvoidGettingSizeCollectionInLoop.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC3")
public class AvoidGettingSizeCollectionInLoop extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Avoid getting the size of the collection in the loop";
private static final MethodMatchers SIZE_METHOD = MethodMatchers.or(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
import org.sonar.plugins.java.api.tree.StatementTree;
import org.sonar.plugins.java.api.tree.Tree;

@Rule(key = "EC2",
name = "Developpement",
description = AvoidMultipleIfElseStatement.RULE_MESSAGE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC2")
public class AvoidMultipleIfElseStatement extends IssuableSubscriptionVisitor {
protected static final String RULE_MESSAGE = "Using a switch statement instead of multiple if-else if possible";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
import org.sonar.plugins.java.api.tree.MethodTree;
import org.sonar.plugins.java.api.tree.Tree;

@Rule(
key = "EC77",
name = "Developpement",
description = AvoidRegexPatternNotStatic.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC77")
public class AvoidRegexPatternNotStatic extends IssuableSubscriptionVisitor {

public static final String MESSAGE_RULE = "Avoid using Pattern.compile() in a non-static context.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;

@Rule(key = "EC72", name = "Developpement", description = AvoidSQLRequestInLoop.MESSAGERULE, priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC72")
public class AvoidSQLRequestInLoop extends IssuableSubscriptionVisitor {

protected static final String MESSAGERULE = "Avoid SQL request in loop";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
import static org.sonar.plugins.java.api.tree.Tree.Kind.MEMBER_SELECT;
import static org.sonar.plugins.java.api.tree.Tree.Kind.METHOD_INVOCATION;

@Rule(key = "EC78", name = "Developpement",
description = AvoidSetConstantInBatchUpdate.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})

@Rule(key = "EC78")
public class AvoidSetConstantInBatchUpdate extends IssuableSubscriptionVisitor {

protected static final String MESSAGERULE = "Avoid setting constants in batch update";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.Tree;

@Rule(key = "EC1",
name = "Developpement",
description = AvoidSpringRepositoryCallInLoopCheck.RULE_MESSAGE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC1")
public class AvoidSpringRepositoryCallInLoopCheck extends IssuableSubscriptionVisitor {

protected static final String RULE_MESSAGE = "Avoid Spring repository call in loop";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.VariableTree;

@Rule(
key = "EC76",
name = "Developpement",
description = AvoidUsageOfStaticCollections.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC76")
public class AvoidUsageOfStaticCollections extends IssuableSubscriptionVisitor {

protected static final String MESSAGE_RULE = "Avoid usage of static collections.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
import org.sonar.plugins.java.api.tree.Tree.Kind;
import org.sonar.plugins.java.api.tree.VariableTree;

@Rule(
key = "EC4",
name = "Developpement",
description = "<p>Prefer local variables to globals</p>",
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC4")
public class AvoidUsingGlobalVariablesCheck extends IssuableSubscriptionVisitor {

private static final String ERROR_MESSAGE = "Avoid using global variables";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@
import org.sonar.plugins.java.api.tree.TryStatementTree;


@Rule(
key = "EC79",
name = "Developpement",
description = FreeResourcesOfAutoCloseableInterface.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC79")
public class FreeResourcesOfAutoCloseableInterface extends IssuableSubscriptionVisitor {
private final Deque<TryStatementTree> withinTry = new LinkedList<>();
private final Deque<List<Tree>> toReport = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;

@Rule(
key = "EC67",
name = "Developpement",
description = IncrementCheck.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC67")
public class IncrementCheck extends IssuableSubscriptionVisitor {

protected static final String MESSAGERULE = "Use ++i instead of i++";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;

@Rule(
key = "EC32",
name = "Developpement",
description = InitializeBufferWithAppropriateSize.RULE_MESSAGE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC32")
public class InitializeBufferWithAppropriateSize extends IssuableSubscriptionVisitor {

protected static final String RULE_MESSAGE = "Initialize StringBuilder or StringBuffer with appropriate size";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import org.sonar.plugins.java.api.tree.PackageDeclarationTree;
import org.sonar.plugins.java.api.tree.Tree;

@Rule(key = "EC69", name = "Developpement", description = NoFunctionCallWhenDeclaringForLoop.MESSAGERULE, priority = Priority.MINOR, tags = {
"bug"})
@Rule(key = "EC69")
public class NoFunctionCallWhenDeclaringForLoop extends IssuableSubscriptionVisitor {

protected static final String MESSAGERULE = "Do not call a function when declaring a for-type loop";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
import org.sonar.plugins.java.api.tree.Tree.Kind;
import org.sonar.plugins.java.api.tree.TryStatementTree;

@Rule(
key = "EC28",
name = "Developpement",
description = OptimizeReadFileExceptions.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC28")
public class OptimizeReadFileExceptions extends IssuableSubscriptionVisitor {

protected static final String MESSAGERULE = "Optimize Read File Exceptions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
import org.sonar.plugins.java.api.tree.UnaryExpressionTree;
import org.sonar.plugins.java.api.tree.VariableTree;

@Rule(key = "EC63", name = "Developpement", description = "Do not unnecessarily assign values to variables", priority = Priority.MINOR, tags = {
"bug"})
@Rule(key = "EC63")
public class UnnecessarilyAssignValuesToVariables extends BaseTreeVisitor implements JavaFileScanner {

protected static final String MESSAGERULE1 = "The variable is not assigned";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;

@Rule(
key = "EC53",
name = "Developpement",
description = UseCorrectForLoop.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
@Rule(key = "EC53")
public class UseCorrectForLoop extends IssuableSubscriptionVisitor {

protected static final String MESSAGERULE = "Avoid the use of Foreach with Arrays";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
import org.sonar.plugins.php.api.tree.expression.LiteralTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;

@Rule(
key = AvoidDoubleQuoteCheck.RULE_KEY,
name = AvoidDoubleQuoteCheck.ERROR_MESSAGE,
description = AvoidDoubleQuoteCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidDoubleQuoteCheck.RULE_KEY)
public class AvoidDoubleQuoteCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC66";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@
import org.sonar.plugins.php.api.tree.expression.LiteralTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;

@Rule(
key = AvoidFullSQLRequestCheck.RULE_KEY,
name = AvoidFullSQLRequestCheck.ERROR_MESSAGE,
description = AvoidFullSQLRequestCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidFullSQLRequestCheck.RULE_KEY)
public class AvoidFullSQLRequestCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC74";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
import org.sonar.plugins.php.api.tree.statement.StatementTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;

@Rule(
key = AvoidSQLRequestInLoopCheck.RULE_KEY,
name = AvoidSQLRequestInLoopCheck.ERROR_MESSAGE,
description = AvoidSQLRequestInLoopCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidSQLRequestInLoopCheck.RULE_KEY)
public class AvoidSQLRequestInLoopCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC72";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
import org.sonar.plugins.php.api.tree.Tree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;

@Rule(
key = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.RULE_KEY,
name = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.ERROR_MESSAGE,
description = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.RULE_KEY)
public class AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC34";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
import org.sonar.plugins.php.api.tree.declaration.FunctionDeclarationTree;
import org.sonar.plugins.php.api.visitors.PHPVisitorCheck;

@Rule(
key = AvoidUsingGlobalVariablesCheck.RULE_KEY,
name = AvoidUsingGlobalVariablesCheck.ERROR_MESSAGE,
description = AvoidUsingGlobalVariablesCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidUsingGlobalVariablesCheck.RULE_KEY)
public class AvoidUsingGlobalVariablesCheck extends PHPVisitorCheck {

public static final String RULE_KEY = "EC4";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@
import org.sonar.plugins.php.api.tree.Tree.Kind;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;

@Rule(
key = IncrementCheck.RULE_KEY,
name = IncrementCheck.ERROR_MESSAGE,
description = IncrementCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = IncrementCheck.RULE_KEY)
public class IncrementCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC67";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
import org.sonar.plugins.php.api.tree.statement.ForStatementTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;

@Rule(
key = NoFunctionCallWhenDeclaringForLoop.RULE_KEY,
name = NoFunctionCallWhenDeclaringForLoop.ERROR_MESSAGE,
description = NoFunctionCallWhenDeclaringForLoop.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = NoFunctionCallWhenDeclaringForLoop.RULE_KEY)
public class NoFunctionCallWhenDeclaringForLoop extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC69";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
import org.sonar.plugins.php.api.tree.statement.StatementTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;

@Rule(
key = UseOfMethodsForBasicOperations.RULE_KEY,
name = UseOfMethodsForBasicOperations.ERROR_MESSAGE,
description = UseOfMethodsForBasicOperations.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = UseOfMethodsForBasicOperations.RULE_KEY)
public class UseOfMethodsForBasicOperations extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC22";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
import org.sonar.plugins.python.api.tree.StringLiteral;
import org.sonar.plugins.python.api.tree.Tree;

@Rule(
key = AvoidFullSQLRequest.RULE_KEY,
name = AvoidFullSQLRequest.MESSAGERULE,
description = AvoidFullSQLRequest.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidFullSQLRequest.RULE_KEY)
public class AvoidFullSQLRequest extends PythonSubscriptionCheck {

public static final String RULE_KEY = "EC74";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
import org.sonar.plugins.python.api.tree.StatementList;
import org.sonar.plugins.python.api.tree.Tree;

@Rule(
key = AvoidGettersAndSetters.RULE_KEY,
name = AvoidGettersAndSetters.DESCRIPTION,
description = AvoidGettersAndSetters.DESCRIPTION,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidGettersAndSetters.RULE_KEY)
public class AvoidGettersAndSetters extends PythonSubscriptionCheck {

public static final String RULE_KEY = "EC7";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@
import org.sonar.plugins.python.api.tree.YieldExpression;
import org.sonar.plugins.python.api.tree.YieldStatement;

@Rule(
key = AvoidGlobalVariableInFunctionCheck.RULE_KEY,
name = "Do not call global variables directly inside functions",
description = AvoidGlobalVariableInFunctionCheck.DESCRIPTION,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
@Rule(key = AvoidGlobalVariableInFunctionCheck.RULE_KEY)
public class AvoidGlobalVariableInFunctionCheck extends PythonSubscriptionCheck {

public static final String RULE_KEY = "EC4";
Expand Down
Loading

0 comments on commit 875be9f

Please sign in to comment.