Skip to content

Commit

Permalink
Merge branch 'main' into CRJVM-JAVA
Browse files Browse the repository at this point in the history
  • Loading branch information
dedece35 authored Sep 22, 2023
2 parents 9bb63b9 + 67e93e7 commit 8c798a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#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

### Deleted

Expand Down
4 changes: 2 additions & 2 deletions RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Some are applicable for different technologies.
| 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/) | 🚀 || 🚀 | 🚀 | 🚀 |
| ??? | Call a DOM element multiple times without caching (linter key : `@ecocode/no-multiple-access-dom-element`) | Access to the Document Object Model (DOM) is costly in terms of CPU resources (CPU cycles). Also, when you use the same DOM element from JavaScript multiple times, store its reference in a variable so that you do not go through the DOM again for the same element. | [cnumr best practices (3rd edition) BP_049](https://github.com/cnumr/best-practices/blob/main/chapters/BP_049_fr.md) | 🚫 | 🚫 || 🚫 | 🚫 |
| EC4 | Use global variables | When using a global variable, the interpretation engine must check: 1) that it exists in the current scope, in the one above, etc. ; 2) the variable has a value; 3) ... To avoid all these checks, it is often possible to pass the useful variables as arguments of routines, making them local. This process saves computational time (CPU cycles). | [cnumr best practices (3rd edition) BP_050 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) ||| 🚀 || 🚀 |
| EC53 | Using arrays in foreach loops | foreach deduplicates items in a list before starting the enumeration. It is therefore generally more economical to use a simple for loop when you have a good command of the collection. | [cnumr best practices (3rd edition) BP_053 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) || 🚀 | 🚀 | 🚀 | 🚀 |
| EC53 | Using arrays in foreach loops | foreach deduplicates items in a list before starting the enumeration. It is therefore generally more economical to use a simple for loop when you have a good command of the collection. | [cnumr best practices (3rd edition) BP_053 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) || 🚀 | 🚀 | 🚫 | 🚀 |
| EC7 | Rewrite native getter/setters | Overloading them lengthens the compilation and execution times of these methods, which are usually much better optimized by the language than by the developer. | [cnumr best practices (3rd edition) BP_062 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) | 🚀 | 🚀 | 🚀 || 🚀 |
| EC63 | Unnecessarily assigning values to variables | Avoid declaring and using variables when it is not indis-thinkable. Indeed, each allocation corresponds to the RAM occupied. | [cnumr best practices (3rd edition) BP_063 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) || 🚀 | 🚀 | 🚀 | 🚀 |
| EC66 | Use single quote (') instead of quotation mark (") | The shape using the quotation marks allows the developer to insert variables that will be substituted at run time. But if the string does not have a variable, use quotes instead. Thus, language will not look for variables to subtituture, which will reduce the consumption of CPU cycles. | [cnumr best practices (3rd edition) BP_066 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) | 🚀 || 🚀 || 🚀 |
Expand All @@ -36,7 +36,7 @@ Some are applicable for different technologies.
| EC72 | Perform an SQL query inside a loop | Servers are optimized to process multiple selections, insertions, or changes in a single query or transaction. consume CPU cycles, RAM, and bandwidth unnecessarily. | [cnumr best practices (3rd edition) BP_072](https://github.com/cnumr/best-practices/blob/main/chapters/BP_072_fr.md) ||| 🚀 || 🚀 |
| EC74 | Write SELECT * FROM | The database server must resolve the fields based on the schema. If you are familiar with the diagram, it is strongly recommended to name the fields. | [cnumr best practices (3rd edition) BP_074 (no longer exists in edition 4)](https://www.greenit.fr/2019/05/07/ecoconception-web-les-115-bonnes-pratiques-3eme-edition/) ||| 🚀 || 🚀 |
| EC1 | Calling a Spring repository inside a loop | The use of Spring repository in a loop induces unnecessary calculations by the CPU and therefore superfluous energy consumption. | || 🚫 | 🚫 | 🚫 | 🚫 |
| EC3 | Getting the size of the collection in the loop | When iterating over any collection, fetch the size of the collection in advance to avoid fetching it on each iteration, this saves CPU cycles, and therefore consumes less power. | ||| 🚀 | 🚀 | 🚀 |
| EC3 | Getting the size of the collection in the loop | When iterating over any collection, fetch the size of the collection in advance to avoid fetching it on each iteration, this saves CPU cycles, and therefore consumes less power. | ||| 🚀 | 🚫 | 🚀 |
| EC2 | Multiple if-else statement | Using too many conditional if-else statements will impact performance since JVM will have to compare the conditions. Prefer using a switch statement instead of multiple if-else if possible, or refactor your code to reduce conditonnal statements on the same variable. Switch statement has a performance advantage over if – else. | ||| 🚀 | 🚧 | 🚀 |
| EC76 | Usage of static collections | Avoid usage of static collections. If you want to use static collections make them final and create for example a singleton if needed containing the collections. The static fields are more complicated for the Garbage Collector to manage and can lead to memory leaks. | || 🚫 | 🚫 | 🚫 | 🚫 |
| EC77 | Usage Pattern.compile() in a non-static context | Avoid using Pattern.compile() in a non-static context. This operation requires a non negligible amount of computational power, Using a single match saves CPU cycles and RAM consumption. | || 🚫 | 🚫 | 🚫 | 🚫 |
Expand Down

0 comments on commit 8c798a8

Please sign in to comment.