Skip to content

Commit

Permalink
#63 - refactor: removes duplicate information about rules properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jycr committed Jun 9, 2023
1 parent 5eeb282 commit f4264fb
Show file tree
Hide file tree
Showing 41 changed files with 42 additions and 228 deletions.
2 changes: 2 additions & 0 deletions ecocode-rules-specifications/src/main/rules/EC3/EC3.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"constantCost": "5min"
},
"tags": [
"bad-practice",
"performance",
"eco-design",
"performance",
"ecocode"
Expand Down
2 changes: 1 addition & 1 deletion ecocode-rules-specifications/src/main/rules/EC34/EC34.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Avoid using try-catch-finally statement",
"title": "Avoid using try-catch statement",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
Expand Down
1 change: 1 addition & 0 deletions ecocode-rules-specifications/src/main/rules/EC66/EC66.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"constantCost": "5min"
},
"tags": [
"bad-practice",
"eco-design",
"performance",
"ecocode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
* @author Aubay
* @formatter:off
*/
@Rule(key = "EC27",
name = "Developpement",
description = ArrayCopyCheck.MESSAGERULE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC27")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRPS0027")
public class ArrayCopyCheck extends IssuableSubscriptionVisitor {

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;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC75",
name = "Developpement",
description = AvoidConcatenateStringsInLoop.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode", "memory"})
@Rule(key = "EC75")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S75")
public class AvoidConcatenateStringsInLoop extends IssuableSubscriptionVisitor {

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.Tree.Kind;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC74",
name = "Developpement",
description = AvoidFullSQLRequest.MESSAGERULE,
priority = Priority.MINOR,
tags = {"performance", "sql", "eco-design", "ecocode", "network"})
@Rule(key = "EC74")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S74")
public class AvoidFullSQLRequest extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
import org.sonar.plugins.java.api.tree.WhileStatementTree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC3",
name = "Developpement",
description = AvoidGettingSizeCollectionInLoop.MESSAGERULE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC3")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GSCIL")
public class AvoidGettingSizeCollectionInLoop extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Avoid getting the size of the collection in the loop";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC2",
name = "Developpement",
description = AvoidMultipleIfElseStatement.RULE_MESSAGE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC2")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "AMIES")
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 @@ -16,12 +16,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC77",
name = "Developpement",
description = AvoidRegexPatternNotStatic.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"performance", "regex", "eco-design", "ecocode", "memory"})
@Rule(key = "EC77")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S77")
public class AvoidRegexPatternNotStatic extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.sonar.plugins.java.api.tree.Tree.Kind;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC72", name = "Developpement", description = AvoidSQLRequestInLoop.MESSAGERULE, priority = Priority.MINOR,
tags = {"performance", "sql", "spring", "eco-design", "ecocode", "memory", "network"})
@Rule(key = "EC72")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S72")
public class AvoidSQLRequestInLoop extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,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 = {"eco-design", "ecocode", "sql", "performance", "memory"})
@Rule(key = "EC78")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S78")
public class AvoidSetConstantInBatchUpdate extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC1",
name = "Developpement",
description = AvoidSpringRepositoryCallInLoopCheck.RULE_MESSAGE,
priority = Priority.MINOR,
tags = {"performance", "spring", "eco-design", "ecocode"})
@Rule(key = "EC1")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRC1")
public class AvoidSpringRepositoryCallInLoopCheck extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC5", tags={"performance", "sql", "eco-design", "ecocode"})
@Rule(key = "EC5")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "SDMLQ1")
public class AvoidStatementForDMLQueries extends IssuableSubscriptionVisitor {

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.VariableTree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC76",
name = "Developpement",
description = AvoidUsageOfStaticCollections.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"cwe", "leak", "eco-design", "ecocode", "memory"})
@Rule(key = "EC76")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S76")
public class AvoidUsageOfStaticCollections extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
import org.sonar.plugins.java.api.tree.VariableTree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC4",
name = "Developpement",
description = "<p>Prefer local variables to globals</p>",
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC4")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "D4")
public class AvoidUsingGlobalVariablesCheck extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;


@Rule(
key = "EC79",
name = "Developpement",
description = FreeResourcesOfAutoCloseableInterface.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC79")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S79")
public class FreeResourcesOfAutoCloseableInterface extends IssuableSubscriptionVisitor {
private final Deque<TryStatementTree> withinTry = new LinkedList<>();
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.Kind;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC67",
name = "Developpement",
description = IncrementCheck.MESSAGERULE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC67")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S67")
public class IncrementCheck extends IssuableSubscriptionVisitor {

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.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC32",
name = "Developpement",
description = InitializeBufferWithAppropriateSize.RULE_MESSAGE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC32")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRSP0032")
public class InitializeBufferWithAppropriateSize extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC69", name = "Developpement", description = NoFunctionCallWhenDeclaringForLoop.MESSAGERULE, priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC69")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S69")
public class NoFunctionCallWhenDeclaringForLoop extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
import org.sonar.plugins.java.api.tree.TryStatementTree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC28",
name = "Developpement",
description = OptimizeReadFileExceptions.MESSAGERULE,
priority = Priority.MINOR,
tags = {"performance", "error-handling", "eco-design", "ecocode"})
@Rule(key = "EC28")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRSP0028")
public class OptimizeReadFileExceptions extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
import org.sonar.plugins.java.api.tree.VariableTree;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC63", name = "Developpement", description = "Do not unnecessarily assign values to variables", priority = Priority.MINOR,
tags = {"eco-design", "ecocode", "memory"})
@Rule(key = "EC63")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S63")
public class UnnecessarilyAssignValuesToVariables extends BaseTreeVisitor implements JavaFileScanner {

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.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = "EC53",
name = "Developpement",
description = UseCorrectForLoop.MESSAGERULE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC53")
@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S53")
public class UseCorrectForLoop extends IssuableSubscriptionVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = AvoidDoubleQuoteCheck.RULE_KEY,
name = AvoidDoubleQuoteCheck.ERROR_MESSAGE,
description = AvoidDoubleQuoteCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC66")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S66")
public class AvoidDoubleQuoteCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC66";
public static final String ERROR_MESSAGE = "Avoid using double quote (\"), prefer using simple quote (')";
private static final Map<String, Collection<Integer>> linesWithIssuesByFile = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = AvoidFullSQLRequestCheck.RULE_KEY,
name = AvoidFullSQLRequestCheck.ERROR_MESSAGE,
description = AvoidFullSQLRequestCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"sql", "performance", "eco-design", "ecocode"})
@Rule(key = "EC74")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S74")
public class AvoidFullSQLRequestCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC74";

public static final String ERROR_MESSAGE = "Don't use the query SELECT * FROM";

private static final Pattern PATTERN = Pattern.compile("(?i).*select.*\\*.*from.*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@
import java.util.List;
import java.util.regex.Pattern;

@Rule(
key = AvoidGettingSizeCollectionInLoopCheck.RULE_KEY,
name = AvoidGettingSizeCollectionInLoopCheck.ERROR_MESSAGE,
description = AvoidGettingSizeCollectionInLoopCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"eco-design", "ecocode", "bad-practice", "performance"}
)
@Rule(key = "EC3")
public class AvoidGettingSizeCollectionInLoopCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC3";
public static final String ERROR_MESSAGE = "Avoid getting the size of the collection in the loop";
private static final Pattern PATTERN = Pattern.compile("\\b(?:count|sizeof|iterator_count)\\b");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,10 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = AvoidSQLRequestInLoopCheck.RULE_KEY,
name = AvoidSQLRequestInLoopCheck.ERROR_MESSAGE,
description = AvoidSQLRequestInLoopCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"sql", "performance", "eco-design", "ecocode"})
@Rule(key = "EC72")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S72")
public class AvoidSQLRequestInLoopCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC72";
public static final String ERROR_MESSAGE = "Avoid SQL request in loop";
private static final Pattern PATTERN = Pattern.compile("(mysql(i::|_)query\\s*\\(.*)|(oci_execute\\(.*)");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.RULE_KEY,
name = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.ERROR_MESSAGE,
description = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"error-handling", "performance", "eco-design", "ecocode"})
@Rule(key = "EC34")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S34")
public class AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC34";
public static final String ERROR_MESSAGE = "Avoid using try-catch";

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@
import org.sonar.plugins.php.api.visitors.PHPVisitorCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = AvoidUsingGlobalVariablesCheck.RULE_KEY,
name = AvoidUsingGlobalVariablesCheck.ERROR_MESSAGE,
description = AvoidUsingGlobalVariablesCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC4")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "D4")
public class AvoidUsingGlobalVariablesCheck extends PHPVisitorCheck {

public static final String RULE_KEY = "EC4";
public static final String ERROR_MESSAGE = "Prefer local variables to globals";

private static final Pattern PATTERN = Pattern.compile("^.*(global \\$|\\$GLOBALS).*$", Pattern.CASE_INSENSITIVE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(
key = IncrementCheck.RULE_KEY,
name = IncrementCheck.ERROR_MESSAGE,
description = IncrementCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"performance", "eco-design", "ecocode"})
@Rule(key = "EC67")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S67")
public class IncrementCheck extends PHPSubscriptionCheck {

public static final String RULE_KEY = "EC67";
public static final String ERROR_MESSAGE = "Remove the usage of $i++. prefer ++$i";

@Override
Expand Down
Loading

0 comments on commit f4264fb

Please sign in to comment.