Skip to content

Commit

Permalink
PR fixes and moved rules from EC to GCI
Browse files Browse the repository at this point in the history
  • Loading branch information
Lmgrto committed Dec 16, 2024
1 parent a68b033 commit 9c38044
Show file tree
Hide file tree
Showing 28 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- PHP rules moved from `ecoCode` repository to current repository
- [#121](https://github.com/green-code-initiative/creedengo/issues/121) new PHP rule : Multiple if-else statement +
- [#121](https://github.com/green-code-initiative/creedengo-rules-specifications/issues/121) new PHP rule : Multiple if-else statement +
refactoring implementation
- [#205](https://github.com/green-code-initiative/creedengo/issues/205) compatibility with SonarQube 10.1
- [#205](https://github.com/green-code-initiative/creedengo-rules-specifications/issues/205) compatibility with SonarQube 10.1

## Comparison list

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ the project is to provide a list of static code analyzers to highlight code stru
ecological impact: energy and resources over-consumption, "fatware", shortening terminals' lifespan, etc.

_creedengo_ is based on evolving catalogs
of [good practices](https://github.com/green-code-initiative/ecoCode/blob/main/docs/rules), for various technologies.
of [good practices](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/docs/rules), for various technologies.
This
SonarQube plugin then implements these catalogs as rules for scanning your PHP projects.

Expand Down Expand Up @@ -69,17 +69,17 @@ Ready to use binaries are available [from GitHub](https://github.com/green-code-
| 1.5.+ | 9.9.+ to 10.6.0 | 17 |

> Compatibility table of versions lower than 1.4.+ are available from the
> main [creedengo repository](https://github.com/green-code-initiative/ecoCode#-plugins-version-compatibility).
> main [creedengo repository](https://github.com/green-code-initiative/creedengo-rules-specifications#-plugins-version-compatibility).
🤝 Contribution
---------------

check [creedengo repository](https://github.com/green-code-initiative/ecoCode#-contribution)
check [creedengo repository](https://github.com/green-code-initiative/creedengo-rules-specifications#-contribution)

🤓 Main contributors
--------------------

check [creedengo repository](https://github.com/green-code-initiative/ecoCode#-main-contributors)
check [creedengo repository](https://github.com/green-code-initiative/creedengo-rules-specifications#-main-contributors)

Links
-----
Expand Down
2 changes: 1 addition & 1 deletion RULES.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Please read [RULES.md](https://github.com/green-code-initiative/ecoCode/blob/main/RULES.md) in `ecocode` repository.
Please read [RULES.md](https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/RULES.md) in `creedengo` repository.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.ecocode</groupId>
<groupId>org.green-code-initiative</groupId>
<artifactId>creedengo-php-plugin</artifactId>
<version>1.5.2-SNAPSHOT</version>

<packaging>sonar-plugin</packaging>

<name>creedengo - PHP language</name>
<description>Provides rules to reduce the environmental footprint of your PHP programs</description>
<inceptionYear>2023</inceptionYear>
<inceptionYear>2024</inceptionYear>

<url>https://github.com/green-code-initiative/creedengo-php</url>
<organization>
Expand Down Expand Up @@ -65,7 +65,7 @@
<sonar-packaging.version>1.23.0.740</sonar-packaging.version>

<!-- temporary version waiting for real automatic release in creedengo repository -->
<ecocode-rules-specifications.version>1.6.2</ecocode-rules-specifications.version>
<creedengo-rules-specifications.version>2.0.0</creedengo-rules-specifications.version>

<maven-shade.version>3.6.0</maven-shade.version>

Expand All @@ -83,8 +83,8 @@

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ecocode-rules-specifications</artifactId>
<version>${ecocode-rules-specifications.version}</version>
<artifactId>creedengo-rules-specifications</artifactId>
<version>${creedengo-rules-specifications.version}</version>
<classifier>php</classifier>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/greencodeinitiative/php/PHPPlugin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,9 +41,9 @@ public class PhpRuleRepository implements RulesDefinition, PHPCustomRuleReposito
);

private static final String LANGUAGE = "php";
private static final String NAME = "ecoCode";
private static final String RESOURCE_BASE_PATH = "io/ecocode/rules/php";
private static final String REPOSITORY_KEY = "ecocode-php";
private static final String NAME = "creedengo";
private static final String RESOURCE_BASE_PATH = "org/green-code-initiative/rules/php";
private static final String REPOSITORY_KEY = "creedengo-php";

private final SonarRuntime sonarRuntime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -30,7 +30,7 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC66")
@Rule(key = "GCI66")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S66")
public class AvoidDoubleQuoteCheck extends PHPSubscriptionCheck {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -28,7 +28,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Rule(key = "EC74")
@Rule(key = "GCI74")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S74")
public class AvoidFullSQLRequestCheck extends PHPSubscriptionCheck {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -32,7 +32,7 @@
import java.util.List;
import java.util.regex.Pattern;

@Rule(key = "EC3")
@Rule(key = "GCI3")
public class AvoidGettingSizeCollectionInLoopCheck extends PHPSubscriptionCheck {

public static final String ERROR_MESSAGE = "Avoid getting the size of the collection in the loop";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -40,7 +40,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 PHPSubscriptionCheck {

public static final String ERROR_MESSAGE = "Use a switch statement instead of multiple if-else if possible";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -34,7 +34,7 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC72")
@Rule(key = "GCI72")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S72")
public class AvoidSQLRequestInLoopCheck extends PHPSubscriptionCheck {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,7 +31,7 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC35")
@Rule(key = "GCI35")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S34")
@DeprecatedRuleKey(ruleKey = "EC34")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,7 +24,7 @@

import java.util.regex.Pattern;

@Rule(key = "EC4")
@Rule(key = "GCI4")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "D4")
public class AvoidUsingGlobalVariablesCheck extends PHPVisitorCheck {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -26,7 +26,7 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC67")
@Rule(key = "GCI67")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S67")
public class IncrementCheck extends PHPSubscriptionCheck {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -30,7 +30,7 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC69")
@Rule(key = "GCI69")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "S69")
public class NoFunctionCallWhenDeclaringForLoop extends PHPSubscriptionCheck {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -34,7 +34,7 @@
import org.sonar.plugins.php.api.visitors.PHPSubscriptionCheck;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "EC22")
@Rule(key = "GCI22")
@DeprecatedRuleKey(repositoryKey = "gci-php", ruleKey = "D2")
public class UseOfMethodsForBasicOperations extends PHPSubscriptionCheck {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -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("php");
assertThat(repository.key()).isEqualTo("ecocode-php");
assertThat(repository.key()).isEqualTo("creedengo-php");
}

@Test
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* creedengo - PHP language - Provides rules to reduce the environmental footprint of your PHP programs
* Copyright © 2023 Green Code Initiative (https://green-code-initiative.org)
* Copyright © 2024 Green Code Initiative (https://green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
Loading

0 comments on commit 9c38044

Please sign in to comment.