From 17841a648bb7a0962137ebe0ea0d5cda818d612a Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Oct 2024 19:49:07 +0200 Subject: [PATCH 1/7] format RULES.md + delete EC34 and EC69 deprecated python rules --- CHANGELOG.md | 2 ++ RULES.md | 31 ++++++++++--------- .../src/main/rules/EC34/python/EC34.asciidoc | 25 --------------- .../src/main/rules/EC34/python/EC34.json | 3 -- .../src/main/rules/EC69/python/EC69.asciidoc | 17 ---------- .../src/main/rules/EC69/python/EC69.json | 3 -- 6 files changed, 18 insertions(+), 63 deletions(-) delete mode 100644 ecocode-rules-specifications/src/main/rules/EC34/python/EC34.asciidoc delete mode 100644 ecocode-rules-specifications/src/main/rules/EC34/python/EC34.json delete mode 100644 ecocode-rules-specifications/src/main/rules/EC69/python/EC69.asciidoc delete mode 100644 ecocode-rules-specifications/src/main/rules/EC69/python/EC69.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a60d77f..75034934f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deleted +- deletion of deprecated python EC34 and EC69 rules + ## [1.6.3] - 2024-07-26 ### Added diff --git a/RULES.md b/RULES.md index 5beaa38fa..a9abfcef5 100644 --- a/RULES.md +++ b/RULES.md @@ -1,10 +1,10 @@ # Rules - [Rules](#rules) - - [Rules support matrix by techno](#rules-support-matrix-by-techno) - - [Rules to be reworked / measured / clarified](#rules-to-be-reworked--measured--clarified) - - [Deprecated rules](#deprecated-rules) - - [Refused / Deleted rules](#refused--deleted-rules) + - [Rules support matrix by techno](#rules-support-matrix-by-techno) + - [Rules to be reworked / measured / clarified](#rules-to-be-reworked--measured--clarified) + - [Deprecated rules](#deprecated-rules) + - [Refused / Deleted rules](#refused--deleted-rules) ## Rules support matrix by techno @@ -36,7 +36,7 @@ Some are applicable for different technologies. | EC12 | Modify several CSS properties all at once | ESLint key : @ecocode/no-multiple-style-changes /// type : Front-end | | 🚫 | ❓ | ✅ | 🚫 | 🚫 | ❓ | 🚫 | | EC13 | Prefer API collections with pagination | ESLint key : @ecocode/prefer-collections-with-pagination /// type : Back-end | | ❓ | ❓ | ✅ | ❓ | ❓ | ❓ | 🚫 | | EC22 | The use of methods for basic operations | Using methods for basic operations consumes additional system resources. The interpreter must in effect and solve the objects and then the methods, just to carry out these simple operations of the language. | [cnumr best practices (3rd edition) BP_048 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) | 🚫 | 🚫 | 🚀 | 🚀 | 🚀 | 🚫 | 🚫 | -| EC24 | Limit the number of returns for a SQL query | ESLint key : @ecocode/limit-db-query-results /// type : Back-end | | 🚧 | 🚀 | ✅ | 🚀 | 🚀 | 🚀 | 🚫 | +| EC24 | Limit the number of returns for a SQL query | ESLint key : @ecocode/limit-db-query-results /// type : Back-end | | 🚧 | 🚀 | ✅ | 🚀 | 🚀 | 🚀 | 🚫 | | EC25 | Do not use an image with empty source attribute | ESLint key : @ecocode/no-empty-image-src-attribute /// type : Front-end | | ❓ | ❓ | ✅ | ❓ | ❓ | ❓ | 🚀 | | EC26 | Prefer shorthand CSS notations | ESLint key : @ecocode/prefer-shorthand-css-notations /// type : Front-end | | ❓ | ❓ | ✅ | ❓ | ❓ | ❓ | 🚫 | | EC27 | Usage of system.arraycopy to copy arrays | Programs spend most of the time in loops. These can be resource consuming, especially when they integrate heavy processing (IO access). Moreover, the size of the data and processing inside the loops will not allow full use of hardware mechanisms such as the cache or compiler optimization mechanisms. | | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | @@ -104,18 +104,19 @@ will be completely deleted in next releases and moved to bottom deleted rules ar | Rule key | Language | Name | Description | Invalidation | |----------|---------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 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) | -| EC69 | Python | Calling a loop invariant function in a loop condition | Finally, not applicable for Python | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode-python/issues/21) | + ## Refused / Deleted rules 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) | -| EC8 | JavaScript | Avoid using high accuracy geolocation | The rule has been merged with the rule EC523 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/318) | -| 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 | Don't concatenate strings in loops | 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) | +| EC8 | JavaScript | Avoid using high accuracy geolocation | The rule has been merged with the rule EC523 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/318) | +| 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) | +| EC69 | Python | Calling a loop invariant function in a loop condition | Finally, not applicable for Python | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode-python/issues/21) | +| EC75 | Java | Don't concatenate strings in loops | 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/EC34/python/EC34.asciidoc b/ecocode-rules-specifications/src/main/rules/EC34/python/EC34.asciidoc deleted file mode 100644 index d214cf7a1..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC34/python/EC34.asciidoc +++ /dev/null @@ -1,25 +0,0 @@ -Inside complex code parts (for example multiple loops, complex data constructions...), avoid using try...catch. - -When an exception is thrown, a variable (the exception itself) is created in a catch block, and it's destruction consumes unnecessary CPU cycles and RAM. Prefer using logical tests in this cases. - -## Noncompliant Code Example - -```python -try: - f = open(path) - print(fh.read()) -except: - print('No such file '+path -finally: - f.close() -``` - -## Compliant Solution - -```python -if os.path.isfile(path): - fh = open(path, 'r') - print(fh.read()) - fh.close -``` - diff --git a/ecocode-rules-specifications/src/main/rules/EC34/python/EC34.json b/ecocode-rules-specifications/src/main/rules/EC34/python/EC34.json deleted file mode 100644 index 0b963543b..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC34/python/EC34.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "status": "deprecated" -} diff --git a/ecocode-rules-specifications/src/main/rules/EC69/python/EC69.asciidoc b/ecocode-rules-specifications/src/main/rules/EC69/python/EC69.asciidoc deleted file mode 100644 index 3d73ce30a..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC69/python/EC69.asciidoc +++ /dev/null @@ -1,17 +0,0 @@ -Do not call a function when declaring a for-type loop in order to avoid function calls each iteration. It saves CPU cycles. - -## Noncompliant Code Example - -```python -for i in my_function(): # Noncompliant - ...... -``` - -## Compliant Solution - -```python -limit = my_function() -for i in limit: - ...... -``` - diff --git a/ecocode-rules-specifications/src/main/rules/EC69/python/EC69.json b/ecocode-rules-specifications/src/main/rules/EC69/python/EC69.json deleted file mode 100644 index 0b963543b..000000000 --- a/ecocode-rules-specifications/src/main/rules/EC69/python/EC69.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "status": "deprecated" -} From d9e50a6e7e48b49ca6462b979e74136fb5cfc9e1 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Oct 2024 20:01:11 +0200 Subject: [PATCH 2/7] update RULES.md : delete deprecated EC34 for python --- RULES.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/RULES.md b/RULES.md index a9abfcef5..353f7f18f 100644 --- a/RULES.md +++ b/RULES.md @@ -101,22 +101,23 @@ implemented in ecoCode plugins. This table lists rules proposed by the community but deprecated in ecoCode plugins with the justification. These rules will be completely deleted in next releases and moved to bottom deleted rules array. -| Rule key | Language | Name | Description | Invalidation | -|----------|---------------------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| 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) | +| Rule key | Language | Name | Description | Invalidation | +|----------|------------|-----------------------------------|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| EC34 | Java / 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) / [php](https://github.com/green-code-initiative/ecoCode-php/pull/10) | ## Refused / Deleted rules 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) | -| EC8 | JavaScript | Avoid using high accuracy geolocation | The rule has been merged with the rule EC523 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/318) | -| 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) | -| EC69 | Python | Calling a loop invariant function in a loop condition | Finally, not applicable for Python | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode-python/issues/21) | -| EC75 | Java | Don't concatenate strings in loops | 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) | +| EC8 | JavaScript | Avoid using high accuracy geolocation | The rule has been merged with the rule EC523 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/318) | +| EC34 | Python | 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) | +| 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) | +| EC69 | Python | Calling a loop invariant function in a loop condition | Finally, not applicable for Python | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode-python/issues/21) | +| EC75 | Java | Don't concatenate strings in loops | Optimizations on Java concatenation Strings are useless since JDK8 | [Github discussion with sources](https://github.com/green-code-initiative/ecoCode/issues/246) | From e232238f7d1a3a206b68b8921da907934f8eeee7 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Oct 2024 20:03:06 +0200 Subject: [PATCH 3/7] prepare 1.6.4 : update CHANGELOG --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75034934f..5fed22654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deleted +## [1.6.4] - 2024-10-04 + +### Deleted + - deletion of deprecated python EC34 and EC69 rules ## [1.6.3] - 2024-07-26 @@ -348,7 +352,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Comparison List -[unreleased](https://github.com/green-code-initiative/ecoCode/compare/1.6.2...HEAD) +[unreleased](https://github.com/green-code-initiative/ecoCode/compare/1.6.4...HEAD) +[1.6.4](https://github.com/green-code-initiative/ecoCode/compare/1.6.3...1.6.4) +[1.6.3](https://github.com/green-code-initiative/ecoCode/compare/1.6.2...1.6.3) [1.6.2](https://github.com/green-code-initiative/ecoCode/compare/1.6.1...1.6.2) [1.6.1](https://github.com/green-code-initiative/ecoCode/compare/1.6.0...1.6.1) [1.6.0](https://github.com/green-code-initiative/ecoCode/compare/1.5.4...1.6.0) From 7e298d1123abd7a319ba1758d60502a4cc32de98 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Oct 2024 20:03:28 +0200 Subject: [PATCH 4/7] [maven-release-plugin] prepare release 1.6.4 --- 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 a6fd3d2eb..b5a7cc04e 100644 --- a/ecocode-rules-specifications/pom.xml +++ b/ecocode-rules-specifications/pom.xml @@ -5,7 +5,7 @@ io.ecocode ecocode-parent - 1.6.4-SNAPSHOT + 1.6.4 ecocode-rules-specifications diff --git a/pom.xml b/pom.xml index 5695ca2ff..541aaab9e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.ecocode ecocode-parent - 1.6.4-SNAPSHOT + 1.6.4 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.6.4 GitHub From d3062f1e3cd98a7ea9c613f6e2885cd7bf7b69b1 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Oct 2024 20:03:28 +0200 Subject: [PATCH 5/7] [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 b5a7cc04e..0e5334b79 100644 --- a/ecocode-rules-specifications/pom.xml +++ b/ecocode-rules-specifications/pom.xml @@ -5,7 +5,7 @@ io.ecocode ecocode-parent - 1.6.4 + 1.6.5-SNAPSHOT ecocode-rules-specifications diff --git a/pom.xml b/pom.xml index 541aaab9e..9e63b82d5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.ecocode ecocode-parent - 1.6.4 + 1.6.5-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.6.4 + HEAD GitHub From 6491b4933a573d790be7ac5705489dc041436177 Mon Sep 17 00:00:00 2001 From: Zied Ellouze Date: Tue, 8 Oct 2024 17:28:32 +0200 Subject: [PATCH 6/7] Update url INSTALL.md with HOWTO.md Replace URL INSTALL.md --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 284fa6d16..551d8b588 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,7 +6,7 @@ ## Common installation notes / requirements -Please read common [INSTALL.md](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/INSTALL.md) +Please read common [HOWTO.md](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/HOWTO.md) in `ecoCode-common` repository. Please follow the specific guides below for additional information on installing the desired plugins. From 7c8265f15ed774b0efc70ded51838ef12de3619d Mon Sep 17 00:00:00 2001 From: imevanc Date: Fri, 11 Oct 2024 23:41:37 +0100 Subject: [PATCH 7/7] fix: fix-typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09ee03304..fb83c9b3b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ refer to the contribution section. 🌿 SonarQube Plugins ------------------- -6 technologies are supported by ecoCode right now: +7 technologies are supported by ecoCode right now: - "standard" plugins : - [Java plugin](https://github.com/green-code-initiative/ecoCode-java)