From 946679642788e31e50cfc546e31a41ec80048057 Mon Sep 17 00:00:00 2001 From: Damien Date: Thu, 30 May 2024 09:48:43 +0200 Subject: [PATCH] add EC530 to javascript --- CHANGELOG.md | 2 ++ .../src/main/rules/EC530/EC530.json | 8 ------- .../src/main/rules/EC530/java/EC530.json | 9 ++++++++ .../rules/EC530/javascript/EC530.asciidoc | 21 +++++++++++++++++++ .../main/rules/EC530/javascript/EC530.json | 13 ++++++++++++ .../src/main/rules/EC530/swift/EC530.json | 9 ++++++++ 6 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 ecocode-rules-specifications/src/main/rules/EC530/java/EC530.json create mode 100644 ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc create mode 100644 ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.json create mode 100644 ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a7ee4bb..73939e07a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- [#315](https://github.com/green-code-initiative/ecoCode/pull/315) Add rule EC530 for javascript + ### Changed ### Deleted diff --git a/ecocode-rules-specifications/src/main/rules/EC530/EC530.json b/ecocode-rules-specifications/src/main/rules/EC530/EC530.json index b834ab295..2bca358ec 100644 --- a/ecocode-rules-specifications/src/main/rules/EC530/EC530.json +++ b/ecocode-rules-specifications/src/main/rules/EC530/EC530.json @@ -6,14 +6,6 @@ "func": "Constant\/Issue", "constantCost": "5min" }, - "tags": [ - "sobriety", - "environment", - "ecocode", - "android", - "ios", - "eco-design" - ], "ecoScore": "0.4", "defaultSeverity": "Major" } diff --git a/ecocode-rules-specifications/src/main/rules/EC530/java/EC530.json b/ecocode-rules-specifications/src/main/rules/EC530/java/EC530.json new file mode 100644 index 000000000..639ebdd0d --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC530/java/EC530.json @@ -0,0 +1,9 @@ +{ + "tags": [ + "sobriety", + "environment", + "ecocode", + "android", + "eco-design" + ] +} diff --git a/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc b/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc new file mode 100644 index 000000000..830784d73 --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc @@ -0,0 +1,21 @@ +== Why is this an issue? + +Turning on the torch mode programmatically with `react-native-torch` must absolutely be avoided because the flashlight is one of the most energy-intensive component. + +## Non compliant Code Example + +[source,js,data-diff-id="2",data-diff-type="noncompliant"] +---- +import Torch from 'react-native-torch'; // Non-compliant +---- + +[source,js,data-diff-id="2",data-diff-type="compliant"] +---- +import axios from 'axios'; // Compliant +---- + +== Resources + +=== Documentation + +- [CNUMR best practices mobile](https://github.com/cnumr/best-practices-mobile) - Torch free \ No newline at end of file diff --git a/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.json b/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.json new file mode 100644 index 000000000..e32eae117 --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.json @@ -0,0 +1,13 @@ +{ + "tags": [ + "sobriety", + "environment", + "ecocode", + "react-native", + "eco-design" + ], + "compatibleLanguages": [ + "JAVASCRIPT", + "TYPESCRIPT" + ] +} diff --git a/ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.json b/ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.json new file mode 100644 index 000000000..bfcb65813 --- /dev/null +++ b/ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.json @@ -0,0 +1,9 @@ +{ + "tags": [ + "sobriety", + "environment", + "ecocode", + "ios", + "eco-design" + ] +}