diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c42bb9f8..ca102b523 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,8 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- [171](https://github.com/green-code-initiative/ecoCode/issues/171) Add migration mechanism to support "issue re-keying"
+
### Changed
+- [166](https://github.com/green-code-initiative/ecoCode/issues/166) Correction of wrong message of rule EC63
+- [167](https://github.com/green-code-initiative/ecoCode/issues/167) Use same kind for rules across different languages
+- [173](https://github.com/green-code-initiative/ecoCode/issues/173) Update issue description of rule EC34 (try-catch)
+
### Deleted
## [1.1.0] - 2023-04-03
diff --git a/RULES.md b/RULES.md
index d40de3775..7ef76d27a 100644
--- a/RULES.md
+++ b/RULES.md
@@ -18,7 +18,7 @@ Some are applicable for different technologies.
| | Non-standard fonts used | Prefer standard fonts, as they are already present on the user's computer, so they do not need to download them. This saves bandwidth, while speeding up the display of the site. | [cnumr best practices (3rd edition) BP_029](https://github.com/cnumr/best-practices/blob/main/chapters/BP_029_fr.md) | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 |
| | Non-outsourced CSS and Javascript | If you include CSS or JavaScript code in the body of the HTML file, while the HTML file is used by several pages (or even the entire site), this code must be transferred for each page requested by the user, which increases the volume of data transmitted. | [cnumr best practices (3rd edition) BP_032](https://github.com/cnumr/best-practices/blob/main/chapters/BP_032_fr.md) | 🚫 | 🚫 | 🚀 | 🚫 | 🚫 |
| | Resize images browser-side | Do not resize images using the HEIGHT and WIDTH attributes of the HTML code. This approach requires transferring these images to their original size, wasting bandwidth and CPU cycles. | [cnumr best practices (3rd edition) BP_034](https://github.com/cnumr/best-practices/blob/main/chapters/BP_034_fr.md) | 🚫 | 🚫 | 🚧 | 🚫 | 🚫 |
-| | Use unoptimized vector images | Less heavy SVG images using less bandwidth | [cnumr best practices (3rd edition) BP_036](https://github.com/cnumr/best-practices/blob/main/chapters/BP_036_fr.md) | 🚀 | 🚀 | 🚀 | 🚀 | 🚀 |
+| EC10 | Use unoptimized vector images | Less heavy SVG images using less bandwidth | [cnumr best practices (3rd edition) BP_036](https://github.com/cnumr/best-practices/blob/main/chapters/BP_036_fr.md) | 🚧 | 🚀 | 🚀 | 🚧 | 🚀 |
| | Using too many CSS/javascript animations | JavaScript/CSS animations can be very expensive in terms of CPU cycles and memory consumption. | [cnumr best practices (3rd edition) BP_039](https://github.com/cnumr/best-practices/blob/main/chapters/BP_039_fr.md) | 🚫 | 🚫 | 🚧 | 🚫 | 🚫 |
| | Modify the DOM when traversing it | Modifying the DOM (Document Object Model) as you traverse it can lead to situations where the loop becomes very resource-intensive, especially CPU cycles. | [cnumr best practices (3rd edition) BP_041](https://github.com/cnumr/best-practices/blob/main/chapters/BP_041_fr.md) | 🚫 | 🚫 | 🚧 | 🚫 | 🚫 |
| | Edit DOM elements to make it invisible | When an element of the Document Object Model (DOM) needs to be modified by several properties, each change in style or content will generate a repaint or reflow. | [cnumr best practices (3rd edition) BP_042](https://github.com/cnumr/best-practices/blob/main/chapters/BP_042_fr.md) | 🚫 | 🚫 | 🚀 | 🚫 | 🚫 |
@@ -36,8 +36,8 @@ Some are applicable for different technologies.
| EC72 | Perform an SQL query inside a loop | Servers are optimized to process multiple selections, insertions, or changes in a single query or transaction. consume CPU cycles, RAM, and bandwidth unnecessarily. | [cnumr best practices (3rd edition) BP_072](https://github.com/cnumr/best-practices/blob/main/chapters/BP_072_fr.md) | ✅ | ✅ | 🚀 | ✅ | 🚀 |
| EC74 | Write SELECT * FROM | The database server must resolve the fields based on the schema. If you are familiar with the diagram, it is strongly recommended to name the fields. | [cnumr best practices (3rd edition) BP_074 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) | ✅ | ✅ | 🚀 | ✅ | 🚀 |
| EC1 | Calling a Spring repository inside a loop | The use of Spring repository in a loop induces unnecessary calculations by the CPU and therefore superfluous energy consumption. | | ✅ | 🚫 | 🚫 | 🚫 | 🚫 |
-| EC3 | Getting the size of the collection in the loop | When iterating over any collection, fetch the size of the collection in advance to avoid fetching it on each iteration, this saves CPU cycles, and therefore consumes less power. | | ✅ | 🚀 | 🚀 | 🚀 | 🚀 |
-| EC2 | Multiple if-else statement | Using too many conditional if-else statements will impact performance since JVM will have to compare the conditions. Prefer using a switch statement instead of multiple if-else if possible. Switch statement has a performance advantage over if – else. | | ✅ | 🚀 | 🚀 | 🚀 | 🚀 |
+| EC3 | Getting the size of the collection in the loop | When iterating over any collection, fetch the size of the collection in advance to avoid fetching it on each iteration, this saves CPU cycles, and therefore consumes less power. | | ✅ | 🚧 | 🚀 | 🚀 | 🚀 |
+| EC2 | Multiple if-else statement | Using too many conditional if-else statements will impact performance since JVM will have to compare the conditions. Prefer using a switch statement instead of multiple if-else if possible. Switch statement has a performance advantage over if – else. | | ✅ | 🚧 | 🚀 | 🚧 | 🚀 |
| EC76 | Usage of static collections | Avoid usage of static collections. If you want to use static collections make them final and create for example a singleton if needed containing the collections. The static fields are more complicated for the Garbage Collector to manage and can lead to memory leaks. | | ✅ | 🚫 | 🚫 | 🚫 | 🚫 |
| EC77 | Usage Pattern.compile() in a non-static context | Avoid using Pattern.compile() in a non-static context. This operation requires a non negligible amount of computational power, Using a single match saves CPU cycles and RAM consumption. | | ✅ | 🚫 | 🚫 | 🚫 | 🚫 |
| EC75 | Concatenate Strings in loop | Don't concatenate Strings in loop. User StringBuilder instead. Strings are immutable so each time you concatenate a String, a new String is created. This is a waste of memory and CPU. | | ✅ | 🚫 | 🚫 | 🚫 | 🚫 |
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/ArrayCopyCheck.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/ArrayCopyCheck.java
index 70cb2f6ac..409303d70 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/ArrayCopyCheck.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/ArrayCopyCheck.java
@@ -26,6 +26,7 @@
import org.sonar.plugins.java.api.tree.TryStatementTree;
import org.sonar.plugins.java.api.tree.VariableTree;
import org.sonar.plugins.java.api.tree.WhileStatementTree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
// TODO DDC : rule already existing natively in SonarQube 9.9 (see java:S3012) for a part of checks
// ==> analyse / add our tag to it (?)
@@ -41,6 +42,7 @@
description = ArrayCopyCheck.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRPS0027")
public class ArrayCopyCheck extends IssuableSubscriptionVisitor {
//@formatter:on
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidConcatenateStringsInLoop.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidConcatenateStringsInLoop.java
index 4e7956f5e..d95335862 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidConcatenateStringsInLoop.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidConcatenateStringsInLoop.java
@@ -13,6 +13,7 @@
import org.sonar.plugins.java.api.tree.BinaryExpressionTree;
import org.sonar.plugins.java.api.tree.ExpressionTree;
import org.sonar.plugins.java.api.tree.Tree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC75",
@@ -20,6 +21,7 @@
description = AvoidConcatenateStringsInLoop.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S75")
public class AvoidConcatenateStringsInLoop extends IssuableSubscriptionVisitor {
public static final String MESSAGE_RULE = "Don't concatenate Strings in loop, use StringBuilder instead.";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidFullSQLRequest.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidFullSQLRequest.java
index a870c0c4b..c73516662 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidFullSQLRequest.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidFullSQLRequest.java
@@ -12,6 +12,7 @@
import org.sonar.plugins.java.api.tree.LiteralTree;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC74",
@@ -19,6 +20,7 @@
description = AvoidFullSQLRequest.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S74")
public class AvoidFullSQLRequest extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Don't use the query SELECT * FROM";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidGettingSizeCollectionInLoop.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidGettingSizeCollectionInLoop.java
index 347026806..7317617c0 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidGettingSizeCollectionInLoop.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidGettingSizeCollectionInLoop.java
@@ -16,12 +16,14 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
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 = {"bug"})
+@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";
private static final MethodMatchers SIZE_METHOD = MethodMatchers.or(
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidMultipleIfElseStatement.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidMultipleIfElseStatement.java
index 9e724eba0..5b584c342 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidMultipleIfElseStatement.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidMultipleIfElseStatement.java
@@ -10,12 +10,14 @@
import org.sonar.plugins.java.api.tree.IfStatementTree;
import org.sonar.plugins.java.api.tree.StatementTree;
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 = {"bug"})
+@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";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidRegexPatternNotStatic.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidRegexPatternNotStatic.java
index e675e4cf1..1020168d8 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidRegexPatternNotStatic.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidRegexPatternNotStatic.java
@@ -14,6 +14,7 @@
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.MethodTree;
import org.sonar.plugins.java.api.tree.Tree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC77",
@@ -21,6 +22,7 @@
description = AvoidRegexPatternNotStatic.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S77")
public class AvoidRegexPatternNotStatic extends IssuableSubscriptionVisitor {
public static final String MESSAGE_RULE = "Avoid using Pattern.compile() in a non-static context.";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSQLRequestInLoop.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSQLRequestInLoop.java
index d6e0ddb26..efea9cce8 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSQLRequestInLoop.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSQLRequestInLoop.java
@@ -12,9 +12,11 @@
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.Tree;
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 = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S72")
public class AvoidSQLRequestInLoop extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Avoid SQL request in loop";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSetConstantInBatchUpdate.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSetConstantInBatchUpdate.java
index 9b8c76086..21f332e27 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSetConstantInBatchUpdate.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSetConstantInBatchUpdate.java
@@ -16,6 +16,8 @@
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
+
import static org.sonar.plugins.java.api.tree.Tree.Kind.MEMBER_SELECT;
import static org.sonar.plugins.java.api.tree.Tree.Kind.METHOD_INVOCATION;
@@ -23,7 +25,7 @@
description = AvoidSetConstantInBatchUpdate.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
-
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S78")
public class AvoidSetConstantInBatchUpdate extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Avoid setting constants in batch update";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSpringRepositoryCallInLoopCheck.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSpringRepositoryCallInLoopCheck.java
index e2519cd6f..2322acfaf 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSpringRepositoryCallInLoopCheck.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidSpringRepositoryCallInLoopCheck.java
@@ -10,12 +10,14 @@
import org.sonar.plugins.java.api.tree.BaseTreeVisitor;
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
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 = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRC1")
public class AvoidSpringRepositoryCallInLoopCheck extends IssuableSubscriptionVisitor {
protected static final String RULE_MESSAGE = "Avoid Spring repository call in loop";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidStatementForDMLQueries.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidStatementForDMLQueries.java
index 3780e5030..f273ae707 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidStatementForDMLQueries.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidStatementForDMLQueries.java
@@ -12,8 +12,10 @@
import org.sonar.plugins.java.api.tree.LiteralTree;
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.Tree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(key = "EC5")
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "SDMLQ1")
public class AvoidStatementForDMLQueries extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "You must not use Statement for a DML query";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsageOfStaticCollections.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsageOfStaticCollections.java
index 82592e214..0dc3ce960 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsageOfStaticCollections.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsageOfStaticCollections.java
@@ -12,6 +12,7 @@
import org.sonar.plugins.java.api.tree.BaseTreeVisitor;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.VariableTree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC76",
@@ -19,6 +20,7 @@
description = AvoidUsageOfStaticCollections.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S76")
public class AvoidUsageOfStaticCollections extends IssuableSubscriptionVisitor {
protected static final String MESSAGE_RULE = "Avoid usage of static collections.";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsingGlobalVariablesCheck.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsingGlobalVariablesCheck.java
index eb064c894..1e86ba874 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsingGlobalVariablesCheck.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/AvoidUsingGlobalVariablesCheck.java
@@ -10,6 +10,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
import org.sonar.plugins.java.api.tree.VariableTree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC4",
@@ -17,6 +18,7 @@
description = "
Prefer local variables to globals
",
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "D4")
public class AvoidUsingGlobalVariablesCheck extends IssuableSubscriptionVisitor {
private static final String ERROR_MESSAGE = "Avoid using global variables";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/FreeResourcesOfAutoCloseableInterface.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/FreeResourcesOfAutoCloseableInterface.java
index 5d7509d13..d36cc9805 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/FreeResourcesOfAutoCloseableInterface.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/FreeResourcesOfAutoCloseableInterface.java
@@ -16,6 +16,7 @@
import org.sonar.plugins.java.api.tree.NewClassTree;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.TryStatementTree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
@@ -24,6 +25,7 @@
description = FreeResourcesOfAutoCloseableInterface.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S79")
public class FreeResourcesOfAutoCloseableInterface extends IssuableSubscriptionVisitor {
private final Deque withinTry = new LinkedList<>();
private final Deque> toReport = new LinkedList<>();
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/IncrementCheck.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/IncrementCheck.java
index 8739dcaba..41a54c1ca 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/IncrementCheck.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/IncrementCheck.java
@@ -8,6 +8,7 @@
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC67",
@@ -15,6 +16,7 @@
description = IncrementCheck.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S67")
public class IncrementCheck extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Use ++i instead of i++";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/InitializeBufferWithAppropriateSize.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/InitializeBufferWithAppropriateSize.java
index d9a82fc02..d5ee088b3 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/InitializeBufferWithAppropriateSize.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/InitializeBufferWithAppropriateSize.java
@@ -9,6 +9,7 @@
import org.sonar.plugins.java.api.tree.NewClassTree;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC32",
@@ -16,6 +17,7 @@
description = InitializeBufferWithAppropriateSize.RULE_MESSAGE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRSP0032")
public class InitializeBufferWithAppropriateSize extends IssuableSubscriptionVisitor {
protected static final String RULE_MESSAGE = "Initialize StringBuilder or StringBuffer with appropriate size";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/NoFunctionCallWhenDeclaringForLoop.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/NoFunctionCallWhenDeclaringForLoop.java
index fd8ec192b..91c88106c 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/NoFunctionCallWhenDeclaringForLoop.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/NoFunctionCallWhenDeclaringForLoop.java
@@ -19,9 +19,11 @@
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.PackageDeclarationTree;
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 = {
"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S69")
public class NoFunctionCallWhenDeclaringForLoop extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Do not call a function when declaring a for-type loop";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/OptimizeReadFileExceptions.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/OptimizeReadFileExceptions.java
index fa71afc46..d94f57676 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/OptimizeReadFileExceptions.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/OptimizeReadFileExceptions.java
@@ -14,6 +14,7 @@
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
import org.sonar.plugins.java.api.tree.TryStatementTree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC28",
@@ -21,6 +22,7 @@
description = OptimizeReadFileExceptions.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "GRSP0028")
public class OptimizeReadFileExceptions extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Optimize Read File Exceptions";
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java
index 70c24c8b8..3069393db 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UnnecessarilyAssignValuesToVariables.java
@@ -32,12 +32,14 @@
import org.sonar.plugins.java.api.tree.TypeCastTree;
import org.sonar.plugins.java.api.tree.UnaryExpressionTree;
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 = {
"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S63")
public class UnnecessarilyAssignValuesToVariables extends BaseTreeVisitor implements JavaFileScanner {
- protected static final String MESSAGERULE1 = "The variable is not assigned";
+ protected static final String MESSAGERULE1 = "The variable is declared but not really used";
protected static final String MESSAGERULE2 = "Immediately throw this expression instead of assigning it to the temporary variable";
protected static final String MESSAGERULE3 = "Immediately return this expression instead of assigning it to the temporary variable";
private JavaFileScannerContext context;
diff --git a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UseCorrectForLoop.java b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UseCorrectForLoop.java
index 46e7ad4a3..767f3449b 100644
--- a/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UseCorrectForLoop.java
+++ b/java-plugin/src/main/java/fr/greencodeinitiative/java/checks/UseCorrectForLoop.java
@@ -9,6 +9,7 @@
import org.sonar.plugins.java.api.tree.ForEachStatement;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.Tree.Kind;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = "EC53",
@@ -16,6 +17,7 @@
description = UseCorrectForLoop.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug"})
+@DeprecatedRuleKey(repositoryKey = "greencodeinitiative-java", ruleKey = "S53")
public class UseCorrectForLoop extends IssuableSubscriptionVisitor {
protected static final String MESSAGERULE = "Avoid the use of Foreach with Arrays";
diff --git a/java-plugin/src/test/files/IncrementCheck.java b/java-plugin/src/test/files/IncrementCheck.java
index 95baab1c8..6a6d1b536 100644
--- a/java-plugin/src/test/files/IncrementCheck.java
+++ b/java-plugin/src/test/files/IncrementCheck.java
@@ -31,4 +31,16 @@ void foo4(int value) {
int counter =0;
counter = counter + 35 + 78 ;
}
+
+ void foo50(int value) {
+ for (int i=0; i < 10; i++) { // Noncompliant {{Use ++i instead of i++}}
+ System.out.println(i);
+ }
+ }
+
+ void foo51(int value) {
+ for (int i=0; i < 10; ++i) {
+ System.out.println(i);
+ }
+ }
}
\ No newline at end of file
diff --git a/java-plugin/src/test/files/UnnecessarilyAssignValuesToVariablesTestCheck.java b/java-plugin/src/test/files/UnnecessarilyAssignValuesToVariablesTestCheck.java
index 4a591504f..b61a58ec7 100644
--- a/java-plugin/src/test/files/UnnecessarilyAssignValuesToVariablesTestCheck.java
+++ b/java-plugin/src/test/files/UnnecessarilyAssignValuesToVariablesTestCheck.java
@@ -14,7 +14,7 @@ public int testSwitchCase() throws Exception {
int[] intArray = {10, 20, 30, 40, 50};
Exception variableException = new Exception("message");
- int variableNotUse = 5; // Noncompliant {{The variable is not assigned}}
+ int variableNotUse = 5; // Noncompliant {{The variable is declared but not really used}}
variableNotUse = 10;
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java
index a8cd4fd70..bebb9e605 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/PhpRuleRepository.java
@@ -38,6 +38,7 @@
import fr.greencodeinitiative.php.checks.IncrementCheck;
import fr.greencodeinitiative.php.checks.NoFunctionCallWhenDeclaringForLoop;
import fr.greencodeinitiative.php.checks.UseOfMethodsForBasicOperations;
+import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinitionAnnotationLoader;
import org.sonar.plugins.php.api.visitors.PHPCustomRuleRepository;
@@ -60,6 +61,7 @@ public void define(Context context) {
remediationCosts.put(AvoidSQLRequestInLoopCheck.RULE_KEY, "10min");
remediationCosts.put(AvoidFullSQLRequestCheck.RULE_KEY, "20min");
repository.rules().forEach(rule -> {
+ rule.setType(RuleType.CODE_SMELL);
String debt = remediationCosts.get(rule.key());
// TODO DDC : create support to use org.apache.commons.lang.StringUtils
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidDoubleQuoteCheck.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidDoubleQuoteCheck.java
index e5a81ec48..2fe45079c 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidDoubleQuoteCheck.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidDoubleQuoteCheck.java
@@ -12,6 +12,7 @@
import org.sonar.plugins.php.api.tree.Tree;
import org.sonar.plugins.php.api.tree.expression.LiteralTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidDoubleQuoteCheck.RULE_KEY,
@@ -19,6 +20,7 @@
description = AvoidDoubleQuoteCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S66")
public class AvoidDoubleQuoteCheck extends PHPSubscriptionCheck {
public static final String RULE_KEY = "EC66";
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidFullSQLRequestCheck.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidFullSQLRequestCheck.java
index 5edd93df0..fdc016916 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidFullSQLRequestCheck.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidFullSQLRequestCheck.java
@@ -10,6 +10,7 @@
import org.sonar.plugins.php.api.tree.Tree.Kind;
import org.sonar.plugins.php.api.tree.expression.LiteralTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidFullSQLRequestCheck.RULE_KEY,
@@ -17,6 +18,7 @@
description = AvoidFullSQLRequestCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S74")
public class AvoidFullSQLRequestCheck extends PHPSubscriptionCheck {
public static final String RULE_KEY = "EC74";
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidSQLRequestInLoopCheck.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidSQLRequestInLoopCheck.java
index 91a4afad9..358f43008 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidSQLRequestInLoopCheck.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidSQLRequestInLoopCheck.java
@@ -16,6 +16,7 @@
import org.sonar.plugins.php.api.tree.statement.IfStatementTree;
import org.sonar.plugins.php.api.tree.statement.StatementTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidSQLRequestInLoopCheck.RULE_KEY,
@@ -23,6 +24,7 @@
description = AvoidSQLRequestInLoopCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S72")
public class AvoidSQLRequestInLoopCheck extends PHPSubscriptionCheck {
public static final String RULE_KEY = "EC72";
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.java
index f1e340785..bced0aa40 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.java
@@ -7,6 +7,7 @@
import org.sonar.check.Rule;
import org.sonar.plugins.php.api.tree.Tree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.RULE_KEY,
@@ -14,10 +15,11 @@
description = AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@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-finally";
+ public static final String ERROR_MESSAGE = "Avoid using try-catch";
@Override
public List nodesToVisit() {
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheck.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheck.java
index 53ab26716..76607760d 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheck.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/AvoidUsingGlobalVariablesCheck.java
@@ -6,6 +6,7 @@
import org.sonar.check.Rule;
import org.sonar.plugins.php.api.tree.declaration.FunctionDeclarationTree;
import org.sonar.plugins.php.api.visitors.PHPVisitorCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidUsingGlobalVariablesCheck.RULE_KEY,
@@ -13,6 +14,7 @@
description = AvoidUsingGlobalVariablesCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "D4")
public class AvoidUsingGlobalVariablesCheck extends PHPVisitorCheck {
public static final String RULE_KEY = "EC4";
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java
index d89e97424..ba2c09e57 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/IncrementCheck.java
@@ -27,6 +27,7 @@
import org.sonar.plugins.php.api.tree.Tree;
import org.sonar.plugins.php.api.tree.Tree.Kind;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = IncrementCheck.RULE_KEY,
@@ -34,6 +35,7 @@
description = IncrementCheck.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S67")
public class IncrementCheck extends PHPSubscriptionCheck {
public static final String RULE_KEY = "EC67";
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/NoFunctionCallWhenDeclaringForLoop.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/NoFunctionCallWhenDeclaringForLoop.java
index 9b75867d4..4381c8a12 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/NoFunctionCallWhenDeclaringForLoop.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/NoFunctionCallWhenDeclaringForLoop.java
@@ -12,6 +12,7 @@
import org.sonar.plugins.php.api.tree.expression.ExpressionTree;
import org.sonar.plugins.php.api.tree.statement.ForStatementTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = NoFunctionCallWhenDeclaringForLoop.RULE_KEY,
@@ -19,6 +20,7 @@
description = NoFunctionCallWhenDeclaringForLoop.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S69")
public class NoFunctionCallWhenDeclaringForLoop extends PHPSubscriptionCheck {
public static final String RULE_KEY = "EC69";
diff --git a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/UseOfMethodsForBasicOperations.java b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/UseOfMethodsForBasicOperations.java
index d59af2230..4af8d8d9e 100644
--- a/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/UseOfMethodsForBasicOperations.java
+++ b/php-plugin/src/main/java/fr/greencodeinitiative/php/checks/UseOfMethodsForBasicOperations.java
@@ -16,6 +16,7 @@
import org.sonar.plugins.php.api.tree.expression.FunctionCallTree;
import org.sonar.plugins.php.api.tree.statement.StatementTree;
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = UseOfMethodsForBasicOperations.RULE_KEY,
@@ -23,6 +24,7 @@
description = UseOfMethodsForBasicOperations.ERROR_MESSAGE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "D2")
public class UseOfMethodsForBasicOperations extends PHPSubscriptionCheck {
public static final String RULE_KEY = "EC22";
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java
index 2a6f0225c..93de44ffb 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java
@@ -36,6 +36,7 @@
import fr.greencodeinitiative.python.checks.AvoidTryCatchFinallyCheck;
import fr.greencodeinitiative.python.checks.NoFunctionCallWhenDeclaringForLoop;
import org.apache.commons.lang.StringUtils;
+import org.sonar.api.rules.RuleType;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinitionAnnotationLoader;
import org.sonar.plugins.python.api.PythonCustomRuleRepository;
@@ -58,6 +59,7 @@ public void define(Context context) {
remediationCosts.put(AvoidSQLRequestInLoop.RULE_KEY, "10min");
remediationCosts.put(AvoidFullSQLRequest.RULE_KEY, "20min");
repository.rules().forEach(rule -> {
+ rule.setType(RuleType.CODE_SMELL);
String debt = remediationCosts.get(rule.key());
// TODO DDC : create support to use org.apache.commons.lang.StringUtils
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java
index ba0235e6b..39e700245 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java
@@ -14,6 +14,7 @@
import org.sonar.plugins.python.api.tree.StringElement;
import org.sonar.plugins.python.api.tree.StringLiteral;
import org.sonar.plugins.python.api.tree.Tree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidFullSQLRequest.RULE_KEY,
@@ -21,6 +22,7 @@
description = AvoidFullSQLRequest.MESSAGERULE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S74")
public class AvoidFullSQLRequest extends PythonSubscriptionCheck {
public static final String RULE_KEY = "EC74";
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java
index a33565e80..b3aeccde1 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java
@@ -16,6 +16,7 @@
import org.sonar.plugins.python.api.tree.Statement;
import org.sonar.plugins.python.api.tree.StatementList;
import org.sonar.plugins.python.api.tree.Tree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidGettersAndSetters.RULE_KEY,
@@ -23,6 +24,7 @@
description = AvoidGettersAndSetters.DESCRIPTION,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "D7")
public class AvoidGettersAndSetters extends PythonSubscriptionCheck {
public static final String RULE_KEY = "EC7";
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java
index 8203a69d3..ef712ec35 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java
@@ -60,6 +60,7 @@
import org.sonar.plugins.python.api.tree.WhileStatement;
import org.sonar.plugins.python.api.tree.YieldExpression;
import org.sonar.plugins.python.api.tree.YieldStatement;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidGlobalVariableInFunctionCheck.RULE_KEY,
@@ -67,6 +68,7 @@
description = AvoidGlobalVariableInFunctionCheck.DESCRIPTION,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "D4")
public class AvoidGlobalVariableInFunctionCheck extends PythonSubscriptionCheck {
public static final String RULE_KEY = "EC4";
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java
index cd1b6e5c1..97877cf22 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java
@@ -18,6 +18,7 @@
import org.sonar.plugins.python.api.tree.Name;
import org.sonar.plugins.python.api.tree.QualifiedExpression;
import org.sonar.plugins.python.api.tree.Tree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidSQLRequestInLoop.RULE_KEY,
@@ -25,6 +26,7 @@
description = AvoidSQLRequestInLoop.MESSAGE_RULE,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S72")
public class AvoidSQLRequestInLoop extends PythonSubscriptionCheck {
public static final String RULE_KEY = "EC72";
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchFinallyCheck.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchFinallyCheck.java
index 179650e7d..2d70e97f3 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchFinallyCheck.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchFinallyCheck.java
@@ -6,6 +6,7 @@
import org.sonar.plugins.python.api.SubscriptionContext;
import org.sonar.plugins.python.api.tree.Tree;
import org.sonar.plugins.python.api.tree.TryStatement;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = AvoidTryCatchFinallyCheck.RULE_KEY,
@@ -13,10 +14,11 @@
description = AvoidTryCatchFinallyCheck.DESCRIPTION,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S34")
public class AvoidTryCatchFinallyCheck extends PythonSubscriptionCheck {
public static final String RULE_KEY = "EC34";
- public static final String DESCRIPTION = "Avoid the use of try-catch-finally";
+ public static final String DESCRIPTION = "Avoid the use of try-catch";
@Override
public void initialize(Context context) {
diff --git a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/NoFunctionCallWhenDeclaringForLoop.java b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/NoFunctionCallWhenDeclaringForLoop.java
index d1fc56594..906a43253 100644
--- a/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/NoFunctionCallWhenDeclaringForLoop.java
+++ b/python-plugin/src/main/java/fr/greencodeinitiative/python/checks/NoFunctionCallWhenDeclaringForLoop.java
@@ -5,6 +5,7 @@
import org.sonar.plugins.python.api.PythonSubscriptionCheck;
import org.sonar.plugins.python.api.tree.CallExpression;
import org.sonar.plugins.python.api.tree.Tree;
+import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
@Rule(
key = NoFunctionCallWhenDeclaringForLoop.RULE_KEY,
@@ -12,6 +13,7 @@
description = NoFunctionCallWhenDeclaringForLoop.DESCRIPTION,
priority = Priority.MINOR,
tags = {"bug", "eco-design", "ecocode"})
+@DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S69")
public class NoFunctionCallWhenDeclaringForLoop extends PythonSubscriptionCheck {
public static final String RULE_KEY = "EC69";