From bf54374c213166ef03874ef6d3161275c042e764 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Mon, 28 Oct 2024 22:41:11 +0100 Subject: [PATCH 1/2] update EC94 rule doc --- RULES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RULES.md b/RULES.md index 353f7f18..63763f0e 100644 --- a/RULES.md +++ b/RULES.md @@ -69,7 +69,7 @@ Some are applicable for different technologies. | EC91 | Use `Where` before `OrderBy` | Filter elements before sorting them for improved efficiency | | ❓ | ❓ | ❓ | ❓ | ❓ | ✅ | ❓ | | EC92 | Use string.Length instead of comparison with empty string | Comparing a string to an empty string is unnecessary and can be replaced by a call to `string.Length` which is more performant and more readable. | | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | | EC93 | Return `Task` directly | Consider returning a `Task` directly instead of a single `await` | | ❓ | ❓ | ❓ | ❓ | ❓ | ✅ | ❓ | -| EC94 | Use orElseGet instead of orElse | Parameter of orElse() is evaluated, even when having a non-empty Optional. Supplier method of orElseGet passed as an argument is only executed when an Optional value isn’t present. Therefore, using orElseGet() will save computing time. | [cnumr best practices (3rd edition) BP_042](https://github.com/cnumr/best-practices/blob/main/chapters/BP_042_fr.md) | 🚧 | ❓ | ❓ | ❓ | ❓ | ❓ | ❓ | +| EC94 | Use orElseGet instead of orElse | Parameter of orElse() is evaluated, even when having a non-empty Optional. Supplier method of orElseGet passed as an argument is only executed when an Optional value isn’t present. Therefore, using orElseGet() will save computing time. | [Optimized use of Java Optional Else](https://github.com/green-code-initiative/ecoCode-challenge/issues/77) | 🚧 | ❓ | ❓ | ❓ | ❓ | ❓ | ❓ | | EC203 | Detect unoptimized file formats | When it is possible, to use svg format image over other image format | | 🚀 | 🚀 | 🚀 | ✅ | 🚀 | 🚀 | 🚫 | | EC404 | Avoid list comprehension in iterations | Use generator comprehension instead of list comprehension in for loop declaration | | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | | | Use official social media sharing buttons | These JavaScript plugins are very resource-intensive: to work, they require a large number of requests and download heavy files. It is better to prefer direct links. | [cnumr best practices (3rd edition) BP_019](https://github.com/cnumr/best-practices/blob/main/chapters/BP_019_fr.md) | 🚫 | 🚫 | 🚀 | 🚫 | 🚫 | 🚫 | 🚀 | From c1c55fe5ba167195e52db230590f672d6527f971 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Mon, 28 Oct 2024 23:35:01 +0100 Subject: [PATCH 2/2] update EC94 rule name --- ecocode-rules-specifications/src/main/rules/EC94/EC94.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecocode-rules-specifications/src/main/rules/EC94/EC94.json b/ecocode-rules-specifications/src/main/rules/EC94/EC94.json index aea5000b..7ece8804 100644 --- a/ecocode-rules-specifications/src/main/rules/EC94/EC94.json +++ b/ecocode-rules-specifications/src/main/rules/EC94/EC94.json @@ -1,5 +1,5 @@ { - "title": "Performance: orElseGet instead of orElse", + "title": "orElseGet instead of orElse", "type": "CODE_SMELL", "status": "ready", "remediation": {