From fc987b9da83f534ce9a4bf405c5d1175968e47f1 Mon Sep 17 00:00:00 2001 From: alograg Date: Thu, 18 Jan 2024 15:17:15 +0100 Subject: [PATCH 1/9] fix: :bug: issues #228 #233 #235 #240 --- RULES.md | 8 ++-- .../src/main/rules/EC4/EC4.json | 15 ------- .../src/main/rules/EC4/java/EC4.asciidoc | 41 ----------------- .../src/main/rules/EC4/java/EC4.json | 3 -- .../src/main/rules/EC4/php/EC4.asciidoc | 29 ------------ .../src/main/rules/EC4/python/EC4.asciidoc | 24 ---------- .../src/main/rules/EC63/EC63.json | 15 ------- .../src/main/rules/EC63/java/EC63.asciidoc | 23 ---------- .../src/main/rules/EC63/java/EC63.json | 3 -- .../src/main/rules/EC75/EC75.json | 16 ------- .../src/main/rules/EC75/java/EC75.asciidoc | 44 ------------------- .../src/main/rules/EC75/java/EC75.json | 3 -- 12 files changed, 4 insertions(+), 220 deletions(-) delete mode 100644 ecocode-rules-specifications/src/main/rules/EC4/EC4.json delete mode 100644 ecocode-rules-specifications/src/main/rules/EC4/java/EC4.asciidoc delete mode 100644 ecocode-rules-specifications/src/main/rules/EC4/java/EC4.json delete mode 100644 ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc delete mode 100644 ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc delete mode 100644 ecocode-rules-specifications/src/main/rules/EC63/EC63.json delete mode 100644 ecocode-rules-specifications/src/main/rules/EC63/java/EC63.asciidoc delete mode 100644 ecocode-rules-specifications/src/main/rules/EC63/java/EC63.json delete mode 100644 ecocode-rules-specifications/src/main/rules/EC75/EC75.json delete mode 100644 ecocode-rules-specifications/src/main/rules/EC75/java/EC75.asciidoc delete mode 100644 ecocode-rules-specifications/src/main/rules/EC75/java/EC75.json diff --git a/RULES.md b/RULES.md index b348788d3..2cc2424f7 100644 --- a/RULES.md +++ b/RULES.md @@ -70,12 +70,8 @@ This table lists rules proposed by the community but deprecated in ecoCode plugi | Rule key | Language | Name | Description | Invalidation | |----------|---------------------|----------------------------------------------------|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| EC4 | Java | Avoid using global variables | Global variables do not exist in Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/233) | | EC34 | Java / Python / PHP | Using try...catch...finally calls | Implementation is too simple (only detection of presence of "try" statement) AND replaced by `EC35` rule | Github discussion with measures : [general/java](https://github.com/green-code-initiative/ecoCode/pull/128) / [python](https://github.com/green-code-initiative/ecoCode-python/pull/6) / [php](https://github.com/green-code-initiative/ecoCode-php/pull/10) | -| EC53 | Java | Using arrays in foreach loops | No good arguments and not enough green measures. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/240) | -| EC63 | Java | Unnecessarily assigning values to variables | There are already 3 native SonarQube rules for Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/pull/258) | | EC66 | Python | Use single quote (') instead of quotation mark (") | Finally, not applicable for Python | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode-python/issues/4) | -| EC75 | Java | Concatenate Strings in loop | Optimizations on Java concatenation Strings are useless since JDK8 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/246) | ## Refused / Deleted rules @@ -85,3 +81,7 @@ This table lists rules proposed by the community but refused or/and deleted in e |----------|----------|------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | CRDOM203 | HTML | HTML page must contain a doctype tag | The difference in performance is negligible, this rule is more related to the user experience. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/103) | | CRPYT | Python | Use numpy array instead of standard list | The use of numpy library to perform array manipulation is more energy efficient than the use of the standard list functions. | [Github discussion with measures](https://github.com/green-code-initiative/ecoCode/issues/132) | +| EC4 | Java | Avoid using global variables | Global variables do not exist in Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/233) | +| EC53 | Java | Using arrays in foreach loops | No good arguments and not enough green measures. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/240) | +| EC63 | Java | Unnecessarily assigning values to variables | There are already 3 native SonarQube rules for Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/pull/258) | +| EC75 | Java | Concatenate Strings in loop | Optimizations on Java concatenation Strings are useless since JDK8 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/246) | diff --git a/ecocode-rules-specifications/src/main/rules/EC4/EC4.json b/ecocode-rules-specifications/src/main/rules/EC4/EC4.json deleted file mode 100644 index 0cf5108bd..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC4/EC4.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "title": "Avoid using global variables", - "type": "CODE_SMELL", - "status": "ready", - "remediation": { - "func": "Constant\/Issue", - "constantCost": "5min" - }, - "tags": [ - "performance", - "eco-design", - "ecocode" - ], - "defaultSeverity": "Minor" -} diff --git a/ecocode-rules-specifications/src/main/rules/EC4/java/EC4.asciidoc b/ecocode-rules-specifications/src/main/rules/EC4/java/EC4.asciidoc deleted file mode 100644 index 0aba43f63..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC4/java/EC4.asciidoc +++ /dev/null @@ -1,41 +0,0 @@ -*This rule is deprecated because not applicable to Java, and will be removed soon.* - -== Why is this an issue? - -When calling a global variable, the interpretation engine must check that it exists in all the scopes, that it has a value, etc. Passing global variables as arguments gives them the status of local variables inside the function, thus saving computing time (CPU cycles). - -=== CASE 1 (Avoid as possible) - -You are back on the service code. You see that the `func1()` uses `globalVariabl1`. Okay, but whats its value by now ? How does it change ? Who mutates the `globalVariabl1` before it comes to this function ? What have been the sequence of all these mutations ? You would have no idea. It will be quite difficult to figure all this out. - -=== CASE 2 (Recommended) - -You are back to you code, and see that the `func0()` fetches something and then passes it to `func1(param1)` as a parameter. You clearly know what the data is, how does it gets here. - -=== Noncompliant Code Example - -[source,java] ----- -var aGlobal = new String('Hello'); - -function globalLength(){ - length = aGlobal.length; - console.log(length); -} - -globalLength(); ----- - -== Compliant Solution - -[source,java] ----- -var aGlobal = new String('Hello'); - -function someVarLength(str){ - length = str.length; - console.log(length); -} - -somVarLength(aGlobal); ----- diff --git a/ecocode-rules-specifications/src/main/rules/EC4/java/EC4.json b/ecocode-rules-specifications/src/main/rules/EC4/java/EC4.json deleted file mode 100644 index 0b963543b..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC4/java/EC4.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "status": "deprecated" -} diff --git a/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc b/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc deleted file mode 100644 index 94021a9e6..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc +++ /dev/null @@ -1,29 +0,0 @@ -Prefer local variables as parameters - -When calling a global variable, the interpretation engine must check that it exists in all the scopes, that it has a value, etc. Passing global variables as arguments gives them the status of local variables inside the function, thus saving computing time (CPU cycles). - -## Noncompliant Code Example - -```php -var aGlobal = new String('Hello'); - -function globalLength(){ - length = aGlobal.length; - console.log(length); -} - -globalLength(); -``` - -## Compliant Solution - -```php -var aGlobal = new String('Hello'); - -function someVarLength(str){ - length = str.length; - console.log(length); -} - -somVarLength(aGlobal); -``` diff --git a/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc b/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc deleted file mode 100644 index b777840a9..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc +++ /dev/null @@ -1,24 +0,0 @@ -When function calls global variables, a lot a CPU cycles is consumed. - -## Noncompliant Code Example - -```python -global_var = 'foo' -def print_global_var_details(): - print(len(global_var)) # Noncompliant - print('Global var : ', global_var) # Noncompliant - print('Global var : ' + global_var) # Noncompliant -print_global_var_details() -``` - -## Compliant Solution - -```python -global_var = 'foo'; -def print_var_details(local_var) { - print(len(local_var)); - print('Var : ', local_var) - print('Var : ' + local_var) -} -print_length(global_var); -``` diff --git a/ecocode-rules-specifications/src/main/rules/EC63/EC63.json b/ecocode-rules-specifications/src/main/rules/EC63/EC63.json deleted file mode 100644 index dc9189905..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC63/EC63.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "title": "Do not unnecessarily assign values to variables", - "type": "CODE_SMELL", - "status": "ready", - "remediation": { - "func": "Constant\/Issue", - "constantCost": "5min" - }, - "tags": [ - "eco-design", - "ecocode", - "memory" - ], - "defaultSeverity": "Minor" -} diff --git a/ecocode-rules-specifications/src/main/rules/EC63/java/EC63.asciidoc b/ecocode-rules-specifications/src/main/rules/EC63/java/EC63.asciidoc deleted file mode 100644 index b5f7ea887..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC63/java/EC63.asciidoc +++ /dev/null @@ -1,23 +0,0 @@ -*This rule is deprecated because there are already Sonarqube native rules for the same things, and will be removed soon.* - -== Why is this an issue? - -Do not unnecessarily assign values to variables. It increases the use of RAM memory. - -== Noncompliant Code Example - -[source,java] ----- -String var1 = getValue(); -return var1; - -String var2 = "hello" -var2 = "world" //Non compliant cause never assigned ----- - -== Compliant Solution - -[source,java] ----- -return getValue(); ----- diff --git a/ecocode-rules-specifications/src/main/rules/EC63/java/EC63.json b/ecocode-rules-specifications/src/main/rules/EC63/java/EC63.json deleted file mode 100644 index 0b963543b..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC63/java/EC63.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "status": "deprecated" -} diff --git a/ecocode-rules-specifications/src/main/rules/EC75/EC75.json b/ecocode-rules-specifications/src/main/rules/EC75/EC75.json deleted file mode 100644 index 42cef3012..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC75/EC75.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title": "Don't concatenate Strings in loop, use StringBuilder instead.", - "type": "CODE_SMELL", - "status": "ready", - "remediation": { - "func": "Constant\/Issue", - "constantCost": "20min" - }, - "tags": [ - "performance", - "eco-design", - "ecocode", - "memory" - ], - "defaultSeverity": "Minor" -} diff --git a/ecocode-rules-specifications/src/main/rules/EC75/java/EC75.asciidoc b/ecocode-rules-specifications/src/main/rules/EC75/java/EC75.asciidoc deleted file mode 100644 index a0b7dad94..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC75/java/EC75.asciidoc +++ /dev/null @@ -1,44 +0,0 @@ -*This rule is deprecated because not applicable to Java since JDK8, and will be removed soon.* - -== Why is this an issue? - -Don't concatenate Strings in loop. Use `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. - -== Noncompliant Code Example - -[source,java] ----- -public String concatenateStrings(String[] strings) { - String result = ""; - - for (String string : strings) { - result += string; // Noncompliant - } - return result; -} - -public String concatenateStrings2() { - String result = ""; - - for (int i = 0; i < 1000; ++i) { - result += "another"; // Noncompliant - } - return result; -} ----- - -== Compliant Solution - -[source,java] ----- -public String concatenateStrings(String[] strings) { - StringBuilder result = new StringBuilder(); - - for (String string : strings) { - result.append(string); - } - return result.toString(); -} ----- diff --git a/ecocode-rules-specifications/src/main/rules/EC75/java/EC75.json b/ecocode-rules-specifications/src/main/rules/EC75/java/EC75.json deleted file mode 100644 index 0b963543b..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC75/java/EC75.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "status": "deprecated" -} From 573ba84b7a08f3019d26e8e809b4c4cb6bb2c91d Mon Sep 17 00:00:00 2001 From: alograg Date: Thu, 18 Jan 2024 15:17:51 +0100 Subject: [PATCH 2/9] [maven-release-plugin] prepare release 1.4.8 --- ecocode-rules-specifications/pom.xml | 2 +- pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ecocode-rules-specifications/pom.xml b/ecocode-rules-specifications/pom.xml index be5d0377a..5951629ef 100644 --- a/ecocode-rules-specifications/pom.xml +++ b/ecocode-rules-specifications/pom.xml @@ -5,7 +5,7 @@ io.ecocode ecocode-parent - 1.4.8-SNAPSHOT + 1.4.8 ecocode-rules-specifications diff --git a/pom.xml b/pom.xml index 099348e0a..875f79141 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.ecocode ecocode-parent - 1.4.8-SNAPSHOT + 1.4.8 pom ecoCode Sonar Plugins Project @@ -86,7 +86,7 @@ scm:git:https://github.com/green-code-initiative/ecocode scm:git:https://github.com/green-code-initiative/ecocode https://github.com/green-code-initiative/ecocode - HEAD + 1.4.8 GitHub From 3e4d14225752d2f8dddc0a0d7c376fceddcc4de8 Mon Sep 17 00:00:00 2001 From: alograg Date: Thu, 18 Jan 2024 15:17:51 +0100 Subject: [PATCH 3/9] [maven-release-plugin] prepare for next development iteration --- ecocode-rules-specifications/pom.xml | 2 +- pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ecocode-rules-specifications/pom.xml b/ecocode-rules-specifications/pom.xml index 5951629ef..a96b92aa7 100644 --- a/ecocode-rules-specifications/pom.xml +++ b/ecocode-rules-specifications/pom.xml @@ -5,7 +5,7 @@ io.ecocode ecocode-parent - 1.4.8 + 1.4.9-SNAPSHOT ecocode-rules-specifications diff --git a/pom.xml b/pom.xml index 875f79141..71befc9fa 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.ecocode ecocode-parent - 1.4.8 + 1.4.9-SNAPSHOT pom ecoCode Sonar Plugins Project @@ -86,7 +86,7 @@ scm:git:https://github.com/green-code-initiative/ecocode scm:git:https://github.com/green-code-initiative/ecocode https://github.com/green-code-initiative/ecocode - 1.4.8 + HEAD GitHub From 4bc9871f5b6cd3bdb6b9e3513deff46fe7fcc6b9 Mon Sep 17 00:00:00 2001 From: alograg Date: Fri, 19 Jan 2024 12:11:48 +0100 Subject: [PATCH 4/9] fix: :bookmark: Version assigned according to pull request comment --- ecocode-rules-specifications/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ecocode-rules-specifications/pom.xml b/ecocode-rules-specifications/pom.xml index a96b92aa7..187f901f3 100644 --- a/ecocode-rules-specifications/pom.xml +++ b/ecocode-rules-specifications/pom.xml @@ -5,7 +5,7 @@ io.ecocode ecocode-parent - 1.4.9-SNAPSHOT + 1.5.0-SNAPSHOT ecocode-rules-specifications diff --git a/pom.xml b/pom.xml index 71befc9fa..19affc8ae 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.ecocode ecocode-parent - 1.4.9-SNAPSHOT + 1.5.0-SNAPSHOT pom ecoCode Sonar Plugins Project From f689764808da1437fcbef7fe6be744ed51b38a17 Mon Sep 17 00:00:00 2001 From: alograg Date: Fri, 19 Jan 2024 12:14:32 +0100 Subject: [PATCH 5/9] fix: :rewind: Removal of EC4 rule for php and python --- .../src/main/rules/EC4/EC4.json | 15 ++++++++++ .../src/main/rules/EC4/php/EC4.asciidoc | 29 +++++++++++++++++++ .../src/main/rules/EC4/python/EC4.asciidoc | 24 +++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 ecocode-rules-specifications/src/main/rules/EC4/EC4.json create mode 100644 ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc create mode 100644 ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC4/EC4.json b/ecocode-rules-specifications/src/main/rules/EC4/EC4.json new file mode 100644 index 000000000..0cf5108bd --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC4/EC4.json @@ -0,0 +1,15 @@ +{ + "title": "Avoid using global variables", + "type": "CODE_SMELL", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "5min" + }, + "tags": [ + "performance", + "eco-design", + "ecocode" + ], + "defaultSeverity": "Minor" +} diff --git a/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc b/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc new file mode 100644 index 000000000..94021a9e6 --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc @@ -0,0 +1,29 @@ +Prefer local variables as parameters + +When calling a global variable, the interpretation engine must check that it exists in all the scopes, that it has a value, etc. Passing global variables as arguments gives them the status of local variables inside the function, thus saving computing time (CPU cycles). + +## Noncompliant Code Example + +```php +var aGlobal = new String('Hello'); + +function globalLength(){ + length = aGlobal.length; + console.log(length); +} + +globalLength(); +``` + +## Compliant Solution + +```php +var aGlobal = new String('Hello'); + +function someVarLength(str){ + length = str.length; + console.log(length); +} + +somVarLength(aGlobal); +``` diff --git a/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc b/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc new file mode 100644 index 000000000..b777840a9 --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc @@ -0,0 +1,24 @@ +When function calls global variables, a lot a CPU cycles is consumed. + +## Noncompliant Code Example + +```python +global_var = 'foo' +def print_global_var_details(): + print(len(global_var)) # Noncompliant + print('Global var : ', global_var) # Noncompliant + print('Global var : ' + global_var) # Noncompliant +print_global_var_details() +``` + +## Compliant Solution + +```python +global_var = 'foo'; +def print_var_details(local_var) { + print(len(local_var)); + print('Var : ', local_var) + print('Var : ' + local_var) +} +print_length(global_var); +``` From 48d85e7877ca37818235f18315866f2a4373e092 Mon Sep 17 00:00:00 2001 From: alograg Date: Fri, 19 Jan 2024 12:19:16 +0100 Subject: [PATCH 6/9] docs: :memo: Documentation of changes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec0177d3b..afc1c6f9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refuse rule proposition [Avoid returning a JPA Entity in a RestController](https://github.com/green-code-initiative/ecoCode/pull/138) for Java because of lack of arguments and measures - Refuse rule proposition [Avoid use of static in interface](https://github.com/green-code-initiative/ecoCode/pull/7) for Java because of lack of arguments and measures +- [Remove deprecated rules EC4, EC53, EC63 and EC75 for JAVA](https://github.com/green-code-initiative/ecoCode/pull/272) ### Deleted From a64d95f573dd8645e7fc0eb685fa2e43274f36c3 Mon Sep 17 00:00:00 2001 From: alograg Date: Fri, 19 Jan 2024 12:28:00 +0100 Subject: [PATCH 7/9] docs: :memo: Rules correction and format --- RULES.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/RULES.md b/RULES.md index 2cc2424f7..9958c26cd 100644 --- a/RULES.md +++ b/RULES.md @@ -63,6 +63,7 @@ This table lists rules proposed by the community but they have to be reworked / | EC22 | Java | The use of methods for basic operations | We have to measure this rule for Java before accepting the implementation | [Github discussion - issue](https://github.com/green-code-initiative/ecoCode/issues/131)
[Github discussion - PR](https://github.com/green-code-initiative/ecoCode/pull/148) | | CRJVM204 | Java | Detect unoptimized file formats | We have to clarify and rework this rule for Java before accepting the implementation | [Github discussion - issue](https://github.com/green-code-initiative/ecoCode/issues/105)
[Github discussion - PR](https://github.com/green-code-initiative/ecoCode/pull/153) | | | Java | Avoid returning a JPA Entity in a RestController | We have to clarify and measure this rule for Java before accepting the implementation | [Github discussion - issue](https://github.com/green-code-initiative/ecoCode-challenge/issues/58)
[Github discussion - PR](https://github.com/green-code-initiative/ecoCode/pull/138) | +| EC53 | Java | Using arrays in foreach loops | No good arguments and not enough green measures. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/240) | ## Deprecated rules @@ -77,11 +78,11 @@ This table lists rules proposed by the community but deprecated in ecoCode plugi This table lists rules proposed by the community but refused or/and deleted in ecoCode plugins with the justification. -| Rule key | Language | Name | Description | Invalidation | -|----------|----------|------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| CRDOM203 | HTML | HTML page must contain a doctype tag | The difference in performance is negligible, this rule is more related to the user experience. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/103) | -| CRPYT | Python | Use numpy array instead of standard list | The use of numpy library to perform array manipulation is more energy efficient than the use of the standard list functions. | [Github discussion with measures](https://github.com/green-code-initiative/ecoCode/issues/132) | -| EC4 | Java | Avoid using global variables | Global variables do not exist in Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/233) | -| EC53 | Java | Using arrays in foreach loops | No good arguments and not enough green measures. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/240) | -| EC63 | Java | Unnecessarily assigning values to variables | There are already 3 native SonarQube rules for Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/pull/258) | -| EC75 | Java | Concatenate Strings in loop | Optimizations on Java concatenation Strings are useless since JDK8 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/246) | +| Rule key | Language | Name | Description | Invalidation | +|----------|----------|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| CRDOM203 | HTML | HTML page must contain a doctype tag | The difference in performance is negligible, this rule is more related to the user experience. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/103) | +| CRPYT | Python | Use numpy array instead of standard list | The use of numpy library to perform array manipulation is more energy efficient than the use of the standard list functions. | [Github discussion with measures](https://github.com/green-code-initiative/ecoCode/issues/132) | +| EC4 | Java | Avoid using global variables | Global variables do not exist in Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/233) | +| EC63 | Java | Unnecessarily assigning values to variables | There are already 3 native SonarQube rules for Java. | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/pull/258) | +| EC75 | Java | Concatenate Strings in loop | Optimizations on Java concatenation Strings are useless since JDK8 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/246) | + From 6b604eeb8858890fa30f5db7191fa862a78ed2f2 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 24 Jan 2024 17:30:01 +0100 Subject: [PATCH 8/9] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afc1c6f9b..b0305a17c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refuse rule proposition [Avoid returning a JPA Entity in a RestController](https://github.com/green-code-initiative/ecoCode/pull/138) for Java because of lack of arguments and measures - Refuse rule proposition [Avoid use of static in interface](https://github.com/green-code-initiative/ecoCode/pull/7) for Java because of lack of arguments and measures -- [Remove deprecated rules EC4, EC53, EC63 and EC75 for JAVA](https://github.com/green-code-initiative/ecoCode/pull/272) +- Remove deprecated rules for JAVA ### Deleted From 5d9c74d01e56e9a034733b37d87a3bfc7a293716 Mon Sep 17 00:00:00 2001 From: alograg Date: Fri, 2 Feb 2024 14:57:38 +0100 Subject: [PATCH 9/9] fix: :memo: Text correction --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0305a17c..cde9f4599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refuse rule proposition [Avoid returning a JPA Entity in a RestController](https://github.com/green-code-initiative/ecoCode/pull/138) for Java because of lack of arguments and measures - Refuse rule proposition [Avoid use of static in interface](https://github.com/green-code-initiative/ecoCode/pull/7) for Java because of lack of arguments and measures -- Remove deprecated rules for JAVA +- Deprecated java rules EC4, EC53, EC63 and EC75 ### Deleted