diff --git a/pom.xml b/pom.xml index b5c8138..51b1510 100644 --- a/pom.xml +++ b/pom.xml @@ -61,15 +61,15 @@ 5.14.1 - 1.6.4 + 1.6.4 - io.ecocode - ecocode-rules-specifications - ${ecocode-rules-specifications.version} + org.green-code-initiative + creedengo-rules-specifications + ${creedengo-rules-specifications.version} python @@ -221,7 +221,7 @@ - io.ecocode:ecocode-rules-specifications:* + org.green-code-initiative:creedengo-rules-specifications:* META-INF/** diff --git a/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java b/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java index 206480d..34911f4 100644 --- a/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java +++ b/src/main/java/fr/greencodeinitiative/python/PythonRuleRepository.java @@ -44,9 +44,9 @@ public class PythonRuleRepository implements RulesDefinition, PythonCustomRuleRe ); public static final String LANGUAGE = "py"; - public static final String NAME = "ecoCode"; - public static final String RESOURCE_BASE_PATH = "io/ecocode/rules/python"; - public static final String REPOSITORY_KEY = "ecocode-python"; + public static final String NAME = "creendengo"; + public static final String RESOURCE_BASE_PATH = "org/green-code-initiative/rules/python"; + public static final String REPOSITORY_KEY = "gci-python"; private final SonarRuntime sonarRuntime; diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java index 34f5794..93fee0f 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidFullSQLRequest.java @@ -32,7 +32,7 @@ import java.util.Map; import java.util.regex.Pattern; -@Rule(key = "EC74") +@Rule(key = "GCI74") @DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S74") public class AvoidFullSQLRequest extends PythonSubscriptionCheck { diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java index 1f4302c..a316783 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidGettersAndSetters.java @@ -34,7 +34,7 @@ import org.sonar.plugins.python.api.tree.Tree; import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey; -@Rule(key = "EC7") +@Rule(key = "GCI7") @DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "D7") public class AvoidGettersAndSetters extends PythonSubscriptionCheck { diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java index c9b127b..6b1a3b6 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheck.java @@ -78,7 +78,7 @@ import org.sonar.plugins.python.api.tree.YieldStatement; import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey; -@Rule(key = "EC4") +@Rule(key = "GCI4") @DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "D4") public class AvoidGlobalVariableInFunctionCheck extends PythonSubscriptionCheck { diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidListComprehensionInIterations.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidListComprehensionInIterations.java index c92f22f..825eb88 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidListComprehensionInIterations.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidListComprehensionInIterations.java @@ -34,7 +34,7 @@ import static org.sonar.plugins.python.api.tree.Tree.Kind.LIST_COMPREHENSION; import static org.sonar.plugins.python.api.tree.Tree.Kind.REGULAR_ARGUMENT; -@Rule(key = "EC404") +@Rule(key = "GCI404") public class AvoidListComprehensionInIterations extends PythonSubscriptionCheck { public static final String DESCRIPTION = "Use generator comprehension instead of list comprehension in for loop declaration"; diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidMultipleIfElseStatementCheck.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidMultipleIfElseStatementCheck.java index ad39168..3b83a2d 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidMultipleIfElseStatementCheck.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidMultipleIfElseStatementCheck.java @@ -42,7 +42,7 @@ * - an "ELSE" statement is considered as a second IF statement using the same variables used on previous * - IF and ELSEIF statements are considered as an IF statement */ -@Rule(key = "EC2") +@Rule(key = "GCI2") public class AvoidMultipleIfElseStatementCheck extends PythonSubscriptionCheck { public static final String ERROR_MESSAGE = "Use a match-case statement instead of multiple if-else if possible"; diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java index f7ef686..c9f5d83 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidSQLRequestInLoop.java @@ -36,7 +36,7 @@ import org.sonar.plugins.python.api.tree.Tree; import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey; -@Rule(key = "EC72") +@Rule(key = "GCI72") @DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S72") public class AvoidSQLRequestInLoop extends PythonSubscriptionCheck { diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchWithFileOpenedCheck.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchWithFileOpenedCheck.java index 79c99b9..efdfa57 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchWithFileOpenedCheck.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidTryCatchWithFileOpenedCheck.java @@ -26,9 +26,9 @@ import static org.sonar.plugins.python.api.tree.Tree.Kind.CALL_EXPR; -@Rule(key = "EC35") +@Rule(key = "GCI35") @DeprecatedRuleKey(repositoryKey = "gci-python", ruleKey = "S34") -@DeprecatedRuleKey(ruleKey = "EC34") +@DeprecatedRuleKey(ruleKey = "GCI34") public class AvoidTryCatchWithFileOpenedCheck extends PythonSubscriptionCheck { public static final String DESCRIPTION = "Avoid the use of try-catch with a file open in try block"; diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnlimitedCache.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnlimitedCache.java index 1fb82c4..0f2851a 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnlimitedCache.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnlimitedCache.java @@ -27,7 +27,7 @@ import org.sonar.plugins.python.api.tree.RegularArgument; import org.sonar.plugins.python.api.tree.Tree; -@Rule(key = "EC89") +@Rule(key = "GCI89") public class AvoidUnlimitedCache extends PythonSubscriptionCheck { public static final String DESCRIPTION = "Do not set cache size to unlimited"; diff --git a/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnoptimizedVectorImagesCheck.java b/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnoptimizedVectorImagesCheck.java index 4fa44f8..c7b3f58 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnoptimizedVectorImagesCheck.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/AvoidUnoptimizedVectorImagesCheck.java @@ -25,7 +25,7 @@ import org.sonar.plugins.python.api.SubscriptionContext; import org.sonar.plugins.python.api.tree.*; -@Rule(key = "EC10") +@Rule(key = "GCI10") public class AvoidUnoptimizedVectorImagesCheck extends PythonSubscriptionCheck { public static final String DESCRIPTION = "Avoid using unoptimized vector images"; diff --git a/src/main/java/fr/greencodeinitiative/python/checks/DetectUnoptimizedImageFormat.java b/src/main/java/fr/greencodeinitiative/python/checks/DetectUnoptimizedImageFormat.java index e5d1daf..86a1fcd 100644 --- a/src/main/java/fr/greencodeinitiative/python/checks/DetectUnoptimizedImageFormat.java +++ b/src/main/java/fr/greencodeinitiative/python/checks/DetectUnoptimizedImageFormat.java @@ -26,10 +26,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -@Rule(key = "EC203") +@Rule(key = "GCI203") public class DetectUnoptimizedImageFormat extends PythonSubscriptionCheck { - protected static final String RULE_KEY = "EC203"; + protected static final String RULE_KEY = "GCI203"; protected static final String MESSAGERULE = "Detect unoptimized image format"; protected static final String MESSAGEERROR = "If possible, the utilisation of svg image format (or html tag) is recommended over other image format."; protected static final Pattern IMGEXTENSION = Pattern.compile("\\.(bmp|ico|tiff|webp|png|jpg|jpeg|jfif|pjpeg|pjp|gif|avif|apng)"); diff --git a/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java b/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java index 8fa5767..5addcf8 100644 --- a/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java +++ b/src/test/java/fr/greencodeinitiative/python/PythonRuleRepositoryTest.java @@ -51,9 +51,9 @@ void init() { @Test @DisplayName("Test repository metadata") void testMetadata() { - assertThat(repository.name()).isEqualTo("ecoCode"); + assertThat(repository.name()).isEqualTo("creedengo"); assertThat(repository.language()).isEqualTo("py"); - assertThat(repository.key()).isEqualTo("ecocode-python"); + assertThat(repository.key()).isEqualTo("gci-python"); } @Test @@ -69,11 +69,11 @@ void checkNumberRules() { } @Test - @DisplayName("All rule keys must be prefixed by 'EC'") + @DisplayName("All rule keys must be prefixed by 'GCI'") void testRuleKeyPrefix() { SoftAssertions assertions = new SoftAssertions(); repository.rules().forEach( - rule -> assertions.assertThat(rule.key()).startsWith("EC") + rule -> assertions.assertThat(rule.key()).startsWith("GCI") ); assertions.assertAll(); }