Skip to content

Commit

Permalink
Merge branch 'main' into feature/ISSUE-208--better-build
Browse files Browse the repository at this point in the history
  • Loading branch information
dedece35 authored Dec 1, 2023
2 parents 214ff70 + e52fd18 commit 8733160
Show file tree
Hide file tree
Showing 128 changed files with 2,378 additions and 219 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [ios#3](https://github.com/green-code-initiative/ecoCode-ios/issues/3) Move iOS rules into centralized rules repository
- [android#67](https://github.com/green-code-initiative/ecoCode-android/issues/67) Move Android rules into centralized rules repository
- [#216](https://github.com/green-code-initiative/ecoCode/issues/216) Upgrade rule EC2 for Java : Multiple if-else statement improvment
- [#106](https://github.com/green-code-initiative/ecoCode/issues/106) Upgrade RULES.md : rule EC67 not relevant neither for Python nor Rust
- [#225](https://github.com/green-code-initiative/ecoCode/pull/225) Upgrade licence system and licence headers of Java files
- [#140](https://github.com/green-code-initiative/ecoCode/issues/140) Upgrade rule EC3 for Python : no implementation possible for python
- [#136](https://github.com/green-code-initiative/ecoCode/issues/136) Upgrade rule EC53 for Python : no implementation possible for python
- [#128](https://github.com/green-code-initiative/ecoCode/pull/128) Adding EC35 rule for Python and PHP : EC35 rule replaces EC34 with a specific use case ("file not found" sepcific)
- [#132](https://github.com/green-code-initiative/ecoCode/issues/132) Upgrade RULES.md: set proposed Python rule "Use numpy array instead of standard list" as refused with link to the justification
- [#103](https://github.com/green-code-initiative/ecoCode/issues/103) Upgrade RULES.md: set proposed HTML rule "HTML page must contain a doctype tag" as refused with link to the justification

### Deleted

Expand Down
101 changes: 57 additions & 44 deletions RULES.md

Large diffs are not rendered by default.

137 changes: 40 additions & 97 deletions ecocode-rules-specifications/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,19 @@
<description>Repository that contains the specifications of every static-analysis rules available in ecoCode plugins.</description>
<url>https://github.com/green-code-initiative/ecoCode/tree/main/ecocode-rules-specifications</url>

<dependencies>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.analyzer-commons</groupId>
<artifactId>sonar-analyzer-commons</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!--
<plugin><!--
This plugin convert ASCIIDOC rule specification in HTML format
ASCIIDOC format is used with custom features such as :
- syntax highlighting (see code blocks on ASCIIDOC rules)
- inclusions (see: php/EC74.asciidoc)
- table data generation from CSV (see: php/EC34.asciidoc)
NB: Current version has a bug which display following false positive warning :
[WARNING] Duplicated destination found: overwriting file ...
This issue is fixed in 3.x release of asciidoctor-maven-plugin
-->
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
Expand All @@ -78,12 +40,13 @@
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/rules</sourceDirectory>
<outputDirectory>${project.build.directory}/rules</outputDirectory>
<outputDirectory>${project.build.directory}/rules-html</outputDirectory>
<attributes>
<source-highlighter>coderay</source-highlighter>
<coderay-css>style</coderay-css>
</attributes>
<preserveDirectories>true</preserveDirectories>
<embedAssets>true</embedAssets>
<headerFooter>false</headerFooter>
<relativeBaseDir>true</relativeBaseDir>
<logHandler>
Expand All @@ -95,65 +58,33 @@
</execution>
</executions>
</plugin>
<plugin>
<!--
Target resources tree need to be "flat".
Each metadata JSON file must be in the same tree as the HTML description file for the corresponding language.
The only way currently found to generate the correct file tree is to use antrun-plugin with `flattenmapper`
<plugin><!--
Prepare resources tree needed by language.
Each metadata JSON file must be in the same folder as the HTML description file for the corresponding language.
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<groupId>com.github.johnpoth</groupId>
<artifactId>jshell-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>process-resources</phase>
<id>prepare-rules-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="${project.build.outputDirectory}/io/ecocode/rules/java">
<fileset dir="${project.build.directory}/rules">
<include name="*/java/EC*.html" />
<include name="*/EC*.json" />
</fileset>
<flattenmapper />
</copy>
<copy todir="${project.build.outputDirectory}/io/ecocode/rules/php">
<fileset dir="${project.build.directory}/rules">
<include name="*/php/EC*.html" />
<include name="*/EC*.json" />
</fileset>
<flattenmapper />
</copy>
<copy todir="${project.build.outputDirectory}/io/ecocode/rules/python">
<fileset dir="${project.build.directory}/rules">
<include name="*/python/EC*.html" />
<include name="*/EC*.json" />
</fileset>
<flattenmapper />
</copy>
<copy todir="${project.build.outputDirectory}/io/ecocode/rules/js">
<fileset dir="${project.build.directory}/rules">
<include name="*/js/EC*.html" />
<include name="*/EC*.json" />
</fileset>
<flattenmapper />
</copy>
<copy todir="${project.build.outputDirectory}/io/ecocode/rules/ts">
<fileset dir="${project.build.directory}/rules">
<include name="*/ts/EC*.html" />
<include name="*/EC*.json" />
</fileset>
<flattenmapper />
</copy>
</target>
<scripts>
<script>${project.basedir}/src/main/script/PrepareResources.jsh</script>
</scripts>
<options>
<option>-R "-DsourceDir=${project.build.directory}/rules-html"</option>
<option>-R "-DtargetDir=${project.build.outputDirectory}/io/ecocode/rules"</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--
<plugin><!--
This module produce one artifact by language (with corresponding classifier)
For example, to add rule specifications for Python language, add following dependency in python sonarqube plugin:
Expand Down Expand Up @@ -205,26 +136,38 @@
</configuration>
</execution>
<execution>
<id>assembly-js</id>
<id>assembly-javascript</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/javascript.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>assembly-swift</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/js.xml</descriptor>
<descriptor>${project.basedir}/src/main/assembly/swift.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>assembly-ts</id>
<id>assembly-xml</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/ts.xml</descriptor>
<descriptor>${project.basedir}/src/main/assembly/xml.xml</descriptor>
</descriptors>
</configuration>
</execution>
Expand Down
18 changes: 18 additions & 0 deletions ecocode-rules-specifications/src/main/assembly/javascript.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id>javascript</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<includes>
<include>io/ecocode/rules/javascript/*.*</include>
</includes>
<outputDirectory/>
</fileSet>
</fileSets>
</assembly>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id>ts</id>
<id>swift</id>
<formats>
<format>jar</format>
</formats>
Expand All @@ -10,7 +10,7 @@
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<includes>
<include>io/ecocode/rules/ts/*.*</include>
<include>io/ecocode/rules/swift/*.*</include>
</includes>
<outputDirectory/>
</fileSet>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id>js</id>
<id>xml</id>
<formats>
<format>jar</format>
</formats>
Expand All @@ -10,7 +10,7 @@
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<includes>
<include>io/ecocode/rules/js/*.*</include>
<include>io/ecocode/rules/xml/*.*</include>
</includes>
<outputDirectory/>
</fileSet>
Expand Down
4 changes: 2 additions & 2 deletions ecocode-rules-specifications/src/main/rules/EC11/EC11.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"constantCost": "5min"
},
"tags": [
"ecocode",
"eco-design",
"performance",
"ecocode"
"performance"
],
"defaultSeverity": "Major",
"compatibleLanguages": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
## Rule details
This rule aims to reduce DOM access assigning its object to variable when access multiple time.
It saves CPU cycles.

This rule aims to reduce DOM access assigning its object to variable when access multiple time. It saves CPU cycles.

## Examples
== Examples

Examples of **incorrect** code for this rule:

```js
[source,js]
----
var el1 = document.getElementById("block1").test1;
var el2 = document.getElementById("block1").test2;
```
----

Examples of **correct** code for this rule:

```js
[source,js]
----
var blockElement = document.getElementById("block1");
var el1 = blockElement.test1;
var el2 = blockElement.test2;
```
----
4 changes: 2 additions & 2 deletions ecocode-rules-specifications/src/main/rules/EC12/EC12.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"constantCost": "10min"
},
"tags": [
"ecocode",
"eco-design",
"performance",
"ecocode"
"performance"
],
"defaultSeverity": "Major",
"compatibleLanguages": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
## Rule Details

This rule aims to disallow batching multiple style changes at once.

To limit the number of repaint/reflow, it is advised to batch style modifications by adding a class containing all style changes that will generate a unique reflow.

## Examples
== Examples

Examples of **non-compliant** code for this rule:

```html
[source,html]
----
<script>
element.style.height = "800px";
element.style.width = "600px";
element.style.color = "red";
</script>
```
----

Examples of **compliant** code for this rule:

```html
[source,html]
----
<style>
.in-error {
color: red;
Expand All @@ -30,4 +30,4 @@ Examples of **compliant** code for this rule:
<script>
element.addClass("in-error");
</script>
```
----
6 changes: 3 additions & 3 deletions ecocode-rules-specifications/src/main/rules/EC13/EC13.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"constantCost": "30min"
},
"tags": [
"ecocode",
"eco-design",
"performance",
"ecocode"
"nestjs",
"performance"
],
"defaultSeverity": "Minor",
"compatibleLanguages": [
"JAVASCRIPT",
"TYPESCRIPT"
]
}
Loading

0 comments on commit 8733160

Please sign in to comment.