Skip to content

Commit

Permalink
Merge pull request #54 from green-code-initiative/ISSUE_40_refacto
Browse files Browse the repository at this point in the history
[ISSUE 40] refacto 'cnumr' to 'greencodeinitiative'
  • Loading branch information
dedece35 authored Jan 31, 2023
2 parents 4371c14 + 6888652 commit 303ac59
Show file tree
Hide file tree
Showing 223 changed files with 1,667 additions and 1,575 deletions.
36 changes: 19 additions & 17 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ Installation documentation
==========================

- [Installation documentation](#installation-documentation)
- [Requirements](#requirements)
- [Project structure](#project-structure)
- [Howto build the SonarQube ecoCode plugins](#howto-build-the-sonarqube-ecocode-plugins)
- [Requirements](#requirements-1)
- [Build the code](#build-the-code)
- [Howto install SonarQube dev environment](#howto-install-sonarqube-dev-environment)
- [Requirements](#requirements-2)
- [Start SonarQube (if first time)](#start-sonarqube-if-first-time)
- [Reinstall SonarQube (if needed)](#reinstall-sonarqube-if-needed)
- [Howto install Plugin Ecocode](#howto-install-plugin-ecocode)
- [Howto start or stop service (already installed)](#howto-start-or-stop-service-already-installed)
- [Howto create a release](#howto-create-a-release)
- [Howto debug a rule (with logs)](#howto-debug-a-rule-with-logs)
- [Links](#links)
- [Requirements](#requirements)
- [Project structure](#project-structure)
- [Howto build the SonarQube ecoCode plugins](#howto-build-the-sonarqube-ecocode-plugins)
- [Requirements](#requirements-1)
- [Build the code](#build-the-code)
- [Howto install SonarQube dev environment](#howto-install-sonarqube-dev-environment)
- [Requirements](#requirements-2)
- [Start SonarQube (if first time)](#start-sonarqube-if-first-time)
- [Reinstall SonarQube (if needed)](#reinstall-sonarqube-if-needed)
- [Howto install Plugin Ecocode](#howto-install-plugin-ecocode)
- [Howto start or stop service (already installed)](#howto-start-or-stop-service-already-installed)
- [Howto create a release](#howto-create-a-release)
- [Howto debug a rule (with logs)](#howto-debug-a-rule-with-logs)
- [Links](#links)

Requirements
------------
Expand Down Expand Up @@ -174,7 +174,8 @@ Howto create a release
2 new commits and a tag)
3. if all is ok, execute `tool_release_2_branch.sh` to create and push a new branch with that release and SNAPSHOT
4. if all is ok, on github, create a PR based on this new branch to `main` branch
5. wait that automatic check on the new branch are OK, then check modifications and finally merge it with `Create a merge commit` option
5. wait that automatic check on the new branch are OK, then check modifications and finally merge it
with `Create a merge commit` option
6. if PR merge is OK, then delete the branch as mentionned when PR merged
7. wait that automatic check on the `main` branch are OK, and then if all is ok, upgrade your local source code from
remote, and go to `main` branch and finally check locally if the
Expand All @@ -187,10 +188,11 @@ Howto create a release
Howto debug a rule (with logs)
------------------------------

1. Add logs like in `java-plugin/src/main/java/fr/cnumr/java/checks/OptimizeReadFileExceptions` class file
1. Add logs like in `java-plugin/src/main/java/fr/greencodeinitiative/java/checks/OptimizeReadFileExceptions` class file
2. Build plugin JARs with `tool_build.sh`
3. Launch local Sonar with `tool_docker_init.sh`
4. Launch a sonar scanner on an exemple project with `mvn verify` command (only the first time), followed by `mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar -Dsonar.login=***** -Dsonar.password=***** -X`
4. Launch a sonar scanner on an exemple project with `mvn verify` command (only the first time), followed
by `mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar -Dsonar.login=***** -Dsonar.password=***** -X`
5. logs will appear in console (debug logs will appear if `-X` option is given like above)

Links
Expand Down
4 changes: 2 additions & 2 deletions _TO_CHECK_ecolinter-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>ecocode-ecolinter-plugin</artifactId>
<name>ecoCode EcoLinter Sonar Plugin</name>
<packaging>sonar-plugin</packaging>

<dependencies>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
Expand Down Expand Up @@ -54,7 +54,7 @@
<configuration>
<pluginKey>${project.artifactId}</pluginKey>
<pluginName>${project.name}</pluginName>
<pluginClass>fr.cnumr.ecolinter.MyEcoLintRulesPlugin</pluginClass>
<pluginClass>fr.greencodeinitiative.ecolinter.MyEcoLintRulesPlugin</pluginClass>
<sonarLintSupported>true</sonarLintSupported>
<sonarQubeMinVersion>${sonarqube.version}</sonarQubeMinVersion>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package fr.cnumr.ecolinter;
package fr.greencodeinitiative.ecolinter;

import org.sonar.api.Plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package fr.cnumr.ecolinter;
package fr.greencodeinitiative.ecolinter;

import org.sonar.api.server.rule.RulesDefinition;
import org.sonarsource.analyzer.commons.ExternalRuleLoader;
Expand All @@ -29,7 +29,7 @@
public class MyEslintRulesDefinition implements RulesDefinition {

// don't change that because the path is hard coded in CheckVerifier
private static final String RESOURCE_BASE_PATH = "fr/cnumr/l10n/ecolint/rules/eslint/";
private static final String RESOURCE_BASE_PATH = "fr/greencodeinitiative/l10n/ecolint/rules/eslint/";

public static final String LINTER_NAME = "ESLint";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package fr.cnumr.ecolinter;
package fr.greencodeinitiative.ecolinter;

import org.sonar.api.server.rule.RulesDefinition;
import org.sonarsource.analyzer.commons.ExternalRuleLoader;
Expand All @@ -29,7 +29,7 @@
public class MyStylelintRulesDefinition implements RulesDefinition {

// don't change that because the path is hard coded in CheckVerifier
private static final String RESOURCE_BASE_PATH = "fr/cnumr/l10n/ecolint/rules/stylelint/";
private static final String RESOURCE_BASE_PATH = "fr/greencodeinitiative/l10n/ecolint/rules/stylelint/";

public static final String LINTER_NAME = "STYLELINT";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.cnumr.ecolinter;
package fr.greencodeinitiative.ecolinter;

import org.junit.jupiter.api.Test;
import org.sonar.api.Plugin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.cnumr.ecolinter;
package fr.greencodeinitiative.ecolinter;

import org.junit.jupiter.api.Test;
import org.sonar.api.server.rule.RulesDefinition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.cnumr.ecolinter;
package fr.greencodeinitiative.ecolinter;

import org.junit.jupiter.api.Test;
import org.sonar.api.server.rule.RulesDefinition;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.cnumr.python.checks;
package fr.greencodeinitiative.python.checks;

import org.junit.Test;
import org.sonar.python.checks.utils.PythonCheckVerifier;
Expand Down
13 changes: 7 additions & 6 deletions _TO_CHECK_xml-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.ecocode</groupId>
<artifactId>ecocode-parent</artifactId>
Expand All @@ -10,9 +11,9 @@

<artifactId>ecocode-xml-plugin</artifactId>
<packaging>sonar-plugin</packaging>

<name>ecoCode XML Sonar Plugin</name>

<dependencies>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
Expand Down Expand Up @@ -40,7 +41,7 @@
<dependency>
<groupId>org.sonarsource.analyzer-commons</groupId>
<artifactId>test-sonar-xml-parsing</artifactId>
<version>1.25.0.1003</version>
<version>1.25.0.1003</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -55,7 +56,7 @@
<configuration>
<pluginKey>${project.artifactId}</pluginKey>
<pluginName>${project.name}</pluginName>
<pluginClass>fr.cnumr.xml.XMLCustomRulesPlugin</pluginClass>
<pluginClass>fr.greencodeinitiative.xml.XMLCustomRulesPlugin</pluginClass>
<sonarLintSupported>true</sonarLintSupported>
<sonarQubeMinVersion>6.7</sonarQubeMinVersion>
<basePlugin>xml</basePlugin>
Expand Down
30 changes: 15 additions & 15 deletions _TO_CHECK_xml-plugin/src/main/java/fr/cnumr/xml/MyXmlRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package fr.cnumr.xml;
package fr.greencodeinitiative.xml;

import java.util.Collections;
import java.util.Set;

import org.sonar.api.server.rule.RulesDefinition;
import org.sonarsource.analyzer.commons.RuleMetadataLoader;

import fr.cnumr.xml.checks.CheckList;
import fr.greencodeinitiative.xml.checks.CheckList;

/**
* Extension point to define a PHP rule repository.
*/
public class MyXmlRules implements RulesDefinition {

public static final String LANGUAGE = "xml";
public static final String NAME = "Collectif Conception Numérique Responsable";
public static final String RESOURCE_BASE_PATH = "fr/cnumr/l10n/xml/rules/custom";
public static final String REPOSITORY_KEY = "cnumr-xml";
private static final Set<String> RULE_TEMPLATES_KEY = Collections.emptySet();
public static final String LANGUAGE = "xml";
public static final String NAME = "Collectif Conception Numérique Responsable";
public static final String RESOURCE_BASE_PATH = "fr/greencodeinitiative/l10n/xml/rules/custom";
public static final String REPOSITORY_KEY = "greencodeinitiative-xml";
private static final Set<String> RULE_TEMPLATES_KEY = Collections.emptySet();

@Override
public void define(Context context) {
NewRepository repository = context.createRepository(REPOSITORY_KEY, LANGUAGE).setName(NAME);
@Override
public void define(Context context) {
NewRepository repository = context.createRepository(REPOSITORY_KEY, LANGUAGE).setName(NAME);

RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH);
RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_BASE_PATH);

// add the new checks
ruleMetadataLoader.addRulesByAnnotatedClass(repository, CheckList.getCheckClasses());
// add the new checks
ruleMetadataLoader.addRulesByAnnotatedClass(repository, CheckList.getCheckClasses());

// repository.rule("XPathCheck").setTemplate(true);
// repository.rule("S3417").setTemplate(true);
repository.done();
}
repository.done();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package fr.cnumr.xml;
package fr.greencodeinitiative.xml;

import org.sonar.api.Plugin;

Expand All @@ -26,8 +26,8 @@
*/
public class XMLCustomRulesPlugin implements Plugin {

@Override
public void define(Context context) {
context.addExtension(MyXmlRules.class);
@Override
public void define(Context context) {
context.addExtension(MyXmlRules.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package fr.cnumr.xml.checks;
package fr.greencodeinitiative.xml.checks;

import java.util.Arrays;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.cnumr.xml.checks;
package fr.greencodeinitiative.xml.checks;

import java.util.Collections;

Expand All @@ -7,7 +7,7 @@
import org.sonarsource.analyzer.commons.xml.XmlFile;
import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheck;

@Rule(key = "S99", name = "Developpement", description = UseUnoptimizedVectorImage.MESSAGERULE, priority = Priority.MINOR, tags = { "bug" })
@Rule(key = "S99", name = "Developpement", description = UseUnoptimizedVectorImage.MESSAGERULE, priority = Priority.MINOR, tags = {"bug"})
public class UseUnoptimizedVectorImage extends SonarXmlCheck {

protected static final String MESSAGERULE = "Avoid the use of unoptimized vector images";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.cnumr.xml;
package fr.greencodeinitiative.xml;

import static org.junit.Assert.assertEquals;

Expand All @@ -7,7 +7,7 @@

public class MyXmlRulesTest {

private int NumberOfRuleInRepository = 6;
private final int NumberOfRuleInRepository = 6;

@Test
public void rules() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.cnumr.xml.checks;
package fr.greencodeinitiative.xml.checks;

import java.io.IOException;

Expand Down
2 changes: 1 addition & 1 deletion java-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<configuration>
<pluginKey>${project.artifactId}</pluginKey>
<pluginName>${project.name}</pluginName>
<pluginClass>fr.cnumr.java.JavaPlugin</pluginClass>
<pluginClass>fr.greencodeinitiative.java.JavaPlugin</pluginClass>
<sonarLintSupported>true</sonarLintSupported>
<sonarQubeMinVersion>${sonarqube.version}</sonarQubeMinVersion>
<!-- TODO : commented because plugin not loaded in SONAR if required version of java plugin is not installed -->
Expand Down
Loading

0 comments on commit 303ac59

Please sign in to comment.