From 4cf008d61263f53518023f52398b516967de4091 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Tue, 10 Dec 2024 23:27:04 +0100 Subject: [PATCH] migration from ecocode to creedengo --- .github/workflows/build.yml | 18 +- .../workflows/publish_to_maven_central.yml | 22 +- CHANGELOG.md | 6 + CODE_STYLE.md | 2 +- CONTRIBUTING.md | 2 +- INSTALL.md | 19 +- README.md | 59 ++- ecocode-rules-specifications/README.md | 45 --- ecocode-rules-specifications/pom.xml | 198 ---------- pom.xml | 370 ++++++++++++------ .../src => src}/main/assembly/csharp.xml | 2 +- .../src => src}/main/assembly/html.xml | 2 +- .../src => src}/main/assembly/java.xml | 2 +- .../src => src}/main/assembly/javascript.xml | 2 +- .../src => src}/main/assembly/php.xml | 2 +- .../src => src}/main/assembly/python.xml | 2 +- .../src => src}/main/assembly/swift.xml | 2 +- .../src => src}/main/assembly/xml.xml | 2 +- .../EC1.json => src/main/rules/GCI1/GCI1.json | 0 .../main/rules/GCI1/java/GCI1.asciidoc | 24 +- .../main/rules/GCI10/GCI10.json | 0 .../main/rules/GCI10/python/GCI10.asciidoc | 14 +- .../main/rules/GCI11/GCI11.json | 0 .../rules/GCI11/javascript/GCI11.asciidoc | 0 .../main/rules/GCI12/GCI12.json | 0 .../rules/GCI12/javascript/GCI12.asciidoc | 0 .../main/rules/GCI13/GCI13.json | 0 .../rules/GCI13/javascript/GCI13.asciidoc | 0 .../EC2.json => src/main/rules/GCI2/GCI2.json | 0 .../main/rules/GCI2/java/GCI2.asciidoc | 16 +- .../main/rules/GCI2/php/GCI2.asciidoc | 16 +- .../main/rules/GCI2/python/GCI2.asciidoc | 16 +- .../main/rules/GCI203/GCI203.json | 0 .../main/rules/GCI203/python/GCI203.asciidoc | 47 ++- .../main/rules/GCI22/GCI22.json | 0 .../main/rules/GCI22/php/GCI22.asciidoc | 14 +- .../main/rules/GCI22/php/GCI22.json | 0 .../main/rules/GCI24/GCI24.json | 0 .../main/rules/GCI24/java/GCI24.asciidoc | 0 .../rules/GCI24/javascript/GCI24.asciidoc | 0 .../main/rules/GCI25/GCI25.json | 0 .../rules/GCI25/javascript/GCI25.asciidoc | 0 .../main/rules/GCI26/GCI26.json | 0 .../rules/GCI26/javascript/GCI26.asciidoc | 0 .../main/rules/GCI27/GCI27.json | 0 .../main/rules/GCI27/java/GCI27.asciidoc | 14 +- .../main/rules/GCI28/GCI28.json | 0 .../main/rules/GCI28/java/GCI28.asciidoc | 14 +- .../main/rules/GCI29/GCI29.json | 0 .../rules/GCI29/javascript/GCI29.asciidoc | 0 .../EC3.json => src/main/rules/GCI3/GCI3.json | 0 .../main/rules/GCI3/java/GCI3.asciidoc | 14 +- .../main/rules/GCI3/php/GCI3.asciidoc | 14 +- .../main/rules/GCI30/GCI30.json | 0 .../rules/GCI30/javascript/GCI30.asciidoc | 0 .../main/rules/GCI31/GCI31.json | 0 .../rules/GCI31/javascript/GCI31.asciidoc | 0 .../main/rules/GCI32/GCI32.json | 0 .../main/rules/GCI32/java/GCI32.asciidoc | 14 +- .../main/rules/GCI34/GCI34.json | 0 .../main/rules/GCI34}/php/1GB.etsdiff.csv | 0 .../main/rules/GCI34/php/GCI34.asciidoc | 16 +- .../main/rules/GCI34/php/GCI34.json | 0 .../main/rules/GCI35/GCI35.json | 0 .../main/rules/GCI35}/php/1GB.etsdiff.csv | 0 .../main/rules/GCI35/php/GCI35.asciidoc | 16 +- .../main/rules/GCI35/python/GCI35.asciidoc | 14 +- .../main/rules/GCI36/GCI36.json | 0 .../main/rules/GCI36/html/GCI36.asciidoc | 0 .../EC4.json => src/main/rules/GCI4/GCI4.json | 0 .../main/rules/GCI4/php/GCI4.asciidoc | 14 +- .../main/rules/GCI4/python/GCI4.asciidoc | 14 +- .../main/rules/GCI404/GCI404.json | 0 .../main/rules/GCI404/python/GCI404.asciidoc | 14 +- .../EC5.json => src/main/rules/GCI5/GCI5.json | 0 .../main/rules/GCI5/java/GCI5.asciidoc | 14 +- .../main/rules/GCI500/GCI500.json | 0 .../main/rules/GCI500/java/GCI500.asciidoc | 14 +- .../main/rules/GCI501/GCI501.json | 0 .../main/rules/GCI501/java/GCI501.asciidoc | 14 +- .../main/rules/GCI502/GCI502.json | 0 .../main/rules/GCI502/java/GCI502.asciidoc | 7 +- .../main/rules/GCI503/GCI503.json | 0 .../main/rules/GCI503/java/GCI503.asciidoc | 14 +- .../main/rules/GCI504/GCI504.json | 0 .../main/rules/GCI504/java/GCI504.asciidoc | 18 +- .../main/rules/GCI505/GCI505.json | 0 .../main/rules/GCI505/java/GCI505.asciidoc | 7 +- .../main/rules/GCI505/swift/GCI505.asciidoc | 7 +- .../main/rules/GCI505/xml/GCI505.asciidoc | 16 +- .../main/rules/GCI506/GCI506.json | 0 .../main/rules/GCI506/java/GCI506.asciidoc | 7 +- .../main/rules/GCI507/GCI507.json | 0 .../main/rules/GCI507/java/GCI507.asciidoc | 7 +- .../main/rules/GCI507/xml/GCI507.asciidoc | 9 +- .../main/rules/GCI508/GCI508.json | 0 .../main/rules/GCI508/java/GCI508.asciidoc | 14 +- .../main/rules/GCI509/GCI509.json | 0 .../main/rules/GCI509/java/GCI509.asciidoc | 32 +- .../main/rules/GCI509/swift/GCI509.asciidoc | 14 +- .../main/rules/GCI510/GCI510.json | 0 .../main/rules/GCI510/java/GCI510.asciidoc | 14 +- .../main/rules/GCI511/GCI511.json | 0 .../main/rules/GCI511/java/GCI511.asciidoc | 19 +- .../main/rules/GCI512/GCI512.json | 0 .../main/rules/GCI512/java/GCI512.asciidoc | 14 +- .../main/rules/GCI513/GCI513.json | 0 .../main/rules/GCI513/java/GCI513.asciidoc | 14 +- .../main/rules/GCI513/swift/GCI513.asciidoc | 2 +- .../main/rules/GCI514/GCI514.json | 0 .../main/rules/GCI514/java/GCI514.asciidoc | 14 +- .../main/rules/GCI514/swift/GCI514.asciidoc | 2 +- .../main/rules/GCI515/GCI515.json | 0 .../main/rules/GCI515/java/GCI515.asciidoc | 14 +- .../main/rules/GCI515/swift/GCI515.asciidoc | 2 +- .../main/rules/GCI516/GCI516.json | 0 .../main/rules/GCI516/java/GCI516.asciidoc | 14 +- .../main/rules/GCI517/GCI517.json | 0 .../main/rules/GCI517/java/GCI517.asciidoc | 14 +- .../main/rules/GCI518/GCI518.json | 0 .../main/rules/GCI518/java/GCI518.asciidoc | 14 +- .../main/rules/GCI519/GCI519.json | 0 .../main/rules/GCI519/java/GCI519.asciidoc | 22 +- .../main/rules/GCI519/swift/GCI519.asciidoc | 22 +- .../main/rules/GCI519/xml/GCI519.asciidoc | 32 +- .../main/rules/GCI520/GCI520.json | 0 .../main/rules/GCI520/java/GCI520.asciidoc | 22 +- .../main/rules/GCI520/swift/GCI520.asciidoc | 17 +- .../main/rules/GCI520/xml/GCI520.asciidoc | 11 +- .../main/rules/GCI521/GCI521.json | 0 .../main/rules/GCI521/java/GCI521.asciidoc | 14 +- .../main/rules/GCI522/GCI522.json | 0 .../main/rules/GCI522/java/GCI522.asciidoc | 7 +- .../main/rules/GCI522/java/GCI522.json | 0 .../rules/GCI522/javascript/GCI522.asciidoc | 2 +- .../main/rules/GCI522/javascript/GCI522.json | 0 .../main/rules/GCI522/swift/GCI522.asciidoc | 7 +- .../main/rules/GCI522/swift/GCI522.json | 0 .../main/rules/GCI523/GCI523.json | 0 .../main/rules/GCI523/java/GCI523.asciidoc | 14 +- .../main/rules/GCI523/java/GCI523.json | 0 .../rules/GCI523/javascript/GCI523.asciidoc | 0 .../main/rules/GCI523/javascript/GCI523.json | 0 .../main/rules/GCI524/GCI524.json | 0 .../main/rules/GCI524/java/GCI524.asciidoc | 14 +- .../main/rules/GCI524/swift/GCI524.asciidoc | 7 +- .../main/rules/GCI525/GCI525.json | 0 .../main/rules/GCI525/java/GCI525.asciidoc | 14 +- .../main/rules/GCI526/GCI526.json | 0 .../main/rules/GCI526/java/GCI526.asciidoc | 14 +- .../main/rules/GCI527/GCI527.json | 0 .../main/rules/GCI527/java/GCI527.asciidoc | 14 +- .../main/rules/GCI528/GCI528.json | 0 .../main/rules/GCI528/java/GCI528.asciidoc | 12 +- .../main/rules/GCI529/GCI529.json | 0 .../main/rules/GCI529/java/GCI529.asciidoc | 12 +- .../main/rules/GCI530/GCI530.json | 0 .../main/rules/GCI530/java/GCI530.asciidoc | 7 +- .../main/rules/GCI530/java/GCI530.json | 0 .../rules/GCI530/javascript/GCI530.asciidoc | 2 +- .../main/rules/GCI530/javascript/GCI530.json | 0 .../main/rules/GCI530/swift/GCI530.asciidoc | 7 +- .../main/rules/GCI530/swift/GCI530.json | 0 .../main/rules/GCI531/GCI531.json | 0 .../main/rules/GCI531/java/GCI531.asciidoc | 14 +- .../main/rules/GCI532/GCI532.json | 0 .../main/rules/GCI532/java/GCI532.asciidoc | 12 +- .../main/rules/GCI533/GCI533.json | 0 .../main/rules/GCI533/swift/GCI533.asciidoc | 7 +- .../main/rules/GCI534/GCI534.json | 0 .../main/rules/GCI534/swift/GCI534.asciidoc | 7 +- .../main/rules/GCI540/GCI540.json | 0 .../main/rules/GCI540/xml/GCI540.asciidoc | 9 +- .../main/rules/GCI543/GCI543.json | 0 .../main/rules/GCI543/xml/GCI543.asciidoc | 9 +- .../main/rules/GCI544/GCI544.json | 0 .../main/rules/GCI544/xml/GCI544.asciidoc | 9 +- .../main/rules/GCI547/GCI547.json | 0 .../main/rules/GCI547/xml/GCI547.asciidoc | 9 +- .../main/rules/GCI548/GCI548.json | 0 .../main/rules/GCI548/xml/GCI548.asciidoc | 26 +- .../main/rules/GCI602/GCI602.json | 0 .../main/rules/GCI603/GCI603.json | 0 .../main/rules/GCI603/swift/GCI603.asciidoc | 14 +- .../main/rules/GCI66/GCI66.json | 0 .../main/rules/GCI66}/php/1GB.etsdiff.csv | 0 .../main/rules/GCI66/php/GCI66.asciidoc | 16 +- .../main/rules/GCI67/GCI67.json | 0 .../main/rules/GCI67/java/GCI67.asciidoc | 14 +- .../main/rules/GCI67}/php/1GB.etsdiff.csv | 0 .../main/rules/GCI67/php/GCI67.asciidoc | 16 +- .../main/rules/GCI69/GCI69.json | 0 .../main/rules/GCI69/csharp/GCI69.asciidoc | 8 +- .../main/rules/GCI69/java/GCI69.asciidoc | 14 +- .../main/rules/GCI69}/php/1GB.etsdiff.csv | 0 .../main/rules/GCI69/php/GCI69.asciidoc | 16 +- .../EC7.json => src/main/rules/GCI7/GCI7.json | 0 .../main/rules/GCI7/python/GCI7.asciidoc | 14 +- .../main/rules/GCI72/GCI72.json | 0 .../main/rules/GCI72/csharp/GCI72.asciidoc | 8 +- .../main/rules/GCI72/java/GCI72.asciidoc | 14 +- .../main/rules/GCI72}/php/1GB.etsdiff.csv | 0 .../main/rules/GCI72}/php/2GB.etsdiff.csv | 0 .../main/rules/GCI72}/php/4GB.etsdiff.csv | 0 .../main/rules/GCI72}/php/8GB.etsdiff.csv | 0 .../main/rules/GCI72/php/GCI72.asciidoc | 22 +- .../main/rules/GCI72/python/GCI72.asciidoc | 14 +- .../main/rules/GCI74/GCI74.json | 0 .../main/rules/GCI74/java/GCI74.asciidoc | 14 +- .../main/rules/GCI74}/php/1GB.etsdiff.csv | 0 .../main/rules/GCI74/php/GCI74.asciidoc | 16 +- .../main/rules/GCI74/python/GCI74.asciidoc | 14 +- .../main/rules/GCI75/GCI75.json | 0 .../main/rules/GCI75/csharp/GCI75.asciidoc | 8 +- .../main/rules/GCI76/GCI76.json | 0 .../main/rules/GCI76/java/GCI76.asciidoc | 14 +- .../main/rules/GCI77/GCI77.json | 0 .../main/rules/GCI77/java/GCI77.asciidoc | 28 +- .../main/rules/GCI78/GCI78.json | 0 .../main/rules/GCI78/java/GCI78.asciidoc | 14 +- .../main/rules/GCI79/GCI79.json | 0 .../main/rules/GCI79/java/GCI79.asciidoc | 14 +- .../main/rules/GCI81/GCI81.json | 0 .../main/rules/GCI81/csharp/GCI81.asciidoc | 8 +- .../main/rules/GCI82/GCI82.json | 0 .../main/rules/GCI82/csharp/GCI82.asciidoc | 8 +- .../main/rules/GCI83/GCI83.json | 0 .../main/rules/GCI83/csharp/GCI83.asciidoc | 8 +- .../main/rules/GCI84/GCI84.json | 0 .../main/rules/GCI84/csharp/GCI84.asciidoc | 8 +- .../main/rules/GCI85/GCI85.json | 0 .../main/rules/GCI85/csharp/GCI85.asciidoc | 10 +- .../main/rules/GCI86/GCI86.json | 0 .../main/rules/GCI86/csharp/GCI86.asciidoc | 8 +- .../main/rules/GCI87/GCI87.json | 0 .../main/rules/GCI87/csharp/GCI87.asciidoc | 8 +- .../main/rules/GCI88/GCI88.json | 0 .../main/rules/GCI88/csharp/GCI88.asciidoc | 8 +- .../main/rules/GCI89/GCI89.json | 0 .../main/rules/GCI89/python/GCI89.asciidoc | 24 +- .../EC9.json => src/main/rules/GCI9/GCI9.json | 0 .../main/rules/GCI9/javascript/GCI9.asciidoc | 0 .../main/rules/GCI91/GCI91.json | 0 .../main/rules/GCI91/csharp/GCI91.asciidoc | 8 +- .../main/rules/GCI92/GCI92.json | 0 .../main/rules/GCI92/csharp/GCI92.asciidoc | 8 +- .../main/rules/GCI93/GCI93.json | 0 .../main/rules/GCI93/csharp/GCI93.asciidoc | 8 +- .../main/rules/GCI94/GCI94.json | 0 .../main/rules/GCI94/java/GCI94.asciidoc | 23 +- .../main/rules/etsdiff-methodology.asciidoc | 2 +- .../main/script/PrepareResources.jsh | 2 +- 252 files changed, 1163 insertions(+), 1038 deletions(-) delete mode 100644 ecocode-rules-specifications/README.md delete mode 100644 ecocode-rules-specifications/pom.xml rename {ecocode-rules-specifications/src => src}/main/assembly/csharp.xml (88%) rename {ecocode-rules-specifications/src => src}/main/assembly/html.xml (88%) rename {ecocode-rules-specifications/src => src}/main/assembly/java.xml (89%) rename {ecocode-rules-specifications/src => src}/main/assembly/javascript.xml (88%) rename {ecocode-rules-specifications/src => src}/main/assembly/php.xml (89%) rename {ecocode-rules-specifications/src => src}/main/assembly/python.xml (88%) rename {ecocode-rules-specifications/src => src}/main/assembly/swift.xml (89%) rename {ecocode-rules-specifications/src => src}/main/assembly/xml.xml (89%) rename ecocode-rules-specifications/src/main/rules/EC1/EC1.json => src/main/rules/GCI1/GCI1.json (100%) rename ecocode-rules-specifications/src/main/rules/EC1/java/EC1.asciidoc => src/main/rules/GCI1/java/GCI1.asciidoc (89%) rename ecocode-rules-specifications/src/main/rules/EC10/EC10.json => src/main/rules/GCI10/GCI10.json (100%) rename ecocode-rules-specifications/src/main/rules/EC10/python/EC10.asciidoc => src/main/rules/GCI10/python/GCI10.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC11/EC11.json => src/main/rules/GCI11/GCI11.json (100%) rename ecocode-rules-specifications/src/main/rules/EC11/javascript/EC11.asciidoc => src/main/rules/GCI11/javascript/GCI11.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC12/EC12.json => src/main/rules/GCI12/GCI12.json (100%) rename ecocode-rules-specifications/src/main/rules/EC12/javascript/EC12.asciidoc => src/main/rules/GCI12/javascript/GCI12.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC13/EC13.json => src/main/rules/GCI13/GCI13.json (100%) rename ecocode-rules-specifications/src/main/rules/EC13/javascript/EC13.asciidoc => src/main/rules/GCI13/javascript/GCI13.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC2/EC2.json => src/main/rules/GCI2/GCI2.json (100%) rename ecocode-rules-specifications/src/main/rules/EC2/java/EC2.asciidoc => src/main/rules/GCI2/java/GCI2.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC2/php/EC2.asciidoc => src/main/rules/GCI2/php/GCI2.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC2/python/EC2.asciidoc => src/main/rules/GCI2/python/GCI2.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC203/EC203.json => src/main/rules/GCI203/GCI203.json (100%) rename ecocode-rules-specifications/src/main/rules/EC203/python/EC203.asciidoc => src/main/rules/GCI203/python/GCI203.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC22/EC22.json => src/main/rules/GCI22/GCI22.json (100%) rename ecocode-rules-specifications/src/main/rules/EC22/php/EC22.asciidoc => src/main/rules/GCI22/php/GCI22.asciidoc (51%) rename ecocode-rules-specifications/src/main/rules/EC22/php/EC22.json => src/main/rules/GCI22/php/GCI22.json (100%) rename ecocode-rules-specifications/src/main/rules/EC24/EC24.json => src/main/rules/GCI24/GCI24.json (100%) rename ecocode-rules-specifications/src/main/rules/EC24/java/EC24.asciidoc => src/main/rules/GCI24/java/GCI24.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC24/javascript/EC24.asciidoc => src/main/rules/GCI24/javascript/GCI24.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC25/EC25.json => src/main/rules/GCI25/GCI25.json (100%) rename ecocode-rules-specifications/src/main/rules/EC25/javascript/EC25.asciidoc => src/main/rules/GCI25/javascript/GCI25.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC26/EC26.json => src/main/rules/GCI26/GCI26.json (100%) rename ecocode-rules-specifications/src/main/rules/EC26/javascript/EC26.asciidoc => src/main/rules/GCI26/javascript/GCI26.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC27/EC27.json => src/main/rules/GCI27/GCI27.json (100%) rename ecocode-rules-specifications/src/main/rules/EC27/java/EC27.asciidoc => src/main/rules/GCI27/java/GCI27.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC28/EC28.json => src/main/rules/GCI28/GCI28.json (100%) rename ecocode-rules-specifications/src/main/rules/EC28/java/EC28.asciidoc => src/main/rules/GCI28/java/GCI28.asciidoc (84%) rename ecocode-rules-specifications/src/main/rules/EC29/EC29.json => src/main/rules/GCI29/GCI29.json (100%) rename ecocode-rules-specifications/src/main/rules/EC29/javascript/EC29.asciidoc => src/main/rules/GCI29/javascript/GCI29.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC3/EC3.json => src/main/rules/GCI3/GCI3.json (100%) rename ecocode-rules-specifications/src/main/rules/EC3/java/EC3.asciidoc => src/main/rules/GCI3/java/GCI3.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC3/php/EC3.asciidoc => src/main/rules/GCI3/php/GCI3.asciidoc (94%) rename ecocode-rules-specifications/src/main/rules/EC30/EC30.json => src/main/rules/GCI30/GCI30.json (100%) rename ecocode-rules-specifications/src/main/rules/EC30/javascript/EC30.asciidoc => src/main/rules/GCI30/javascript/GCI30.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC31/EC31.json => src/main/rules/GCI31/GCI31.json (100%) rename ecocode-rules-specifications/src/main/rules/EC31/javascript/EC31.asciidoc => src/main/rules/GCI31/javascript/GCI31.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC32/EC32.json => src/main/rules/GCI32/GCI32.json (100%) rename ecocode-rules-specifications/src/main/rules/EC32/java/EC32.asciidoc => src/main/rules/GCI32/java/GCI32.asciidoc (80%) rename ecocode-rules-specifications/src/main/rules/EC34/EC34.json => src/main/rules/GCI34/GCI34.json (100%) rename {ecocode-rules-specifications/src/main/rules/EC34 => src/main/rules/GCI34}/php/1GB.etsdiff.csv (100%) rename ecocode-rules-specifications/src/main/rules/EC34/php/EC34.asciidoc => src/main/rules/GCI34/php/GCI34.asciidoc (89%) rename ecocode-rules-specifications/src/main/rules/EC34/php/EC34.json => src/main/rules/GCI34/php/GCI34.json (100%) rename ecocode-rules-specifications/src/main/rules/EC35/EC35.json => src/main/rules/GCI35/GCI35.json (100%) rename {ecocode-rules-specifications/src/main/rules/EC35 => src/main/rules/GCI35}/php/1GB.etsdiff.csv (100%) rename ecocode-rules-specifications/src/main/rules/EC35/php/EC35.asciidoc => src/main/rules/GCI35/php/GCI35.asciidoc (89%) rename ecocode-rules-specifications/src/main/rules/EC35/python/EC35.asciidoc => src/main/rules/GCI35/python/GCI35.asciidoc (84%) rename ecocode-rules-specifications/src/main/rules/EC36/EC36.json => src/main/rules/GCI36/GCI36.json (100%) rename ecocode-rules-specifications/src/main/rules/EC36/html/EC36.asciidoc => src/main/rules/GCI36/html/GCI36.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC4/EC4.json => src/main/rules/GCI4/GCI4.json (100%) rename ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc => src/main/rules/GCI4/php/GCI4.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc => src/main/rules/GCI4/python/GCI4.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC404/EC404.json => src/main/rules/GCI404/GCI404.json (100%) rename ecocode-rules-specifications/src/main/rules/EC404/python/EC404.asciidoc => src/main/rules/GCI404/python/GCI404.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC5/EC5.json => src/main/rules/GCI5/GCI5.json (100%) rename ecocode-rules-specifications/src/main/rules/EC5/java/EC5.asciidoc => src/main/rules/GCI5/java/GCI5.asciidoc (87%) rename ecocode-rules-specifications/src/main/rules/EC500/EC500.json => src/main/rules/GCI500/GCI500.json (100%) rename ecocode-rules-specifications/src/main/rules/EC500/java/EC500.asciidoc => src/main/rules/GCI500/java/GCI500.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC501/EC501.json => src/main/rules/GCI501/GCI501.json (100%) rename ecocode-rules-specifications/src/main/rules/EC501/java/EC501.asciidoc => src/main/rules/GCI501/java/GCI501.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC502/EC502.json => src/main/rules/GCI502/GCI502.json (100%) rename ecocode-rules-specifications/src/main/rules/EC502/java/EC502.asciidoc => src/main/rules/GCI502/java/GCI502.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC503/EC503.json => src/main/rules/GCI503/GCI503.json (100%) rename ecocode-rules-specifications/src/main/rules/EC503/java/EC503.asciidoc => src/main/rules/GCI503/java/GCI503.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC504/EC504.json => src/main/rules/GCI504/GCI504.json (100%) rename ecocode-rules-specifications/src/main/rules/EC504/java/EC504.asciidoc => src/main/rules/GCI504/java/GCI504.asciidoc (75%) rename ecocode-rules-specifications/src/main/rules/EC505/EC505.json => src/main/rules/GCI505/GCI505.json (100%) rename ecocode-rules-specifications/src/main/rules/EC505/java/EC505.asciidoc => src/main/rules/GCI505/java/GCI505.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC505/swift/EC505.asciidoc => src/main/rules/GCI505/swift/GCI505.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC505/xml/EC505.asciidoc => src/main/rules/GCI505/xml/GCI505.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC506/EC506.json => src/main/rules/GCI506/GCI506.json (100%) rename ecocode-rules-specifications/src/main/rules/EC506/java/EC506.asciidoc => src/main/rules/GCI506/java/GCI506.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC507/EC507.json => src/main/rules/GCI507/GCI507.json (100%) rename ecocode-rules-specifications/src/main/rules/EC507/java/EC507.asciidoc => src/main/rules/GCI507/java/GCI507.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC507/xml/EC507.asciidoc => src/main/rules/GCI507/xml/GCI507.asciidoc (86%) rename ecocode-rules-specifications/src/main/rules/EC508/EC508.json => src/main/rules/GCI508/GCI508.json (100%) rename ecocode-rules-specifications/src/main/rules/EC508/java/EC508.asciidoc => src/main/rules/GCI508/java/GCI508.asciidoc (87%) rename ecocode-rules-specifications/src/main/rules/EC509/EC509.json => src/main/rules/GCI509/GCI509.json (100%) rename ecocode-rules-specifications/src/main/rules/EC509/java/EC509.asciidoc => src/main/rules/GCI509/java/GCI509.asciidoc (89%) rename ecocode-rules-specifications/src/main/rules/EC509/swift/EC509.asciidoc => src/main/rules/GCI509/swift/GCI509.asciidoc (86%) rename ecocode-rules-specifications/src/main/rules/EC510/EC510.json => src/main/rules/GCI510/GCI510.json (100%) rename ecocode-rules-specifications/src/main/rules/EC510/java/EC510.asciidoc => src/main/rules/GCI510/java/GCI510.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC511/EC511.json => src/main/rules/GCI511/GCI511.json (100%) rename ecocode-rules-specifications/src/main/rules/EC511/java/EC511.asciidoc => src/main/rules/GCI511/java/GCI511.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC512/EC512.json => src/main/rules/GCI512/GCI512.json (100%) rename ecocode-rules-specifications/src/main/rules/EC512/java/EC512.asciidoc => src/main/rules/GCI512/java/GCI512.asciidoc (86%) rename ecocode-rules-specifications/src/main/rules/EC513/EC513.json => src/main/rules/GCI513/GCI513.json (100%) rename ecocode-rules-specifications/src/main/rules/EC513/java/EC513.asciidoc => src/main/rules/GCI513/java/GCI513.asciidoc (90%) rename ecocode-rules-specifications/src/main/rules/EC513/swift/EC513.asciidoc => src/main/rules/GCI513/swift/GCI513.asciidoc (98%) rename ecocode-rules-specifications/src/main/rules/EC514/EC514.json => src/main/rules/GCI514/GCI514.json (100%) rename ecocode-rules-specifications/src/main/rules/EC514/java/EC514.asciidoc => src/main/rules/GCI514/java/GCI514.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC514/swift/EC514.asciidoc => src/main/rules/GCI514/swift/GCI514.asciidoc (97%) rename ecocode-rules-specifications/src/main/rules/EC515/EC515.json => src/main/rules/GCI515/GCI515.json (100%) rename ecocode-rules-specifications/src/main/rules/EC515/java/EC515.asciidoc => src/main/rules/GCI515/java/GCI515.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC515/swift/EC515.asciidoc => src/main/rules/GCI515/swift/GCI515.asciidoc (98%) rename ecocode-rules-specifications/src/main/rules/EC516/EC516.json => src/main/rules/GCI516/GCI516.json (100%) rename ecocode-rules-specifications/src/main/rules/EC516/java/EC516.asciidoc => src/main/rules/GCI516/java/GCI516.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC517/EC517.json => src/main/rules/GCI517/GCI517.json (100%) rename ecocode-rules-specifications/src/main/rules/EC517/java/EC517.asciidoc => src/main/rules/GCI517/java/GCI517.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC518/EC518.json => src/main/rules/GCI518/GCI518.json (100%) rename ecocode-rules-specifications/src/main/rules/EC518/java/EC518.asciidoc => src/main/rules/GCI518/java/GCI518.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC519/EC519.json => src/main/rules/GCI519/GCI519.json (100%) rename ecocode-rules-specifications/src/main/rules/EC519/java/EC519.asciidoc => src/main/rules/GCI519/java/GCI519.asciidoc (84%) rename ecocode-rules-specifications/src/main/rules/EC519/swift/EC519.asciidoc => src/main/rules/GCI519/swift/GCI519.asciidoc (86%) rename ecocode-rules-specifications/src/main/rules/EC519/xml/EC519.asciidoc => src/main/rules/GCI519/xml/GCI519.asciidoc (67%) rename ecocode-rules-specifications/src/main/rules/EC520/EC520.json => src/main/rules/GCI520/GCI520.json (100%) rename ecocode-rules-specifications/src/main/rules/EC520/java/EC520.asciidoc => src/main/rules/GCI520/java/GCI520.asciidoc (80%) rename ecocode-rules-specifications/src/main/rules/EC520/swift/EC520.asciidoc => src/main/rules/GCI520/swift/GCI520.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC520/xml/EC520.asciidoc => src/main/rules/GCI520/xml/GCI520.asciidoc (73%) rename ecocode-rules-specifications/src/main/rules/EC521/EC521.json => src/main/rules/GCI521/GCI521.json (100%) rename ecocode-rules-specifications/src/main/rules/EC521/java/EC521.asciidoc => src/main/rules/GCI521/java/GCI521.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC522/EC522.json => src/main/rules/GCI522/GCI522.json (100%) rename ecocode-rules-specifications/src/main/rules/EC522/java/EC522.asciidoc => src/main/rules/GCI522/java/GCI522.asciidoc (90%) rename ecocode-rules-specifications/src/main/rules/EC522/java/EC522.json => src/main/rules/GCI522/java/GCI522.json (100%) rename ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.asciidoc => src/main/rules/GCI522/javascript/GCI522.asciidoc (99%) rename ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.json => src/main/rules/GCI522/javascript/GCI522.json (100%) rename ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.asciidoc => src/main/rules/GCI522/swift/GCI522.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.json => src/main/rules/GCI522/swift/GCI522.json (100%) rename ecocode-rules-specifications/src/main/rules/EC523/EC523.json => src/main/rules/GCI523/GCI523.json (100%) rename ecocode-rules-specifications/src/main/rules/EC527/java/EC527.asciidoc => src/main/rules/GCI523/java/GCI523.asciidoc (87%) rename ecocode-rules-specifications/src/main/rules/EC523/java/EC523.json => src/main/rules/GCI523/java/GCI523.json (100%) rename ecocode-rules-specifications/src/main/rules/EC523/javascript/EC523.asciidoc => src/main/rules/GCI523/javascript/GCI523.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC523/javascript/EC523.json => src/main/rules/GCI523/javascript/GCI523.json (100%) rename ecocode-rules-specifications/src/main/rules/EC524/EC524.json => src/main/rules/GCI524/GCI524.json (100%) rename ecocode-rules-specifications/src/main/rules/EC524/java/EC524.asciidoc => src/main/rules/GCI524/java/GCI524.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC524/swift/EC524.asciidoc => src/main/rules/GCI524/swift/GCI524.asciidoc (94%) rename ecocode-rules-specifications/src/main/rules/EC525/EC525.json => src/main/rules/GCI525/GCI525.json (100%) rename ecocode-rules-specifications/src/main/rules/EC525/java/EC525.asciidoc => src/main/rules/GCI525/java/GCI525.asciidoc (87%) rename ecocode-rules-specifications/src/main/rules/EC526/EC526.json => src/main/rules/GCI526/GCI526.json (100%) rename ecocode-rules-specifications/src/main/rules/EC526/java/EC526.asciidoc => src/main/rules/GCI526/java/GCI526.asciidoc (86%) rename ecocode-rules-specifications/src/main/rules/EC527/EC527.json => src/main/rules/GCI527/GCI527.json (100%) rename ecocode-rules-specifications/src/main/rules/EC523/java/EC523.asciidoc => src/main/rules/GCI527/java/GCI527.asciidoc (87%) rename ecocode-rules-specifications/src/main/rules/EC528/EC528.json => src/main/rules/GCI528/GCI528.json (100%) rename ecocode-rules-specifications/src/main/rules/EC528/java/EC528.asciidoc => src/main/rules/GCI528/java/GCI528.asciidoc (90%) rename ecocode-rules-specifications/src/main/rules/EC529/EC529.json => src/main/rules/GCI529/GCI529.json (100%) rename ecocode-rules-specifications/src/main/rules/EC529/java/EC529.asciidoc => src/main/rules/GCI529/java/GCI529.asciidoc (93%) rename ecocode-rules-specifications/src/main/rules/EC530/EC530.json => src/main/rules/GCI530/GCI530.json (100%) rename ecocode-rules-specifications/src/main/rules/EC530/java/EC530.asciidoc => src/main/rules/GCI530/java/GCI530.asciidoc (89%) rename ecocode-rules-specifications/src/main/rules/EC530/java/EC530.json => src/main/rules/GCI530/java/GCI530.json (100%) rename ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc => src/main/rules/GCI530/javascript/GCI530.asciidoc (94%) rename ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.json => src/main/rules/GCI530/javascript/GCI530.json (100%) rename ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.asciidoc => src/main/rules/GCI530/swift/GCI530.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.json => src/main/rules/GCI530/swift/GCI530.json (100%) rename ecocode-rules-specifications/src/main/rules/EC531/EC531.json => src/main/rules/GCI531/GCI531.json (100%) rename ecocode-rules-specifications/src/main/rules/EC531/java/EC531.asciidoc => src/main/rules/GCI531/java/GCI531.asciidoc (83%) rename ecocode-rules-specifications/src/main/rules/EC532/EC532.json => src/main/rules/GCI532/GCI532.json (100%) rename ecocode-rules-specifications/src/main/rules/EC532/java/EC532.asciidoc => src/main/rules/GCI532/java/GCI532.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC533/EC533.json => src/main/rules/GCI533/GCI533.json (100%) rename ecocode-rules-specifications/src/main/rules/EC533/swift/EC533.asciidoc => src/main/rules/GCI533/swift/GCI533.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC534/EC534.json => src/main/rules/GCI534/GCI534.json (100%) rename ecocode-rules-specifications/src/main/rules/EC534/swift/EC534.asciidoc => src/main/rules/GCI534/swift/GCI534.asciidoc (95%) rename ecocode-rules-specifications/src/main/rules/EC540/EC540.json => src/main/rules/GCI540/GCI540.json (100%) rename ecocode-rules-specifications/src/main/rules/EC540/xml/EC540.asciidoc => src/main/rules/GCI540/xml/GCI540.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC543/EC543.json => src/main/rules/GCI543/GCI543.json (100%) rename ecocode-rules-specifications/src/main/rules/EC543/xml/EC543.asciidoc => src/main/rules/GCI543/xml/GCI543.asciidoc (84%) rename ecocode-rules-specifications/src/main/rules/EC544/EC544.json => src/main/rules/GCI544/GCI544.json (100%) rename ecocode-rules-specifications/src/main/rules/EC544/xml/EC544.asciidoc => src/main/rules/GCI544/xml/GCI544.asciidoc (85%) rename ecocode-rules-specifications/src/main/rules/EC547/EC547.json => src/main/rules/GCI547/GCI547.json (100%) rename ecocode-rules-specifications/src/main/rules/EC547/xml/EC547.asciidoc => src/main/rules/GCI547/xml/GCI547.asciidoc (83%) rename ecocode-rules-specifications/src/main/rules/EC548/EC548.json => src/main/rules/GCI548/GCI548.json (100%) rename ecocode-rules-specifications/src/main/rules/EC548/xml/EC548.asciidoc => src/main/rules/GCI548/xml/GCI548.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC602/EC602.json => src/main/rules/GCI602/GCI602.json (100%) rename ecocode-rules-specifications/src/main/rules/EC603/EC603.json => src/main/rules/GCI603/GCI603.json (100%) rename ecocode-rules-specifications/src/main/rules/EC603/swift/EC603.asciidoc => src/main/rules/GCI603/swift/GCI603.asciidoc (90%) rename ecocode-rules-specifications/src/main/rules/EC66/EC66.json => src/main/rules/GCI66/GCI66.json (100%) rename {ecocode-rules-specifications/src/main/rules/EC66 => src/main/rules/GCI66}/php/1GB.etsdiff.csv (100%) rename ecocode-rules-specifications/src/main/rules/EC66/php/EC66.asciidoc => src/main/rules/GCI66/php/GCI66.asciidoc (86%) rename ecocode-rules-specifications/src/main/rules/EC67/EC67.json => src/main/rules/GCI67/GCI67.json (100%) rename ecocode-rules-specifications/src/main/rules/EC67/java/EC67.asciidoc => src/main/rules/GCI67/java/GCI67.asciidoc (54%) rename {ecocode-rules-specifications/src/main/rules/EC67 => src/main/rules/GCI67}/php/1GB.etsdiff.csv (100%) rename ecocode-rules-specifications/src/main/rules/EC67/php/EC67.asciidoc => src/main/rules/GCI67/php/GCI67.asciidoc (74%) rename ecocode-rules-specifications/src/main/rules/EC69/EC69.json => src/main/rules/GCI69/GCI69.json (100%) rename ecocode-rules-specifications/src/main/rules/EC69/csharp/EC69.asciidoc => src/main/rules/GCI69/csharp/GCI69.asciidoc (93%) rename ecocode-rules-specifications/src/main/rules/EC69/java/EC69.asciidoc => src/main/rules/GCI69/java/GCI69.asciidoc (82%) rename {ecocode-rules-specifications/src/main/rules/EC69 => src/main/rules/GCI69}/php/1GB.etsdiff.csv (100%) rename ecocode-rules-specifications/src/main/rules/EC69/php/EC69.asciidoc => src/main/rules/GCI69/php/GCI69.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC7/EC7.json => src/main/rules/GCI7/GCI7.json (100%) rename ecocode-rules-specifications/src/main/rules/EC7/python/EC7.asciidoc => src/main/rules/GCI7/python/GCI7.asciidoc (83%) rename ecocode-rules-specifications/src/main/rules/EC72/EC72.json => src/main/rules/GCI72/GCI72.json (100%) rename ecocode-rules-specifications/src/main/rules/EC72/csharp/EC72.asciidoc => src/main/rules/GCI72/csharp/GCI72.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC72/java/EC72.asciidoc => src/main/rules/GCI72/java/GCI72.asciidoc (91%) rename {ecocode-rules-specifications/src/main/rules/EC72 => src/main/rules/GCI72}/php/1GB.etsdiff.csv (100%) rename {ecocode-rules-specifications/src/main/rules/EC72 => src/main/rules/GCI72}/php/2GB.etsdiff.csv (100%) rename {ecocode-rules-specifications/src/main/rules/EC72 => src/main/rules/GCI72}/php/4GB.etsdiff.csv (100%) rename {ecocode-rules-specifications/src/main/rules/EC72 => src/main/rules/GCI72}/php/8GB.etsdiff.csv (100%) rename ecocode-rules-specifications/src/main/rules/EC72/php/EC72.asciidoc => src/main/rules/GCI72/php/GCI72.asciidoc (90%) rename ecocode-rules-specifications/src/main/rules/EC72/python/EC72.asciidoc => src/main/rules/GCI72/python/GCI72.asciidoc (83%) rename ecocode-rules-specifications/src/main/rules/EC74/EC74.json => src/main/rules/GCI74/GCI74.json (100%) rename ecocode-rules-specifications/src/main/rules/EC74/java/EC74.asciidoc => src/main/rules/GCI74/java/GCI74.asciidoc (78%) rename {ecocode-rules-specifications/src/main/rules/EC74 => src/main/rules/GCI74}/php/1GB.etsdiff.csv (100%) rename ecocode-rules-specifications/src/main/rules/EC74/php/EC74.asciidoc => src/main/rules/GCI74/php/GCI74.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC74/python/EC74.asciidoc => src/main/rules/GCI74/python/GCI74.asciidoc (77%) rename ecocode-rules-specifications/src/main/rules/EC75/EC75.json => src/main/rules/GCI75/GCI75.json (100%) rename ecocode-rules-specifications/src/main/rules/EC75/csharp/EC75.asciidoc => src/main/rules/GCI75/csharp/GCI75.asciidoc (90%) rename ecocode-rules-specifications/src/main/rules/EC76/EC76.json => src/main/rules/GCI76/GCI76.json (100%) rename ecocode-rules-specifications/src/main/rules/EC76/java/EC76.asciidoc => src/main/rules/GCI76/java/GCI76.asciidoc (89%) rename ecocode-rules-specifications/src/main/rules/EC77/EC77.json => src/main/rules/GCI77/GCI77.json (100%) rename ecocode-rules-specifications/src/main/rules/EC77/java/EC77.asciidoc => src/main/rules/GCI77/java/GCI77.asciidoc (83%) rename ecocode-rules-specifications/src/main/rules/EC78/EC78.json => src/main/rules/GCI78/GCI78.json (100%) rename ecocode-rules-specifications/src/main/rules/EC78/java/EC78.asciidoc => src/main/rules/GCI78/java/GCI78.asciidoc (87%) rename ecocode-rules-specifications/src/main/rules/EC79/EC79.json => src/main/rules/GCI79/GCI79.json (100%) rename ecocode-rules-specifications/src/main/rules/EC79/java/EC79.asciidoc => src/main/rules/GCI79/java/GCI79.asciidoc (86%) rename ecocode-rules-specifications/src/main/rules/EC81/EC81.json => src/main/rules/GCI81/GCI81.json (100%) rename ecocode-rules-specifications/src/main/rules/EC81/csharp/EC81.asciidoc => src/main/rules/GCI81/csharp/GCI81.asciidoc (92%) rename ecocode-rules-specifications/src/main/rules/EC82/EC82.json => src/main/rules/GCI82/GCI82.json (100%) rename ecocode-rules-specifications/src/main/rules/EC82/csharp/EC82.asciidoc => src/main/rules/GCI82/csharp/GCI82.asciidoc (89%) rename ecocode-rules-specifications/src/main/rules/EC83/EC83.json => src/main/rules/GCI83/GCI83.json (100%) rename ecocode-rules-specifications/src/main/rules/EC83/csharp/EC83.asciidoc => src/main/rules/GCI83/csharp/GCI83.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC84/EC84.json => src/main/rules/GCI84/GCI84.json (100%) rename ecocode-rules-specifications/src/main/rules/EC84/csharp/EC84.asciidoc => src/main/rules/GCI84/csharp/GCI84.asciidoc (94%) rename ecocode-rules-specifications/src/main/rules/EC85/EC85.json => src/main/rules/GCI85/GCI85.json (100%) rename ecocode-rules-specifications/src/main/rules/EC85/csharp/EC85.asciidoc => src/main/rules/GCI85/csharp/GCI85.asciidoc (93%) rename ecocode-rules-specifications/src/main/rules/EC86/EC86.json => src/main/rules/GCI86/GCI86.json (100%) rename ecocode-rules-specifications/src/main/rules/EC86/csharp/EC86.asciidoc => src/main/rules/GCI86/csharp/GCI86.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC87/EC87.json => src/main/rules/GCI87/GCI87.json (100%) rename ecocode-rules-specifications/src/main/rules/EC87/csharp/EC87.asciidoc => src/main/rules/GCI87/csharp/GCI87.asciidoc (88%) rename ecocode-rules-specifications/src/main/rules/EC88/EC88.json => src/main/rules/GCI88/GCI88.json (100%) rename ecocode-rules-specifications/src/main/rules/EC88/csharp/EC88.asciidoc => src/main/rules/GCI88/csharp/GCI88.asciidoc (90%) rename ecocode-rules-specifications/src/main/rules/EC89/EC89.json => src/main/rules/GCI89/GCI89.json (100%) rename ecocode-rules-specifications/src/main/rules/EC89/python/EC89.asciidoc => src/main/rules/GCI89/python/GCI89.asciidoc (82%) rename ecocode-rules-specifications/src/main/rules/EC9/EC9.json => src/main/rules/GCI9/GCI9.json (100%) rename ecocode-rules-specifications/src/main/rules/EC9/javascript/EC9.asciidoc => src/main/rules/GCI9/javascript/GCI9.asciidoc (100%) rename ecocode-rules-specifications/src/main/rules/EC91/EC91.json => src/main/rules/GCI91/GCI91.json (100%) rename ecocode-rules-specifications/src/main/rules/EC91/csharp/EC91.asciidoc => src/main/rules/GCI91/csharp/GCI91.asciidoc (94%) rename ecocode-rules-specifications/src/main/rules/EC92/EC92.json => src/main/rules/GCI92/GCI92.json (100%) rename ecocode-rules-specifications/src/main/rules/EC92/csharp/EC92.asciidoc => src/main/rules/GCI92/csharp/GCI92.asciidoc (83%) rename ecocode-rules-specifications/src/main/rules/EC93/EC93.json => src/main/rules/GCI93/GCI93.json (100%) rename ecocode-rules-specifications/src/main/rules/EC93/csharp/EC93.asciidoc => src/main/rules/GCI93/csharp/GCI93.asciidoc (91%) rename ecocode-rules-specifications/src/main/rules/EC94/EC94.json => src/main/rules/GCI94/GCI94.json (100%) rename ecocode-rules-specifications/src/main/rules/EC94/java/EC94.asciidoc => src/main/rules/GCI94/java/GCI94.asciidoc (53%) rename {ecocode-rules-specifications/src => src}/main/rules/etsdiff-methodology.asciidoc (89%) rename {ecocode-rules-specifications/src => src}/main/script/PrepareResources.jsh (98%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d977a8fec..2dc9155b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,17 +25,27 @@ jobs: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: 11 + - name: Cache SonarQube packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - - name: Verify - run: ./mvnw -e -B verify + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=green-code-initiative_creedengo-rules-specifications diff --git a/.github/workflows/publish_to_maven_central.yml b/.github/workflows/publish_to_maven_central.yml index cfe7d0b3a..61b664641 100644 --- a/.github/workflows/publish_to_maven_central.yml +++ b/.github/workflows/publish_to_maven_central.yml @@ -4,7 +4,7 @@ # - Go to: https://s01.oss.sonatype.org/#stagingRepositories # - Check upload and if all is right, "Close" corresponding Staging Repository # - "Release" corresponding Staging Repository -# - Wait some hours and then check availability of release on Maven central: https://search.maven.org/search?q=g:io.ecocode +# - Wait some hours and then check availability of release on Maven central: https://search.maven.org/search?q=g:org.greencodeinitiative # # Additional information: # - https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-maven#publishing-packages-to-the-maven-central-repository @@ -23,18 +23,18 @@ jobs: steps: # Checks out a copy of project's repository. - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Sets up the Java JDK, and also configures the Maven `settings.xml` file to add authentication for the # `ossrh` repository using the `OSSRH_USERNAME` and `OSSRH_TOKEN` environment variables. - name: Set up Maven Central Repository - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '11' distribution: 'adopt' - server-id: 'ossrh' # must match the serverId configured for the nexus-staging-maven-plugin in `pom.xml` - server-username: OSSRH_USERNAME - server-password: OSSRH_TOKEN + server-id: 'central' # must match the serverId configured for the central-publishing-maven-plugin in `pom.xml` + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Substituted with the value stored in the referenced secret gpg-passphrase: MAVEN_GPG_PASSPHRASE # Env var that holds the key's passphrase @@ -45,12 +45,12 @@ jobs: key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - # Runs the Maven command to publish to the `ossrh` repository. - # The `OSSRH_USERNAME` environment variable will be set with the contents of your `OSSRH_USERNAME` secret, - # and the `OSSRH_TOKEN` environment variable will be set with the contents of your `OSSRH_TOKEN` secret. + # Runs the Maven command to publish to the maven central repository. + # The `MAVEN_CENTRAL_USERNAME` environment variable will be set with the contents of your `MAVEN_CENTRAL_USERNAME` secret, + # and the `MAVEN_CENTRAL_TOKEN` environment variable will be set with the contents of your `MAVEN_CENTRAL_TOKEN` secret. - name: Publish package run: ./mvnw --batch-mode deploy -Pmaven-central-publishing env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} diff --git a/CHANGELOG.md b/CHANGELOG.md index cb09e062f..cd0900552 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deleted +## [2.0.0] - 2024-12-10 + +### Changed + +- First official release of creedengo-rules-specifications component (renaming ECxx rule ids to GCIxx rule ids, refactoring) + ## [1.6.5] - 2024-10-18 ### Changed diff --git a/CODE_STYLE.md b/CODE_STYLE.md index 86b0ab3f8..c46ab38c6 100644 --- a/CODE_STYLE.md +++ b/CODE_STYLE.md @@ -1 +1 @@ -Please read common [CODE_STYLE.md](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/CODE_STYLE.md) in `ecoCode-common` repository. +Please read common [CODE_STYLE.md](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/CODE_STYLE.md) in `creedengo-common` repository. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77e81dc64..aeeae9161 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -Please read common [CONTRIBUTING.md](https://github.com/green-code-initiative/ecoCode-common/blob/main/doc/CONTRIBUTING.md) in `ecoCode-common` repository. +Please read common [CONTRIBUTING.md](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/CONTRIBUTING.md) in `creedengo-common` repository. diff --git a/INSTALL.md b/INSTALL.md index 551d8b588..d43635191 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,21 +6,6 @@ ## Common installation notes / requirements -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 +Please read common [HOWTO.md](https://github.com/green-code-initiative/creedengo-common/blob/main/doc/HOWTO.md) +in `creedengo-common` repository. Please follow the specific guides below for additional information on installing the desired plugins. - -## Special points for Standard plugins - -### Project structure - -Here is a preview of project tree : - -```txt -ecoCode # Root directory -| -+--ecocode-rules-specifications # rules specifications - -``` - -You will find more information about the plugins’ architecture in their folders diff --git a/README.md b/README.md index fb83c9b3b..6cbff6321 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ ![Logo](docs/resources/logo-large.png) ====================================== -_ecoCode_ is a collective project aiming to reduce environmental footprint of software at the code level. The goal of +_creedengo_ is a collective project aiming to reduce environmental footprint of software at the code level. The goal of the project is to provide a list of static code analyzers to highlight code structures that may have a negative ecological impact: energy and resources over-consumption, "fatware", shortening terminals' lifespan, etc. -_ecoCode_ is based on evolving catalogs of [good practices](docs/rules), for various technologies. A SonarQube plugin +_creedengo_ is based on evolving catalogs of [good practices](docs/rules), for various technologies. A SonarQube plugin then implements these catalogs as rules for scanning your projects. **Warning**: this is still a very early stage project. Any feedback or contribution will be highly appreciated. Please @@ -53,15 +53,62 @@ For example, you’ll be able to access of all your `for` loop, to explore conte To better understand AST structure, you can use the [AST Explorer](https://astexplorer.net/). +### ecoCode rules specification repository + +This project contains the specifications of all ecoCode rules, for all languages. + +#### Structure + +Rules are organized by folder based on their ID in the [root rules folder](../src/main/rules). +Each of these folders contains a file with the metadata of the rule, and description by language. + +The metadata file uses the format supported by +the [SonarSource Analyzers Commons](https://github.com/SonarSource/sonar-analyzer-commons/tree/master/commons) library. +To find out what values can be put there, we advise you to use the +official [SonarQube documentation](https://docs.sonarsource.com/sonarqube/latest/user-guide/rules/overview/), and to +rely on already existing files. + +Here is an example: + +```text +src/main/rules +├── EC104 +│ ├── java +│ │ ├── EC104.asciidoc +│ │ ├── EC104.json +│ ├── php +│ │ ├── EC104.asciidoc +│ ├── python +│ │ ├── EC104.asciidoc +│ └── EC104.json +├── ... +``` + +To specify metadata for a given language (for example deprecate a rule only for a single language), it is possible to +create a json file in the language folder, and this will be merged with the common file during build. The keys in the +specific file have priority and it is possible to add new ones but not to delete them from the global one. + +#### Description language + +The description of the rules uses the ASCIIDOC format ( +with [Markdown compatibility](https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#markdown-compatibility)) +in order to allow the inclusion of other pages (this feature is not available in standard with Markdown). + +See: + +* [AsciiDoc Syntax Quick Reference](https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/) +* [Compare AsciiDoc to Markdown](https://docs.asciidoctor.org/asciidoc/latest/asciidoc-vs-markdown/) + + 🚀 Getting Started ------------------ You can quickly have a look of ecoCode plugins with docker. Plase have a look at "Getting started" section of each plugin : -- [Java plugin](https://github.com/green-code-initiative/ecoCode-java?tab=readme-ov-file#-getting-started) -- [PHP plugin](https://github.com/green-code-initiative/ecoCode-php?tab=readme-ov-file#-getting-started) -- [Python plugin](https://github.com/green-code-initiative/ecoCode-python?tab=readme-ov-file#-getting-started) -- [C# plugin](https://github.com/green-code-initiative/ecoCode-csharp?tab=readme-ov-file#-getting-started) +- [Java plugin](https://github.com/green-code-initiative/creedengo-java?tab=readme-ov-file#-getting-started) +- [PHP plugin](https://github.com/green-code-initiative/creedengo-php?tab=readme-ov-file#-getting-started) +- [Python plugin](https://github.com/green-code-initiative/creedengo-python?tab=readme-ov-file#-getting-started) +- [C# plugin](https://github.com/green-code-initiative/creedengo-csharp?tab=readme-ov-file#-getting-started) 🛒 Distribution ------------------ diff --git a/ecocode-rules-specifications/README.md b/ecocode-rules-specifications/README.md deleted file mode 100644 index b93d93d74..000000000 --- a/ecocode-rules-specifications/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# ecoCode rules specification repository - -This project contains the specifications of all ecoCode rules, for all languages. - -## Structure - -Rules are organized by folder based on their ID in the [root rules folder](src/main/rules). -Each of these folders contains a file with the metadata of the rule, and description by language. - -The metadata file uses the format supported by -the [SonarSource Analyzers Commons](https://github.com/SonarSource/sonar-analyzer-commons/tree/master/commons) library. -To find out what values can be put there, we advise you to use the -official [SonarQube documentation](https://docs.sonarsource.com/sonarqube/latest/user-guide/rules/overview/), and to -rely on already existing files. - -Here is an example: - -```text -src/main/rules -├── EC104 -│ ├── java -│ │ ├── EC104.asciidoc -│ │ ├── EC104.json -│ ├── php -│ │ ├── EC104.asciidoc -│ ├── python -│ │ ├── EC104.asciidoc -│ └── EC104.json -├── ... -``` - -To specify metadata for a given language (for example deprecate a rule only for a single language), it is possible to -create a json file in the language folder, and this will be merged with the common file during build. The keys in the -specific file have priority and it is possible to add new ones but not to delete them from the global one. - -## Description language - -The description of the rules uses the ASCIIDOC format ( -with [Markdown compatibility](https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/#markdown-compatibility)) -in order to allow the inclusion of other pages (this feature is not available in standard with Markdown). - -See: - -* [AsciiDoc Syntax Quick Reference](https://docs.asciidoctor.org/asciidoc/latest/syntax-quick-reference/) -* [Compare AsciiDoc to Markdown](https://docs.asciidoctor.org/asciidoc/latest/asciidoc-vs-markdown/) diff --git a/ecocode-rules-specifications/pom.xml b/ecocode-rules-specifications/pom.xml deleted file mode 100644 index 5cd19de83..000000000 --- a/ecocode-rules-specifications/pom.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - 4.0.0 - - - io.ecocode - ecocode-parent - ${revision} - ../pom.xml - - - ecocode-rules-specifications - - ecoCode Rules Specifications repository - Repository that contains the specifications of every static-analysis rules available in ecoCode plugins. - https://github.com/green-code-initiative/ecoCode/tree/main/ecocode-rules-specifications - - - - - org.asciidoctor - asciidoctor-maven-plugin - - - convert-to-html - generate-resources - - process-asciidoc - - - ${project.basedir}/src/main/rules - ${project.build.directory}/rules-html - - coderay - style - - true - true - false - true - - - ERROR - - - - - - - - com.github.johnpoth - jshell-maven-plugin - - - prepare-rules-resources - generate-resources - - run - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - assembly-java - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/java.xml - - - - - assembly-php - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/php.xml - - - - - assembly-python - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/python.xml - - - - - assembly-javascript - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/javascript.xml - - - - - assembly-swift - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/swift.xml - - - - - assembly-xml - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/xml.xml - - - - - assembly-csharp - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/csharp.xml - - - - - assembly-html - prepare-package - - single - - - - ${project.basedir}/src/main/assembly/html.xml - - - - - - true - - - - - diff --git a/pom.xml b/pom.xml index a5ad5cafb..fb02e2cd6 100644 --- a/pom.xml +++ b/pom.xml @@ -2,15 +2,15 @@ 4.0.0 - io.ecocode - ecocode-parent + org.green-code-initiative + creedengo-rules-specifications ${revision} - pom - ecoCode Sonar Plugins Project - Provides rules to reduce the environmental footprint of your programs - https://github.com/green-code-initiative/ecocode - 2023 + creedengo Rules Specifications repository + Repository that contains the specifications of every static-analysis rules available in creedengo plugins. + https://github.com/green-code-initiative/creedengo-rules-specifications + + 2024 green-code-initiative https://github.com/green-code-initiative @@ -24,24 +24,20 @@ - - Gilles Grousset + Gilles GROUSSET zippy1978@users.noreply.github.com green-code-initiative https://github.com/green-code-initiative - Maxime Malgorn + Maxime MALGORN utarwyn@users.noreply.github.com green-code-initiative https://github.com/green-code-initiative - Geoffrey Lalloué + Geoffrey LALLOUÉ glalloue@users.noreply.github.com green-code-initiative https://github.com/green-code-initiative @@ -53,44 +49,40 @@ https://github.com/green-code-initiative - Olivier Le Goaër + Olivier LE GOAËR olegoaer@users.noreply.github.com green-code-initiative https://github.com/green-code-initiative - Julien Hertout + Julien HERTOUT jhertout@users.noreply.github.com green-code-initiative https://github.com/green-code-initiative - Jules Delecour + Jules DELECOUR jules-delecour-dav@users.noreply.github.com green-code-initiative https://github.com/green-code-initiative - DUBOIS Maxime + Maxime DUBOIS mdubois81@users.noreply.github.com green-code-initiative https://github.com/green-code-initiative - - ecocode-rules-specifications - - - 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 + scm:git:https://github.com/green-code-initiative/creedengo-rules-specifications + scm:git:https://github.com/green-code-initiative/creedengo-rules-specifications + https://github.com/green-code-initiative/creedengo-rules-specifications HEAD GitHub - https://github.com/green-code-initiative/ecocode/issues + https://github.com/green-code-initiative/creedengo-rules-specifications/issues @@ -112,65 +104,17 @@ ${encoding} ${encoding} + green-code-initiative + https://sonarcloud.io + - - - - me.qoomon - maven-git-versioning-extension - 9.8.1 - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.5.0 - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.7.0 - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.7 - - - org.apache.maven.plugins - maven-assembly-plugin - 3.7.1 - - - com.github.johnpoth - jshell-maven-plugin - 1.4 - - - jakarta.json - jakarta.json-api - 2.1.3 - - - org.glassfish - jakarta.json - 2.0.1 - module - - - - - org.asciidoctor - asciidoctor-maven-plugin - 3.0.0 - - - org.apache.maven.plugins maven-enforcer-plugin + 3.5.0 enforce-maven @@ -188,36 +132,201 @@ - + org.asciidoctor + asciidoctor-maven-plugin + 3.1.1 - validate + convert-to-html + generate-resources - check + process-asciidoc - validate + + ../src/main/rules + ${project.build.directory}/rules-html + + coderay + style + + true + true + false + true + + + ERROR + + + - --> + + + com.github.johnpoth + jshell-maven-plugin + 1.4 + + + jakarta.json + jakarta.json-api + 2.1.3 + + + org.glassfish + jakarta.json + 2.0.1 + module + + + + + prepare-rules-resources + generate-resources + + run + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.7.1 + + + assembly-java + prepare-package + + single + + + + ../src/main/assembly/java.xml + + + + + assembly-php + prepare-package + + single + + + + ../src/main/assembly/php.xml + + + + + assembly-python + prepare-package + + single + + + + ../src/main/assembly/python.xml + + + + + assembly-javascript + prepare-package + + single + + + + ../src/main/assembly/javascript.xml + + + + + assembly-swift + prepare-package + + single + + + + ../src/main/assembly/swift.xml + + + + + assembly-xml + prepare-package + + single + + + + ../src/main/assembly/xml.xml + + + + + assembly-csharp + prepare-package + + single + + + + ../src/main/assembly/csharp.xml + + + + + assembly-html + prepare-package + + single + + + + ../src/main/assembly/html.xml + + + + + + true + + @@ -231,31 +340,41 @@ - https://central.sonatype.org/publish/release/#login-into-ossrh --> - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - - org.sonatype.plugins - nexus-staging-maven-plugin - true + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + verify + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.11.2 + + + attach-javadoc + + jar + + + - ossrh - https://s01.oss.sonatype.org/ - - true + java + none - -``` +---- -## Compliant Solution +== Compliant Solution -```xml +[source,xml] +---- -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC11/EC11.json b/src/main/rules/GCI11/GCI11.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC11/EC11.json rename to src/main/rules/GCI11/GCI11.json diff --git a/ecocode-rules-specifications/src/main/rules/EC11/javascript/EC11.asciidoc b/src/main/rules/GCI11/javascript/GCI11.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC11/javascript/EC11.asciidoc rename to src/main/rules/GCI11/javascript/GCI11.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC12/EC12.json b/src/main/rules/GCI12/GCI12.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC12/EC12.json rename to src/main/rules/GCI12/GCI12.json diff --git a/ecocode-rules-specifications/src/main/rules/EC12/javascript/EC12.asciidoc b/src/main/rules/GCI12/javascript/GCI12.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC12/javascript/EC12.asciidoc rename to src/main/rules/GCI12/javascript/GCI12.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC13/EC13.json b/src/main/rules/GCI13/GCI13.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC13/EC13.json rename to src/main/rules/GCI13/GCI13.json diff --git a/ecocode-rules-specifications/src/main/rules/EC13/javascript/EC13.asciidoc b/src/main/rules/GCI13/javascript/GCI13.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC13/javascript/EC13.asciidoc rename to src/main/rules/GCI13/javascript/GCI13.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC2/EC2.json b/src/main/rules/GCI2/GCI2.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC2/EC2.json rename to src/main/rules/GCI2/GCI2.json diff --git a/ecocode-rules-specifications/src/main/rules/EC2/java/EC2.asciidoc b/src/main/rules/GCI2/java/GCI2.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC2/java/EC2.asciidoc rename to src/main/rules/GCI2/java/GCI2.asciidoc index df00a5933..bd874ef5b 100644 --- a/ecocode-rules-specifications/src/main/rules/EC2/java/EC2.asciidoc +++ b/src/main/rules/GCI2/java/GCI2.asciidoc @@ -3,7 +3,7 @@ We can think of using a switch statement instead of multiple if-else if possible to reduce number of IF, ELSEIF and ELSE statements. Sometimes called "complexity cyclomatic". Switch statement has a performance advantage over if – else. -## Functional rules +== Functional rules - one variable must be used maximum twice in IF / ELSEIF / ELSE statements at the same level - WARNINGs : - IF and ELSEIF statements use explicitly variable names ! - ELSE statements use implicity variable names ! @@ -12,13 +12,14 @@ Switch statement has a performance advantage over if – else. - use a SWITCH statement instead - or refactor the code if possible -## Non-compliant Code Example +== Non compliant Code Example NON compliant, because `nb` is used 4 times : - 2 explicit times in IF statements - 2 implicit times in ELSE statements -```java +[source,java] +---- int index = 1; int nb = 2; ... @@ -32,13 +33,14 @@ if (nb == 0) { nb = -1; } return nb; -``` +---- -## Compliant Code Example +== Compliant Code Example SWITCH statement solution + refactor solution -```java +[source,java] +---- int index = 1; int nb = 2; ... @@ -52,4 +54,4 @@ switch (nb) { nb = -1; } return nb; -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC2/php/EC2.asciidoc b/src/main/rules/GCI2/php/GCI2.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC2/php/EC2.asciidoc rename to src/main/rules/GCI2/php/GCI2.asciidoc index eae2c2817..56ab360c8 100644 --- a/ecocode-rules-specifications/src/main/rules/EC2/php/EC2.asciidoc +++ b/src/main/rules/GCI2/php/GCI2.asciidoc @@ -3,7 +3,7 @@ We can think of using a switch statement instead of multiple if-else if possible to reduce number of IF, ELSEIF and ELSE statements. Sometimes called "complexity cyclomatic". Switch statement has a performance advantage over if – else. -## Functional rules +== Functional rules - one variable must be used maximum twice in IF / ELSEIF / ELSE statements at the same level - WARNINGs : - IF and ELSEIF statements use explicitly variable names ! - ELSE statements use implicity variable names ! @@ -12,13 +12,14 @@ Switch statement has a performance advantage over if – else. - use a SWITCH statement instead - or refactor the code if possible -## Non-compliant Code Example +== Non compliant Code Example NON compliant, because `$nb` is used 4 times : - 2 explicit times in IF statements - 2 implicit times in ELSE statements -```php +[source,php] +---- $index = 1; $nb = 2; ... @@ -32,13 +33,14 @@ if ($nb == 0) { $nb = -1; } return $nb; -``` +---- -## Compliant Code Example +== Compliant Code Example SWITCH statement solution + refactor solution -```php +[source,php] +---- $index = 1; $nb = 2; ... @@ -52,4 +54,4 @@ switch ($nb) { $nb = -1; } return $nb; -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC2/python/EC2.asciidoc b/src/main/rules/GCI2/python/GCI2.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC2/python/EC2.asciidoc rename to src/main/rules/GCI2/python/GCI2.asciidoc index e2688d834..81cd9fa32 100644 --- a/ecocode-rules-specifications/src/main/rules/EC2/python/EC2.asciidoc +++ b/src/main/rules/GCI2/python/GCI2.asciidoc @@ -3,7 +3,7 @@ We can think of using a switch statement instead of multiple if-else if possible to reduce number of IF, ELSEIF and ELSE statements. Sometimes called "complexity cyclomatic". MATCH-CASE statement has a performance advantage over if – else. -## Functional rules +== Functional rules - one variable must be used maximum twice in IF / ELSEIF / ELSE statements at the same level - WARNINGs : - IF and ELSEIF statements use explicitly variable names ! - ELSE statements use implicity variable names ! @@ -12,13 +12,14 @@ MATCH-CASE statement has a performance advantage over if – else. - use a MATCH-CASE statement instead - or refactor the code if possible -## Non-compliant Code Example +== Non compliant Code Example Non-compliant, because `nb` is used 4 times : - 2 explicit times in IF statements - 2 implicit times in ELSE statements -```python +[source,python] +---- index = 1 nb = 2 ... @@ -31,13 +32,14 @@ elif nb == 2: else: nb = -1 return nb -``` +---- -## Compliant Code Example +== Compliant Code Example MATCH-CASE statement solution + refactor solution -```python +[source,python] +---- index = 1 nb = 2 ... @@ -51,4 +53,4 @@ match nb: case _: nb = -1 return nb -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC203/EC203.json b/src/main/rules/GCI203/GCI203.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC203/EC203.json rename to src/main/rules/GCI203/GCI203.json diff --git a/ecocode-rules-specifications/src/main/rules/EC203/python/EC203.asciidoc b/src/main/rules/GCI203/python/GCI203.asciidoc similarity index 82% rename from ecocode-rules-specifications/src/main/rules/EC203/python/EC203.asciidoc rename to src/main/rules/GCI203/python/GCI203.asciidoc index 85d38acb6..8c7f1f1fd 100644 --- a/ecocode-rules-specifications/src/main/rules/EC203/python/EC203.asciidoc +++ b/src/main/rules/GCI203/python/GCI203.asciidoc @@ -15,64 +15,71 @@ Some advantages of using SVG: - SVGs can be embedded into the HTML which means they can be cached, edited directly using CSS and indexed for greater accessibility. - SVGs can be animated directly or by using CSS or JavaScript making it easy for web designers to add interactivity to a site. -## Noncompliant Code Example +== Non compliant Code Example -``` +[source,python] +---- img_jpg = "image.jpg" -``` +---- -## Compliant Solution +== Compliant Solution -``` +[source,python] +---- img_svg = "image.svg" -``` +---- -## Noncompliant Code Example +== Non compliant Code Example -``` +[source,python] +---- public void foo() { // ... image_format = testImage("image.jpg") // ... } -``` +---- -## Compliant Solution +== Compliant Solution -``` +[source,python] +---- public void foo() { // ... image_format = testImage("image.svg") // ... } -``` +---- -## Noncompliant Code Example +== Non compliant Code Example -``` +[source,python] +---- public void foo() { // ... return '' // ... } -``` +---- -## Compliant Solution +== Compliant Solution -``` +[source,python] +---- public void foo() { // ... return '' // ... } -``` +---- Or -``` +[source,python] +---- public void foo() { // ... return ('') // ... } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC22/EC22.json b/src/main/rules/GCI22/GCI22.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC22/EC22.json rename to src/main/rules/GCI22/GCI22.json diff --git a/ecocode-rules-specifications/src/main/rules/EC22/php/EC22.asciidoc b/src/main/rules/GCI22/php/GCI22.asciidoc similarity index 51% rename from ecocode-rules-specifications/src/main/rules/EC22/php/EC22.asciidoc rename to src/main/rules/GCI22/php/GCI22.asciidoc index c42338993..b3f586708 100644 --- a/ecocode-rules-specifications/src/main/rules/EC22/php/EC22.asciidoc +++ b/src/main/rules/GCI22/php/GCI22.asciidoc @@ -1,13 +1,15 @@ Use of methods for basic operations -## Noncompliant Code Example +== Non compliant Code Example -```php +[source,php] +---- $min = min($a, $b); // Noncompliant -``` +---- -## Compliant Solution +== Compliant Solution -```php +[source,php] +---- $min = $a < $b ? $a : $b; -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC22/php/EC22.json b/src/main/rules/GCI22/php/GCI22.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC22/php/EC22.json rename to src/main/rules/GCI22/php/GCI22.json diff --git a/ecocode-rules-specifications/src/main/rules/EC24/EC24.json b/src/main/rules/GCI24/GCI24.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC24/EC24.json rename to src/main/rules/GCI24/GCI24.json diff --git a/ecocode-rules-specifications/src/main/rules/EC24/java/EC24.asciidoc b/src/main/rules/GCI24/java/GCI24.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC24/java/EC24.asciidoc rename to src/main/rules/GCI24/java/GCI24.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC24/javascript/EC24.asciidoc b/src/main/rules/GCI24/javascript/GCI24.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC24/javascript/EC24.asciidoc rename to src/main/rules/GCI24/javascript/GCI24.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC25/EC25.json b/src/main/rules/GCI25/GCI25.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC25/EC25.json rename to src/main/rules/GCI25/GCI25.json diff --git a/ecocode-rules-specifications/src/main/rules/EC25/javascript/EC25.asciidoc b/src/main/rules/GCI25/javascript/GCI25.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC25/javascript/EC25.asciidoc rename to src/main/rules/GCI25/javascript/GCI25.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC26/EC26.json b/src/main/rules/GCI26/GCI26.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC26/EC26.json rename to src/main/rules/GCI26/GCI26.json diff --git a/ecocode-rules-specifications/src/main/rules/EC26/javascript/EC26.asciidoc b/src/main/rules/GCI26/javascript/GCI26.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC26/javascript/EC26.asciidoc rename to src/main/rules/GCI26/javascript/GCI26.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC27/EC27.json b/src/main/rules/GCI27/GCI27.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC27/EC27.json rename to src/main/rules/GCI27/GCI27.json diff --git a/ecocode-rules-specifications/src/main/rules/EC27/java/EC27.asciidoc b/src/main/rules/GCI27/java/GCI27.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC27/java/EC27.asciidoc rename to src/main/rules/GCI27/java/GCI27.asciidoc index 455e0a137..416f29076 100644 --- a/ecocode-rules-specifications/src/main/rules/EC27/java/EC27.asciidoc +++ b/src/main/rules/GCI27/java/GCI27.asciidoc @@ -8,21 +8,23 @@ In the case of table copying (table), use the native `System.arraycopy`. We can also use `copyOf` or `clone` that are slightly less efficient. The looping method will be outlawed. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- int len = array.length; boolean[] copy = new boolean[array.length]; for (int i = 0; i < len; i++) { copy[i] = array[i]; // Noncompliant } return copy; -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- int[] copy = new int[array.length]; System.arraycopy(array, 0, copy, 0, array.length); return copy; -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC28/EC28.json b/src/main/rules/GCI28/GCI28.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC28/EC28.json rename to src/main/rules/GCI28/GCI28.json diff --git a/ecocode-rules-specifications/src/main/rules/EC28/java/EC28.asciidoc b/src/main/rules/GCI28/java/GCI28.asciidoc similarity index 84% rename from ecocode-rules-specifications/src/main/rules/EC28/java/EC28.asciidoc rename to src/main/rules/GCI28/java/GCI28.asciidoc index 841ee9f8c..b131e2284 100644 --- a/ecocode-rules-specifications/src/main/rules/EC28/java/EC28.asciidoc +++ b/src/main/rules/GCI28/java/GCI28.asciidoc @@ -1,8 +1,9 @@ Optimize read file exception -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- public void readPreferences(String filename) { //... InputStream in = null; @@ -14,11 +15,12 @@ public void readPreferences(String filename) { in.read(...); //... } -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- public void readPreferences(String filename) throws IllegalArgumentException, FileNotFoundException, IOException { if (filename == null) { throw new IllegalArgumentException ("filename is null"); @@ -27,4 +29,4 @@ public void readPreferences(String filename) throws IllegalArgumentException, Fi InputStream in = new FileInputStream(filename); //... } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC29/EC29.json b/src/main/rules/GCI29/GCI29.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC29/EC29.json rename to src/main/rules/GCI29/GCI29.json diff --git a/ecocode-rules-specifications/src/main/rules/EC29/javascript/EC29.asciidoc b/src/main/rules/GCI29/javascript/GCI29.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC29/javascript/EC29.asciidoc rename to src/main/rules/GCI29/javascript/GCI29.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC3/EC3.json b/src/main/rules/GCI3/GCI3.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC3/EC3.json rename to src/main/rules/GCI3/GCI3.json diff --git a/ecocode-rules-specifications/src/main/rules/EC3/java/EC3.asciidoc b/src/main/rules/GCI3/java/GCI3.asciidoc similarity index 82% rename from ecocode-rules-specifications/src/main/rules/EC3/java/EC3.asciidoc rename to src/main/rules/GCI3/java/GCI3.asciidoc index 49fcb223e..4789f1ac7 100644 --- a/ecocode-rules-specifications/src/main/rules/EC3/java/EC3.asciidoc +++ b/src/main/rules/GCI3/java/GCI3.asciidoc @@ -1,22 +1,24 @@ 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. The example provided below illustrates what should be avoided. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- List objList = getData(); for (int i = 0; i < objList.size(); i++) { // Noncompliant // execute code } -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- List objList = getData(); int size = objList.size(); for (int i = 0; i < size; i++) { // execute code } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC3/php/EC3.asciidoc b/src/main/rules/GCI3/php/GCI3.asciidoc similarity index 94% rename from ecocode-rules-specifications/src/main/rules/EC3/php/EC3.asciidoc rename to src/main/rules/GCI3/php/GCI3.asciidoc index 9c4d5bb81..489686e1b 100644 --- a/ecocode-rules-specifications/src/main/rules/EC3/php/EC3.asciidoc +++ b/src/main/rules/GCI3/php/GCI3.asciidoc @@ -2,9 +2,10 @@ When iterating over any collection, fetch the size of the collection in advance NB : note that we are using the `count()` method to get the size of an array but it would work the same with the `sizeof()` and `iterator_count()` methods. -## Noncompliant Code Example +== Non compliant Code Example -```php +[source,php] +---- $array = array('orange', 'banana', 'apple', 'carrot', 'collard', 'pea'); // FOR STATEMENTS / Right operand @@ -44,11 +45,12 @@ do { var_dump($array[$i]); ++$i; } while (count($array) > $i); -``` +---- -## Compliant Solution +== Compliant Solution -```php +[source,php] +---- $array = array('orange', 'banana', 'apple', 'carrot', 'collard', 'pea'); // FOR STATEMENTS / Right operand $size = sizeof($array); @@ -93,4 +95,4 @@ do { var_dump($array[$i]); ++$i; } while ($size > $i); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC30/EC30.json b/src/main/rules/GCI30/GCI30.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC30/EC30.json rename to src/main/rules/GCI30/GCI30.json diff --git a/ecocode-rules-specifications/src/main/rules/EC30/javascript/EC30.asciidoc b/src/main/rules/GCI30/javascript/GCI30.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC30/javascript/EC30.asciidoc rename to src/main/rules/GCI30/javascript/GCI30.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC31/EC31.json b/src/main/rules/GCI31/GCI31.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC31/EC31.json rename to src/main/rules/GCI31/GCI31.json diff --git a/ecocode-rules-specifications/src/main/rules/EC31/javascript/EC31.asciidoc b/src/main/rules/GCI31/javascript/GCI31.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC31/javascript/EC31.asciidoc rename to src/main/rules/GCI31/javascript/GCI31.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC32/EC32.json b/src/main/rules/GCI32/GCI32.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC32/EC32.json rename to src/main/rules/GCI32/GCI32.json diff --git a/ecocode-rules-specifications/src/main/rules/EC32/java/EC32.asciidoc b/src/main/rules/GCI32/java/GCI32.asciidoc similarity index 80% rename from ecocode-rules-specifications/src/main/rules/EC32/java/EC32.asciidoc rename to src/main/rules/GCI32/java/GCI32.asciidoc index 00c2ac907..655f96efb 100644 --- a/ecocode-rules-specifications/src/main/rules/EC32/java/EC32.asciidoc +++ b/src/main/rules/GCI32/java/GCI32.asciidoc @@ -2,20 +2,22 @@ If you know in advance how many characters would be appended, initialize builder They will thus never have to be resized. This saves CPU cycles and therefore consumes less energy. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- StringBuilder sb = new StringBuilder(); // Noncompliant for (int i = 0; i < 100; i++) { sb.append(...); } -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- StringBuilder sb = new StringBuilder(100); for (int i = 0; i < 100; i++) { sb.append(...); } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC34/EC34.json b/src/main/rules/GCI34/GCI34.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC34/EC34.json rename to src/main/rules/GCI34/GCI34.json diff --git a/ecocode-rules-specifications/src/main/rules/EC34/php/1GB.etsdiff.csv b/src/main/rules/GCI34/php/1GB.etsdiff.csv similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC34/php/1GB.etsdiff.csv rename to src/main/rules/GCI34/php/1GB.etsdiff.csv diff --git a/ecocode-rules-specifications/src/main/rules/EC34/php/EC34.asciidoc b/src/main/rules/GCI34/php/GCI34.asciidoc similarity index 89% rename from ecocode-rules-specifications/src/main/rules/EC34/php/EC34.asciidoc rename to src/main/rules/GCI34/php/GCI34.asciidoc index 47b8d2e36..3f1aec8af 100644 --- a/ecocode-rules-specifications/src/main/rules/EC34/php/EC34.asciidoc +++ b/src/main/rules/GCI34/php/GCI34.asciidoc @@ -2,9 +2,10 @@ Inside complex code parts (for exemple multiple loops, complex data construction 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 +== Non compliant Code Example -```php +[source,php] +---- try { $picture = PDF_open_image_file($PDF, "jpeg", $imgFile, "", 0); // This is the original statement, this works on PHP4 @@ -14,11 +15,12 @@ catch(Exception $ex) $msg = "Error opening $imgFile for Product $row['Identifier']"; throw new Exception($msg); } -``` +---- -## Compliant Solution +== Compliant Solution -```php +[source,php] +---- //try if (file_exists($imgFile)) { $picture = PDF_open_image_file($PDF, "jpeg", $imgFile, "", 0); @@ -29,11 +31,11 @@ if (!$picture) { $msg = "Error opening $imgFile for Product $row['Identifier']"; print $msg; } -``` +---- include::../../etsdiff-methodology.asciidoc[] -## Case for a 1GB database: +== Case for a 1GB database: image::https://live.staticflickr.com/65535/52622382871_f19da08db4_o.png[ETSdiff percent comparison] diff --git a/ecocode-rules-specifications/src/main/rules/EC34/php/EC34.json b/src/main/rules/GCI34/php/GCI34.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC34/php/EC34.json rename to src/main/rules/GCI34/php/GCI34.json diff --git a/ecocode-rules-specifications/src/main/rules/EC35/EC35.json b/src/main/rules/GCI35/GCI35.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC35/EC35.json rename to src/main/rules/GCI35/GCI35.json diff --git a/ecocode-rules-specifications/src/main/rules/EC35/php/1GB.etsdiff.csv b/src/main/rules/GCI35/php/1GB.etsdiff.csv similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC35/php/1GB.etsdiff.csv rename to src/main/rules/GCI35/php/1GB.etsdiff.csv diff --git a/ecocode-rules-specifications/src/main/rules/EC35/php/EC35.asciidoc b/src/main/rules/GCI35/php/GCI35.asciidoc similarity index 89% rename from ecocode-rules-specifications/src/main/rules/EC35/php/EC35.asciidoc rename to src/main/rules/GCI35/php/GCI35.asciidoc index 60f1e8c0b..b9a2c6e35 100644 --- a/ecocode-rules-specifications/src/main/rules/EC35/php/EC35.asciidoc +++ b/src/main/rules/GCI35/php/GCI35.asciidoc @@ -3,9 +3,10 @@ For the moment, this rule only deals with "file open" use case in try...catch bl 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 +== Non compliant Code Example -```php +[source,php] +---- try { $picture = PDF_open_image_file($PDF, "jpeg", $imgFile, "", 0); // This is the original statement, this works on PHP4 @@ -15,11 +16,12 @@ catch(Exception $ex) $msg = "Error opening $imgFile for Product $row['Identifier']"; throw new Exception($msg); } -``` +---- -## Compliant Solution +== Compliant Solution -```php +[source,php] +---- //try if (file_exists($imgFile)) { $picture = PDF_open_image_file($PDF, "jpeg", $imgFile, "", 0); @@ -30,11 +32,11 @@ if (!$picture) { $msg = "Error opening $imgFile for Product $row['Identifier']"; print $msg; } -``` +---- include::../../etsdiff-methodology.asciidoc[] -## Case for a 1GB database: +== Case for a 1GB database: image::https://live.staticflickr.com/65535/52622382871_f19da08db4_o.png[ETSdiff percent comparison] diff --git a/ecocode-rules-specifications/src/main/rules/EC35/python/EC35.asciidoc b/src/main/rules/GCI35/python/GCI35.asciidoc similarity index 84% rename from ecocode-rules-specifications/src/main/rules/EC35/python/EC35.asciidoc rename to src/main/rules/GCI35/python/GCI35.asciidoc index 08fc1f95f..28647b8a1 100644 --- a/ecocode-rules-specifications/src/main/rules/EC35/python/EC35.asciidoc +++ b/src/main/rules/GCI35/python/GCI35.asciidoc @@ -3,9 +3,10 @@ For the moment, this rule only deals with "file open" use case in try...catch bl 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 +== Non compliant Code Example -```python +[source,python] +---- try: f = open(path) print(fh.read()) @@ -13,14 +14,15 @@ except: print('No such file '+path finally: f.close() -``` +---- -## Compliant Solution +== Compliant Solution -```python +[source,python] +---- if os.path.isfile(path): fh = open(path, 'r') print(fh.read()) fh.close -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC36/EC36.json b/src/main/rules/GCI36/GCI36.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC36/EC36.json rename to src/main/rules/GCI36/GCI36.json diff --git a/ecocode-rules-specifications/src/main/rules/EC36/html/EC36.asciidoc b/src/main/rules/GCI36/html/GCI36.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC36/html/EC36.asciidoc rename to src/main/rules/GCI36/html/GCI36.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC4/EC4.json b/src/main/rules/GCI4/GCI4.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC4/EC4.json rename to src/main/rules/GCI4/GCI4.json diff --git a/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc b/src/main/rules/GCI4/php/GCI4.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc rename to src/main/rules/GCI4/php/GCI4.asciidoc index 94021a9e6..94bfbd614 100644 --- a/ecocode-rules-specifications/src/main/rules/EC4/php/EC4.asciidoc +++ b/src/main/rules/GCI4/php/GCI4.asciidoc @@ -2,9 +2,10 @@ 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 +== Non compliant Code Example -```php +[source,php] +---- var aGlobal = new String('Hello'); function globalLength(){ @@ -13,11 +14,12 @@ function globalLength(){ } globalLength(); -``` +---- -## Compliant Solution +== Compliant Solution -```php +[source,php] +---- var aGlobal = new String('Hello'); function someVarLength(str){ @@ -26,4 +28,4 @@ function someVarLength(str){ } somVarLength(aGlobal); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc b/src/main/rules/GCI4/python/GCI4.asciidoc similarity index 82% rename from ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc rename to src/main/rules/GCI4/python/GCI4.asciidoc index b777840a9..d76ae8baa 100644 --- a/ecocode-rules-specifications/src/main/rules/EC4/python/EC4.asciidoc +++ b/src/main/rules/GCI4/python/GCI4.asciidoc @@ -1,19 +1,21 @@ When function calls global variables, a lot a CPU cycles is consumed. -## Noncompliant Code Example +== Non compliant Code Example -```python +[source,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 +== Compliant Solution -```python +[source,python] +---- global_var = 'foo'; def print_var_details(local_var) { print(len(local_var)); @@ -21,4 +23,4 @@ def print_var_details(local_var) { print('Var : ' + local_var) } print_length(global_var); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC404/EC404.json b/src/main/rules/GCI404/GCI404.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC404/EC404.json rename to src/main/rules/GCI404/GCI404.json diff --git a/ecocode-rules-specifications/src/main/rules/EC404/python/EC404.asciidoc b/src/main/rules/GCI404/python/GCI404.asciidoc similarity index 88% rename from ecocode-rules-specifications/src/main/rules/EC404/python/EC404.asciidoc rename to src/main/rules/GCI404/python/GCI404.asciidoc index 4a0738f9f..14ac668e4 100644 --- a/ecocode-rules-specifications/src/main/rules/EC404/python/EC404.asciidoc +++ b/src/main/rules/GCI404/python/GCI404.asciidoc @@ -4,17 +4,19 @@ Python generators resemble lazy lists from other programming languages: when ite For more details on list comprehensions vs generator comprehensions, see https://docs.python.org/3/howto/functional.html#generator-expressions-and-list-comprehensions[Python documentation]. -## Noncompliant Code Example +== Non compliant Code Example -```python +[source,python] +---- for var in [var2 for var2 in range(100)]: ... -``` +---- -## Compliant Solution +== Compliant Solution -```python +[source,python] +---- for var in (var2 for var2 in range(100)): ... -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC5/EC5.json b/src/main/rules/GCI5/GCI5.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC5/EC5.json rename to src/main/rules/GCI5/GCI5.json diff --git a/ecocode-rules-specifications/src/main/rules/EC5/java/EC5.asciidoc b/src/main/rules/GCI5/java/GCI5.asciidoc similarity index 87% rename from ecocode-rules-specifications/src/main/rules/EC5/java/EC5.asciidoc rename to src/main/rules/GCI5/java/GCI5.asciidoc index 229a3503d..a9be9fcc9 100644 --- a/ecocode-rules-specifications/src/main/rules/EC5/java/EC5.asciidoc +++ b/src/main/rules/GCI5/java/GCI5.asciidoc @@ -1,17 +1,19 @@ Use `PreparedStatement` instead of `Statement`, because SQL will only commit the query once, whereas if you used only one statement, it would commit the query every time and thus induce unnecessary calculations by the CPU and therefore superfluous energy consumption. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- public void select() { Statement statement = connection.createStatement(); statement.executeUpdate("INSERT INTO persons(id, name) VALUES(2, 'John DOE')"); // Noncompliant } -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- public void select() { PreparedStatement statement = connection.prepareStatement(INSERT INTO persons(id, name) VALUES(?, ?)); @@ -19,4 +21,4 @@ public void select() { statement.setString(2, "John DOE"); statement.executeQuery(); } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC500/EC500.json b/src/main/rules/GCI500/GCI500.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC500/EC500.json rename to src/main/rules/GCI500/GCI500.json diff --git a/ecocode-rules-specifications/src/main/rules/EC500/java/EC500.asciidoc b/src/main/rules/GCI500/java/GCI500.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC500/java/EC500.asciidoc rename to src/main/rules/GCI500/java/GCI500.asciidoc index 951822492..7e2052d20 100644 --- a/ecocode-rules-specifications/src/main/rules/EC500/java/EC500.asciidoc +++ b/src/main/rules/GCI500/java/GCI500.asciidoc @@ -4,22 +4,24 @@ Instead, `SensorManager#registerListener(SensorEventListener, Sensor, int, int m Once one of the events in the FIFO needs to be reported, all the events in the FIFO are reported sequentially. Setting `maxReportLatencyUs` to a positive value allows to reduce the number of interrupts the AP (Application Processor) receives, hence reducing power consumption, as the AP can switch to a lower power state while the sensor is capturing the data. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- SensorEventListener sensorEventListener; SensorManager sensorManager; Sensor sensor; sensorManager.registerListener(sensorEventListener, sensor, SensorManager.SENSOR_DELAY_NORMAL); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- SensorEventListener sensorEventListener; SensorManager sensorManager; Sensor sensor; sensorManager.registerListener(sensorEventListener, sensor, SensorManager.SENSOR_DELAY_NORMAL, 200000); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC501/EC501.json b/src/main/rules/GCI501/GCI501.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC501/EC501.json rename to src/main/rules/GCI501/GCI501.json diff --git a/ecocode-rules-specifications/src/main/rules/EC501/java/EC501.asciidoc b/src/main/rules/GCI501/java/GCI501.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC501/java/EC501.asciidoc rename to src/main/rules/GCI501/java/GCI501.asciidoc index 84062dbab..1f0a464fe 100644 --- a/ecocode-rules-specifications/src/main/rules/EC501/java/EC501.asciidoc +++ b/src/main/rules/GCI501/java/GCI501.asciidoc @@ -4,9 +4,10 @@ Compared to a custom Sync Adapter or the alarm manager, the Job Scheduler suppor The Android system can combine jobs so that battery consumption is reduced. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- void setAlarm(Context context) { AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, Alarm.class); @@ -16,11 +17,12 @@ void setAlarm(Context context) { Alarm alarm = new Alarm(); alarm.setAlarm(this); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- JobInfo info = new JobInfo.Builder(123, COMPONENT_NAME) .setRequiresCharging(true) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED) @@ -29,4 +31,4 @@ JobInfo info = new JobInfo.Builder(123, COMPONENT_NAME) .build(); JobScheduler scheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE); scheduler.schedule(info); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC502/EC502.json b/src/main/rules/GCI502/GCI502.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC502/EC502.json rename to src/main/rules/GCI502/GCI502.json diff --git a/ecocode-rules-specifications/src/main/rules/EC502/java/EC502.asciidoc b/src/main/rules/GCI502/java/GCI502.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC502/java/EC502.asciidoc rename to src/main/rules/GCI502/java/GCI502.asciidoc index c645aaf93..388849978 100644 --- a/ecocode-rules-specifications/src/main/rules/EC502/java/EC502.asciidoc +++ b/src/main/rules/GCI502/java/GCI502.asciidoc @@ -2,10 +2,11 @@ Opening and closing internet connection continuously is extremely battery-ineffi Also, this bad practice must be early prevented because it is the root of another evil that consists in polling data at regular intervals, instead of using push notifications to save a lot of battery power. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- for (int val : myArray) { URL.openConnection(); } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC503/EC503.json b/src/main/rules/GCI503/GCI503.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC503/EC503.json rename to src/main/rules/GCI503/GCI503.json diff --git a/ecocode-rules-specifications/src/main/rules/EC503/java/EC503.asciidoc b/src/main/rules/GCI503/java/GCI503.asciidoc similarity index 88% rename from ecocode-rules-specifications/src/main/rules/EC503/java/EC503.asciidoc rename to src/main/rules/GCI503/java/GCI503.asciidoc index 674011019..0407d70c7 100644 --- a/ecocode-rules-specifications/src/main/rules/EC503/java/EC503.asciidoc +++ b/src/main/rules/GCI503/java/GCI503.asciidoc @@ -2,19 +2,21 @@ Normally the Wi-Fi stack filters out packets not explicitly addressed to the dev Processing these extra packets can cause a noticeable battery drain and must be disabled when not needed with to a call to `WifiManager.MulticastLock.release()`. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiManager.MulticastLock lock = wifiManager.createMulticastLock("tag"); lock.acquire(); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiManager.MulticastLock lock = wifiManager.createMulticastLock("tag"); lock.acquire(); lock.release() -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC504/EC504.json b/src/main/rules/GCI504/GCI504.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC504/EC504.json rename to src/main/rules/GCI504/GCI504.json diff --git a/ecocode-rules-specifications/src/main/rules/EC504/java/EC504.asciidoc b/src/main/rules/GCI504/java/GCI504.asciidoc similarity index 75% rename from ecocode-rules-specifications/src/main/rules/EC504/java/EC504.asciidoc rename to src/main/rules/GCI504/java/GCI504.asciidoc index 80f67b532..f2730c290 100644 --- a/ecocode-rules-specifications/src/main/rules/EC504/java/EC504.asciidoc +++ b/src/main/rules/GCI504/java/GCI504.asciidoc @@ -1,17 +1,19 @@ Transmitting a file over a network infrastructure without compressing it consumes more energy than with compression. More precisely, energy efficiency is improved in case the data is compressed at least by 10%, transmitted and decompressed at the other network node. From the Android client side, it means making a post HTTP request using a `GZIPOutputStream` instead of the classical OutputStream, along with the `HttpURLConnection` object. -## Noncompliant Code Example +== Non compliant Code Example -```java -Url url = new Url("https://www.ecocode.io/"); +[source,java] +---- +Url url = new Url("https://www.green-code-initiative.io/"); HttpsUrlConnection con = (HttpsURLConnection) url.openConnection(); OutputStream stream = con.getOutputStream(); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java -Url url = new Url("https://www.ecocode.io/"); +[source,java] +---- +Url url = new Url("https://www.green-code-initiative.io/"); HttpsUrlConnection con = (HttpsURLConnection) url.openConnection(); OutputStream stream = new GZIPOutputStream(con.getOutputStream()); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC505/EC505.json b/src/main/rules/GCI505/GCI505.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC505/EC505.json rename to src/main/rules/GCI505/GCI505.json diff --git a/ecocode-rules-specifications/src/main/rules/EC505/java/EC505.asciidoc b/src/main/rules/GCI505/java/GCI505.asciidoc similarity index 88% rename from ecocode-rules-specifications/src/main/rules/EC505/java/EC505.asciidoc rename to src/main/rules/GCI505/java/GCI505.asciidoc index 8cb61fe1e..d7fe87a9a 100644 --- a/ecocode-rules-specifications/src/main/rules/EC505/java/EC505.asciidoc +++ b/src/main/rules/GCI505/java/GCI505.asciidoc @@ -2,8 +2,9 @@ To avoid draining the battery, an Android device that is left idle quickly falls Hence, keeping the screen on should be avoided, unless it is absolutely necessary. If so, developers typically use the `FLAG_KEEP_SCREEN_ON` in their activity. Another way to implement this is in their application's layout XML file, by using the `android:keepScreenOn` attribute. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- getWindow().addFlags(FLAG_KEEP_SCREEN_ON); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC505/swift/EC505.asciidoc b/src/main/rules/GCI505/swift/GCI505.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC505/swift/EC505.asciidoc rename to src/main/rules/GCI505/swift/GCI505.asciidoc index 17999dc22..dd1b579cf 100644 --- a/ecocode-rules-specifications/src/main/rules/EC505/swift/EC505.asciidoc +++ b/src/main/rules/GCI505/swift/GCI505.asciidoc @@ -3,9 +3,10 @@ To avoid draining the battery, an iOS device that is left idle quickly falls asl Hence, keeping the screen on should be avoided, unless it is absolutely necessary. If so, developers typically disable the idle timer with `UIApplication.shared.isIdleTimerDisabled = true`. -## Noncompliant Code Example +== Non compliant Code Example -```swift +[source,swift] +---- UIApplication.shared.isIdleTimerDisabled = true -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC505/xml/EC505.asciidoc b/src/main/rules/GCI505/xml/GCI505.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC505/xml/EC505.asciidoc rename to src/main/rules/GCI505/xml/GCI505.asciidoc index ddb1cf0c0..3d79d936e 100644 --- a/ecocode-rules-specifications/src/main/rules/EC505/xml/EC505.asciidoc +++ b/src/main/rules/GCI505/xml/GCI505.asciidoc @@ -1,23 +1,25 @@ -Score ecoCode: 2sur5 +Score creedengo: 2sur5 To avoid draining the battery, an Android device that is left idle quickly falls asleep. Hence, keeping the screen on should be avoided, unless it is absolutely necessary. If so, developers typically use the `FLAG_KEEP_SCREEN_ON` in their activity. Another way to implement this is in their application's layout XML file, by using the `android:keepScreenOn` attribute. -## Noncompliant Code Example +== Non compliant Code Example -```xml +[source,xml] +---- -``` +---- -## Compliant Code Example +== Compliant Code Example -```xml +[source,xml] +---- -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC506/EC506.json b/src/main/rules/GCI506/GCI506.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC506/EC506.json rename to src/main/rules/GCI506/GCI506.json diff --git a/ecocode-rules-specifications/src/main/rules/EC506/java/EC506.asciidoc b/src/main/rules/GCI506/java/GCI506.asciidoc similarity index 88% rename from ecocode-rules-specifications/src/main/rules/EC506/java/EC506.asciidoc rename to src/main/rules/GCI506/java/GCI506.asciidoc index b047c41cc..9764c6d57 100644 --- a/ecocode-rules-specifications/src/main/rules/EC506/java/EC506.asciidoc +++ b/src/main/rules/GCI506/java/GCI506.asciidoc @@ -2,8 +2,9 @@ To avoid draining the battery, an Android device that is left idle quickly falls Hence, keeping the screen on should be avoided, unless it is absolutely necessary. If so, developers typically use the `FLAG_KEEP_SCREEN_ON` in their activity. Another way to implement this is in their application's layout XML file, by using the `android:keepScreenOn` attribute. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- getWindow().setFlags(FLAG_KEEP_SCREEN_ON, FLAG_KEEP_SCREEN_ON); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC507/EC507.json b/src/main/rules/GCI507/GCI507.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC507/EC507.json rename to src/main/rules/GCI507/GCI507.json diff --git a/ecocode-rules-specifications/src/main/rules/EC507/java/EC507.asciidoc b/src/main/rules/GCI507/java/GCI507.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC507/java/EC507.asciidoc rename to src/main/rules/GCI507/java/GCI507.asciidoc index a1a8362d5..9270a91fb 100644 --- a/ecocode-rules-specifications/src/main/rules/EC507/java/EC507.asciidoc +++ b/src/main/rules/GCI507/java/GCI507.asciidoc @@ -2,9 +2,10 @@ To avoid draining the battery, an Android device that is left idle quickly falls If so, developers typically use a Power Manager system service feature called wake locks by invoking `PowerManager.WakeLock#newWakeLock(int levelAndFlags, String tag)`, along with the specific permission `WAKE_LOCK` in their manifest. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLock manager = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TAG"); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC507/xml/EC507.asciidoc b/src/main/rules/GCI507/xml/GCI507.asciidoc similarity index 86% rename from ecocode-rules-specifications/src/main/rules/EC507/xml/EC507.asciidoc rename to src/main/rules/GCI507/xml/GCI507.asciidoc index b3b66f946..f16aa2d6c 100644 --- a/ecocode-rules-specifications/src/main/rules/EC507/xml/EC507.asciidoc +++ b/src/main/rules/GCI507/xml/GCI507.asciidoc @@ -1,4 +1,4 @@ -Score ecoCode: 2sur5 +Score creedengo: 2sur5 To avoid draining the battery, an Android device that is left idle quickly falls asleep. @@ -8,10 +8,11 @@ If so, developers typically use a Power Manager system service feature called wa by invoking `PowerManager.WakeLock#newWakeLock(int levelAndFlags, String tag)`, along with the specific permission `WAKE_LOCK` in their manifest. -## Noncompliant Code Example +== Non compliant Code Example -```xml +[source,xml] +---- -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC508/EC508.json b/src/main/rules/GCI508/GCI508.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC508/EC508.json rename to src/main/rules/GCI508/GCI508.json diff --git a/ecocode-rules-specifications/src/main/rules/EC508/java/EC508.asciidoc b/src/main/rules/GCI508/java/GCI508.asciidoc similarity index 87% rename from ecocode-rules-specifications/src/main/rules/EC508/java/EC508.asciidoc rename to src/main/rules/GCI508/java/GCI508.asciidoc index 98bf682f7..0e5e22cf5 100644 --- a/ecocode-rules-specifications/src/main/rules/EC508/java/EC508.asciidoc +++ b/src/main/rules/GCI508/java/GCI508.asciidoc @@ -4,14 +4,16 @@ Hence, the challenge here is to release the lock as soon as possible to avoid ru This can be avoided by a call to `PowerManager#acquire(long timeout)` instead of `PowerManager#acquire()`, because the lock will be released for sure after the given timeout expires. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- PowerManager.acquire() -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- PowerManager.acquire(long timeout) -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC509/EC509.json b/src/main/rules/GCI509/GCI509.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC509/EC509.json rename to src/main/rules/GCI509/GCI509.json diff --git a/ecocode-rules-specifications/src/main/rules/EC509/java/EC509.asciidoc b/src/main/rules/GCI509/java/GCI509.asciidoc similarity index 89% rename from ecocode-rules-specifications/src/main/rules/EC509/java/EC509.asciidoc rename to src/main/rules/GCI509/java/GCI509.asciidoc index a477697e7..2321aaf29 100644 --- a/ecocode-rules-specifications/src/main/rules/EC509/java/EC509.asciidoc +++ b/src/main/rules/GCI509/java/GCI509.asciidoc @@ -4,28 +4,36 @@ For most apps prior to API 19, `setInexactRepeating()` is preferable over `setRe Similarly after API 19, `setExact()` and `setExactAndAllowWhileIdle()` can significantly impact the power use of the device when idle, so they should be used with care. High-frequency alarms are also bad for battery life but this is already checked by Android lint (ShortAlarm built-in check). -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(alarmType, triggerAtMillis, intervalMillis, operation); -``` or -```java +---- +or +[source,java] +---- AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); alarmManager.setExact(type,triggerAtMillis,operation); -``` or -```java +---- +or +[source,java] +---- AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); alarmManager.setExact(type,triggerAtMillis,tag,listener,targetHandler); -``` or -```java +---- +or +[source,java] +---- AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); alarmManager.setExactAndAllowWhileIdle(type,triggerAtMilllis,operation); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); alarmManager.setInexactRepeating(alarmType, triggerAtMillis, intervalMillis, operation); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC509/swift/EC509.asciidoc b/src/main/rules/GCI509/swift/GCI509.asciidoc similarity index 86% rename from ecocode-rules-specifications/src/main/rules/EC509/swift/EC509.asciidoc rename to src/main/rules/GCI509/swift/GCI509.asciidoc index 3663db78d..77e2a9e2f 100644 --- a/ecocode-rules-specifications/src/main/rules/EC509/swift/EC509.asciidoc +++ b/src/main/rules/GCI509/swift/GCI509.asciidoc @@ -1,14 +1,16 @@ Setting a tolerance for timers will allow them to fire later than the scheduled fire date. The system will use this flexibility to shift the execution of timers by small amounts of time, within their tolerances, increasing the ability to optimize power savings. Your app can set the `Timer#tolerance` property to specify a tolerance for a timer. Using this approach dramatically increases the amount of time that the processor spends idling while users detect no change in system responsiveness. -## Noncompliant Code Example +== Non compliant Code Example -```swift +[source,swift] +---- let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in } -``` +---- -## Compliant Code Example +== Compliant Code Example -```swift +[source,swift] +---- let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in } timer.tolerance = 0.5 -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC510/EC510.json b/src/main/rules/GCI510/GCI510.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC510/EC510.json rename to src/main/rules/GCI510/GCI510.json diff --git a/ecocode-rules-specifications/src/main/rules/EC510/java/EC510.asciidoc b/src/main/rules/GCI510/java/GCI510.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC510/java/EC510.asciidoc rename to src/main/rules/GCI510/java/GCI510.asciidoc index 9d12df018..288722410 100644 --- a/ecocode-rules-specifications/src/main/rules/EC510/java/EC510.asciidoc +++ b/src/main/rules/GCI510/java/GCI510.asciidoc @@ -1,15 +1,17 @@ For developers wishing to display OpenGL rendering, when choosing the rendering mode with `GLSurfaceView#setRenderMode(int renderMode)`, using `RENDERMODE_WHEN_DIRTY` instead of `RENDERMODE_CONTINUOUSLY` (by default) can improve battery life and overall system performance by allowing the GPU and CPU to idle when the view does not need to be updated. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- GLSurfaceView surfaceView = new GLSurfaceView(this); surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY) -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- GLSurfaceView surfaceView = new GLSurfaceView(this); surfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY) -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC511/EC511.json b/src/main/rules/GCI511/GCI511.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC511/EC511.json rename to src/main/rules/GCI511/GCI511.json diff --git a/ecocode-rules-specifications/src/main/rules/EC511/java/EC511.asciidoc b/src/main/rules/GCI511/java/GCI511.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC511/java/EC511.asciidoc rename to src/main/rules/GCI511/java/GCI511.asciidoc index c911421da..af7dae9bd 100644 --- a/ecocode-rules-specifications/src/main/rules/EC511/java/EC511.asciidoc +++ b/src/main/rules/GCI511/java/GCI511.asciidoc @@ -2,22 +2,25 @@ During a voice interaction session, `VoiceInteractionSession#setKeepAwake(boolea By default, the system holds a wake lock for it while in this state, so that it can work even if the screen is off. Setting this to `false` removes that wake lock, allowing the CPU to go to sleep and hence does not let this continue to drain the battery. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- VoiceInteractionSession voiceSession = new VoiceInteractionSession(this); -``` +---- or -```java +[source,java] +---- VoiceInteractionSession voiceSession = new VoiceInteractionSession(this); voiceSession.setKeepAwake(true); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- VoiceInteractionSession voiceSession = new VoiceInteractionSession(this); voiceSession.setKeepAwake(false); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC512/EC512.json b/src/main/rules/GCI512/GCI512.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC512/EC512.json rename to src/main/rules/GCI512/GCI512.json diff --git a/ecocode-rules-specifications/src/main/rules/EC512/java/EC512.asciidoc b/src/main/rules/GCI512/java/GCI512.asciidoc similarity index 86% rename from ecocode-rules-specifications/src/main/rules/EC512/java/EC512.asciidoc rename to src/main/rules/GCI512/java/GCI512.asciidoc index 782c35274..15695507f 100644 --- a/ecocode-rules-specifications/src/main/rules/EC512/java/EC512.asciidoc +++ b/src/main/rules/GCI512/java/GCI512.asciidoc @@ -6,15 +6,17 @@ The common point of all these sensors is that they are expensive while in use. T Consequently, calls must be carefully pairwised: `Camera.open()/Camera.release()`. Failing to do so can drain the battery in just a few hours. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- Camera camera = Camera.open(); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- Camera camera = Camera.open(); camera.release(); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC513/EC513.json b/src/main/rules/GCI513/GCI513.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC513/EC513.json rename to src/main/rules/GCI513/GCI513.json diff --git a/ecocode-rules-specifications/src/main/rules/EC513/java/EC513.asciidoc b/src/main/rules/GCI513/java/GCI513.asciidoc similarity index 90% rename from ecocode-rules-specifications/src/main/rules/EC513/java/EC513.asciidoc rename to src/main/rules/GCI513/java/GCI513.asciidoc index cdc8b59a1..7f06765f0 100644 --- a/ecocode-rules-specifications/src/main/rules/EC513/java/EC513.asciidoc +++ b/src/main/rules/GCI513/java/GCI513.asciidoc @@ -7,17 +7,19 @@ The common point of all these sensors is that they are expensive while in use. T Failing to do so can drain the battery in just a few hours. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 1.0f, this); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 1.0f, this); locationManager.removeUpdates(this); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC513/swift/EC513.asciidoc b/src/main/rules/GCI513/swift/GCI513.asciidoc similarity index 98% rename from ecocode-rules-specifications/src/main/rules/EC513/swift/EC513.asciidoc rename to src/main/rules/GCI513/swift/GCI513.asciidoc index efcb0b784..dd25ac311 100644 --- a/ecocode-rules-specifications/src/main/rules/EC513/swift/EC513.asciidoc +++ b/src/main/rules/GCI513/swift/GCI513.asciidoc @@ -6,7 +6,7 @@ The common point of all these sensors is that they are power-intensive while in Consequently, calls must be carefully paired: `CLLocationManager.startUpdatingLocation()` and `CLLocationManager.stopUpdatingLocation()`. Failing to do so can drain the battery in just a few hours. -== Noncompliant Code Example +== Non compliant Code Example [source,swift] ---- diff --git a/ecocode-rules-specifications/src/main/rules/EC514/EC514.json b/src/main/rules/GCI514/GCI514.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC514/EC514.json rename to src/main/rules/GCI514/GCI514.json diff --git a/ecocode-rules-specifications/src/main/rules/EC514/java/EC514.asciidoc b/src/main/rules/GCI514/java/GCI514.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC514/java/EC514.asciidoc rename to src/main/rules/GCI514/java/GCI514.asciidoc index 2f06dd287..80d7be74a 100644 --- a/ecocode-rules-specifications/src/main/rules/EC514/java/EC514.asciidoc +++ b/src/main/rules/GCI514/java/GCI514.asciidoc @@ -6,19 +6,21 @@ The common point of all these sensors is that they are expensive while in use. T Consequently, calls must be carefully pairwised: `SensorManager#registerListener()/unregisterListener()`. Failing to do so can drain the battery in just a few hours. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- SensorManager sManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); sManager.registerListener(this,accelerometer,SensorManager.SENSOR_DELAY_NORMAL); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- SensorManager sManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); Sensor accelerometer = sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); sManager.registerListener(this,accelerometer,SensorManager.SENSOR_DELAY_NORMAL); sManager.unregisterListener(this); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC514/swift/EC514.asciidoc b/src/main/rules/GCI514/swift/GCI514.asciidoc similarity index 97% rename from ecocode-rules-specifications/src/main/rules/EC514/swift/EC514.asciidoc rename to src/main/rules/GCI514/swift/GCI514.asciidoc index 37eb6dcb4..676191a36 100644 --- a/ecocode-rules-specifications/src/main/rules/EC514/swift/EC514.asciidoc +++ b/src/main/rules/GCI514/swift/GCI514.asciidoc @@ -5,7 +5,7 @@ The common point of all these sensors is that they consume significant power whi Consequently, calls to start and stop sensor updates must be carefully managed for motion sensor: CMMotionManager#startAccelerometerUpdates()/CMMotionManager#stopAccelerometerUpdates(). Failing to do so can drain the battery quickly. -== Noncompliant Code Example +== Non compliant Code Example [source,swift] ---- diff --git a/ecocode-rules-specifications/src/main/rules/EC515/EC515.json b/src/main/rules/GCI515/GCI515.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC515/EC515.json rename to src/main/rules/GCI515/GCI515.json diff --git a/ecocode-rules-specifications/src/main/rules/EC515/java/EC515.asciidoc b/src/main/rules/GCI515/java/GCI515.asciidoc similarity index 82% rename from ecocode-rules-specifications/src/main/rules/EC515/java/EC515.asciidoc rename to src/main/rules/GCI515/java/GCI515.asciidoc index 2053d051b..ba08b5394 100644 --- a/ecocode-rules-specifications/src/main/rules/EC515/java/EC515.asciidoc +++ b/src/main/rules/GCI515/java/GCI515.asciidoc @@ -2,15 +2,17 @@ Creation of a Media Recorder object with `new MediaRecorder()` is used to record In addition to unnecessary resources (such as memory and instances of codecs) being held, failure to call this method immediately if a media object is no longer needed may also lead to continuous battery consumption for mobile devices. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- MediaRecorder mr = new MediaRecorder(); -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- MediaRecorder mr = new MediaRecorder(); mr.release(); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC515/swift/EC515.asciidoc b/src/main/rules/GCI515/swift/GCI515.asciidoc similarity index 98% rename from ecocode-rules-specifications/src/main/rules/EC515/swift/EC515.asciidoc rename to src/main/rules/GCI515/swift/GCI515.asciidoc index 3770fdedd..c99ca1e68 100644 --- a/ecocode-rules-specifications/src/main/rules/EC515/swift/EC515.asciidoc +++ b/src/main/rules/GCI515/swift/GCI515.asciidoc @@ -3,7 +3,7 @@ Creation of an `AVAudioRecorder` object is used to record audio. These class has In addition to unnecessary resources (such as memory and instances of codecs) being held, failure to properly stop and release these object if it is no longer needed may also lead to continuous battery consumption for mobile devices. -== Noncompliant Code Example +== Non compliant Code Example [source,swift] ---- diff --git a/ecocode-rules-specifications/src/main/rules/EC516/EC516.json b/src/main/rules/GCI516/GCI516.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC516/EC516.json rename to src/main/rules/GCI516/GCI516.json diff --git a/ecocode-rules-specifications/src/main/rules/EC516/java/EC516.asciidoc b/src/main/rules/GCI516/java/GCI516.asciidoc similarity index 82% rename from ecocode-rules-specifications/src/main/rules/EC516/java/EC516.asciidoc rename to src/main/rules/GCI516/java/GCI516.asciidoc index e59c5a2ed..c55e5be18 100644 --- a/ecocode-rules-specifications/src/main/rules/EC516/java/EC516.asciidoc +++ b/src/main/rules/GCI516/java/GCI516.asciidoc @@ -2,15 +2,17 @@ Creation of a Media Player object with `new MediaPlayer()` can be used to contro In addition to unnecessary resources (such as memory and instances of codecs) being held, failure to call this method immediately if a media object is no longer needed may also lead to continuous battery consumption for mobile devices. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- MediaPlayer mp = new MediaPlayer(); -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- MediaPlayer mp = new MediaPlayer(); mp.release(); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC517/EC517.json b/src/main/rules/GCI517/GCI517.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC517/EC517.json rename to src/main/rules/GCI517/GCI517.json diff --git a/ecocode-rules-specifications/src/main/rules/EC517/java/EC517.asciidoc b/src/main/rules/GCI517/java/GCI517.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC517/java/EC517.asciidoc rename to src/main/rules/GCI517/java/GCI517.asciidoc index 03a404866..c2864776b 100644 --- a/ecocode-rules-specifications/src/main/rules/EC517/java/EC517.asciidoc +++ b/src/main/rules/GCI517/java/GCI517.asciidoc @@ -2,14 +2,16 @@ The fused location provider is one of the location APIs in Google Play services Thus, developer has to set up Google Play Service in her gradle file with a dependency to `com.google.android.gms:play-services-location:x.y.z`, and then to import from `com.google.android.gms.location` instead of the `android.location` package of the SDK. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- import android.location.*; -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- import com.google.android.gms.location.*; -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC518/EC518.json b/src/main/rules/GCI518/GCI518.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC518/EC518.json rename to src/main/rules/GCI518/GCI518.json diff --git a/ecocode-rules-specifications/src/main/rules/EC518/java/EC518.asciidoc b/src/main/rules/GCI518/java/GCI518.asciidoc similarity index 82% rename from ecocode-rules-specifications/src/main/rules/EC518/java/EC518.asciidoc rename to src/main/rules/GCI518/java/GCI518.asciidoc index 805dd1e46..b9529c227 100644 --- a/ecocode-rules-specifications/src/main/rules/EC518/java/EC518.asciidoc +++ b/src/main/rules/GCI518/java/GCI518.asciidoc @@ -2,14 +2,16 @@ In contrast to classic Bluetooth, Bluetooth Low Energy (BLE) is designed to prov From the Android client side, it means append `android.bluetooth.le.\*` imports to `android.bluetooth.*` imports in order to benefits from low-energy features. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- import android.bluetooth.* -``` +---- -## Compliant Solution +== Compliant Solution -```java +[source,java] +---- import android.bluetooth.le.* -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC519/EC519.json b/src/main/rules/GCI519/GCI519.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC519/EC519.json rename to src/main/rules/GCI519/GCI519.json diff --git a/ecocode-rules-specifications/src/main/rules/EC519/java/EC519.asciidoc b/src/main/rules/GCI519/java/GCI519.asciidoc similarity index 84% rename from ecocode-rules-specifications/src/main/rules/EC519/java/EC519.asciidoc rename to src/main/rules/GCI519/java/GCI519.asciidoc index 1bdc27c6e..e85c11ed3 100644 --- a/ecocode-rules-specifications/src/main/rules/EC519/java/EC519.asciidoc +++ b/src/main/rules/GCI519/java/GCI519.asciidoc @@ -2,26 +2,30 @@ It's always good that an app has different behavior when device is connected/dis One can monitor the changes in charging state with a broadcast receiver registered on the actions `ACTION_POWER_CONNECTED` and `ACTION_POWER_DISCONNECTED`, or monitor significant changes in battery level with a broadcast receiver registered on the actions `BATTERY_LOW` and `BATTERY_OKAY`. -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- new IntentFilter(Intent.ACTION_POWER_CONNECTED) -``` +---- Or -```java +[source,java] +---- new IntentFilter(Intent.ACTION_POWER_DISCONNECTED) -``` +---- Or -```java +[source,java] +---- new IntentFilter(Intent.ACTION_POWER_BATTERY_OKAY) -``` +---- Or -```java +[source,java] +---- new IntentFilter(Intent.ACTION_POWER_BATTERY_LOW) -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC519/swift/EC519.asciidoc b/src/main/rules/GCI519/swift/GCI519.asciidoc similarity index 86% rename from ecocode-rules-specifications/src/main/rules/EC519/swift/EC519.asciidoc rename to src/main/rules/GCI519/swift/GCI519.asciidoc index 906ee3872..e524cf257 100644 --- a/ecocode-rules-specifications/src/main/rules/EC519/swift/EC519.asciidoc +++ b/src/main/rules/GCI519/swift/GCI519.asciidoc @@ -2,26 +2,30 @@ It's always good that an app has different behavior when device is connected/dis Your app can also register to receive notifications when the battery level or state changes, using `batteryLevelDidChangeNotification` and `batteryStateDidChangeNotification`. -## Compliant Code Example +== Compliant Code Example -```swift +[source,swift] +---- let level = UIDevice.current.batteryLevel -``` +---- or -```swift +[source,swift] +---- let state = UIDevice.current.batteryState -``` +---- or -```swift +[source,swift] +---- NotificationCenter.default.addObserver(forName: UIDevice.batteryLevelDidChangeNotification, object: nil, queue: nil) { _ in } -``` +---- or -```swift +[source,swift] +---- NotificationCenter.default.addObserver(forName: UIDevice.batteryStateDidChangeNotification, object: nil, queue: nil) { _ in } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC519/xml/EC519.asciidoc b/src/main/rules/GCI519/xml/GCI519.asciidoc similarity index 67% rename from ecocode-rules-specifications/src/main/rules/EC519/xml/EC519.asciidoc rename to src/main/rules/GCI519/xml/GCI519.asciidoc index 9d1ebf6cb..8c3a254bd 100644 --- a/ecocode-rules-specifications/src/main/rules/EC519/xml/EC519.asciidoc +++ b/src/main/rules/GCI519/xml/GCI519.asciidoc @@ -1,43 +1,47 @@ -Score ecoCode: 5sur5 +Score creedengo: 5sur5 It's always good that an app has different behavior when device is connected/disconnected to a power station, or has different battery levels. One can monitor the changes in charging state with a broadcast receiver registered on the actions `ACTION_POWER_CONNECTED` and `ACTION_POWER_DISCONNECTED`, or monitor significant changes in battery level with a broadcast receiver registered on the actions `BATTERY_LOW` and `BATTERY_OKAY`. -## Compliant Code Example +== Compliant Code Example -```xml - +[source,xml] +---- + -``` +---- or -```xml - +[source,xml] +---- + -``` +---- or -```xml - +[source,xml] +---- + -``` +---- or -```xml - +[source,xml] +---- + -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC520/EC520.json b/src/main/rules/GCI520/GCI520.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC520/EC520.json rename to src/main/rules/GCI520/GCI520.json diff --git a/ecocode-rules-specifications/src/main/rules/EC520/java/EC520.asciidoc b/src/main/rules/GCI520/java/GCI520.asciidoc similarity index 80% rename from ecocode-rules-specifications/src/main/rules/EC520/java/EC520.asciidoc rename to src/main/rules/GCI520/java/GCI520.asciidoc index d4e3c166c..d752363eb 100644 --- a/ecocode-rules-specifications/src/main/rules/EC520/java/EC520.asciidoc +++ b/src/main/rules/GCI520/java/GCI520.asciidoc @@ -2,26 +2,30 @@ Taking into account when the device is entering or exiting the power save mode i It implies the existence of a broadcast receiver registered on the action `ACTION_POWER_SAVE_MODE_CHANGED`, or programmaticaly with a call to `PowerManager#isPowerSaveMode().` -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- new IntentFilter(Intent.ACTION_POWER_SAVE_MODE_CHANGED) -``` +---- Or -```java +[source,java] +---- intentFilter.addAction(ACTION_POWER_SAVE_MODE_CHANGED) -``` +---- Or -```java +[source,java] +---- IntentFilter.create(ACTION_POWER_SAVE_MODE_CHANGED,"") -``` +---- Or -```java +[source,java] +---- powerManager.isPowerSaveMode() -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC520/swift/EC520.asciidoc b/src/main/rules/GCI520/swift/GCI520.asciidoc similarity index 88% rename from ecocode-rules-specifications/src/main/rules/EC520/swift/EC520.asciidoc rename to src/main/rules/GCI520/swift/GCI520.asciidoc index ba002a0e1..b37390306 100644 --- a/ecocode-rules-specifications/src/main/rules/EC520/swift/EC520.asciidoc +++ b/src/main/rules/GCI520/swift/GCI520.asciidoc @@ -4,20 +4,23 @@ For example, you can reduce frequency of data update if low power mode is enable Your app can query the `ProcessInfo.processInfo.isLowPowerModeEnabled` property at any time to determine whether Low Power Mode is active. Your app can also register to receive notifications when the Low Power Mode state of a device changes, using `NSProcessInfoPowerStateDidChange`. -## Compliant Code Example +== Compliant Code Example -```swift +[source,swift] +---- let isLowPowerModeEnabled = ProcessInfo.processInfo.isLowPowerModeEnabled -``` +---- or -```swift +[source,swift] +---- NotificationCenter.default.addObserver(forName: .NSProcessInfoPowerStateDidChange, object: nil, queue: nil) { _ in } -``` +---- or -```swift +[source,swift] +---- NotificationCenter.default.addObserver(forName: Notification.Name.NSProcessInfoPowerStateDidChange, object: nil, queue: nil) { _ in } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC520/xml/EC520.asciidoc b/src/main/rules/GCI520/xml/GCI520.asciidoc similarity index 73% rename from ecocode-rules-specifications/src/main/rules/EC520/xml/EC520.asciidoc rename to src/main/rules/GCI520/xml/GCI520.asciidoc index a342353a4..71df4aa4c 100644 --- a/ecocode-rules-specifications/src/main/rules/EC520/xml/EC520.asciidoc +++ b/src/main/rules/GCI520/xml/GCI520.asciidoc @@ -1,15 +1,16 @@ -Score ecoCode: 5sur5 +Score creedengo: 5sur5 Taking into account when the device is entering or exiting the power save mode is higly desirable for the battery life. It implies the existence of a broadcast receiver registered on the action `ACTION_POWER_SAVE_MODE_CHANGED`, or programmatically with a call to `PowerManager#isPowerSaveMode().` -## Compliant Code Example +== Compliant Code Example -```xml - +[source,xml] +---- + -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC521/EC521.json b/src/main/rules/GCI521/GCI521.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC521/EC521.json rename to src/main/rules/GCI521/GCI521.json diff --git a/ecocode-rules-specifications/src/main/rules/EC521/java/EC521.asciidoc b/src/main/rules/GCI521/java/GCI521.asciidoc similarity index 88% rename from ecocode-rules-specifications/src/main/rules/EC521/java/EC521.asciidoc rename to src/main/rules/GCI521/java/GCI521.asciidoc index 4d370f0a4..5d8f67dbd 100644 --- a/ecocode-rules-specifications/src/main/rules/EC521/java/EC521.asciidoc +++ b/src/main/rules/GCI521/java/GCI521.asciidoc @@ -1,15 +1,17 @@ The rotation vector sensor is the most frequently used sensor for motion detection and monitoring. When using `SensorManager#getDefaultSensor(int type)`, always prefer the constant `TYPE_GEOMAGNETIC_ROTATION_VECTOR` which is similar to `TYPE_ROTATION_VECTOR`, but using a magnetometer instead of using a gyroscope. This sensor uses lower power than the other rotation vectors, because it doesn't use the gyroscope. However, it is more noisy and will work best outdoors. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- SensorManager sManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- SensorManager sManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sManager.getDefaultSensor(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC522/EC522.json b/src/main/rules/GCI522/GCI522.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC522/EC522.json rename to src/main/rules/GCI522/GCI522.json diff --git a/ecocode-rules-specifications/src/main/rules/EC522/java/EC522.asciidoc b/src/main/rules/GCI522/java/GCI522.asciidoc similarity index 90% rename from ecocode-rules-specifications/src/main/rules/EC522/java/EC522.asciidoc rename to src/main/rules/GCI522/java/GCI522.asciidoc index a7286af84..eadc760ca 100644 --- a/ecocode-rules-specifications/src/main/rules/EC522/java/EC522.asciidoc +++ b/src/main/rules/GCI522/java/GCI522.asciidoc @@ -4,8 +4,9 @@ For some reasons, developers may disable this feature programmatically, setting This feature was introduced to improve battery life, be careful when deactivating it. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- getWindow().getAttributes().screenBrightness = BRIGHTNESS_OVERRIDE_FULL; -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC522/java/EC522.json b/src/main/rules/GCI522/java/GCI522.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC522/java/EC522.json rename to src/main/rules/GCI522/java/GCI522.json diff --git a/ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.asciidoc b/src/main/rules/GCI522/javascript/GCI522.asciidoc similarity index 99% rename from ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.asciidoc rename to src/main/rules/GCI522/javascript/GCI522.asciidoc index 94e8c6f5e..629d6cda7 100644 --- a/ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.asciidoc +++ b/src/main/rules/GCI522/javascript/GCI522.asciidoc @@ -12,7 +12,7 @@ Hence, keeping forcing the screen brightness on should be avoided, unless it is == Example of non compliant code -```js +----js // Example with expo-brightness (Expo framework library) import React, { useEffect } from 'react'; import { View, Text } from 'react-native'; diff --git a/ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.json b/src/main/rules/GCI522/javascript/GCI522.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC522/javascript/EC522.json rename to src/main/rules/GCI522/javascript/GCI522.json diff --git a/ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.asciidoc b/src/main/rules/GCI522/swift/GCI522.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.asciidoc rename to src/main/rules/GCI522/swift/GCI522.asciidoc index 16cee2bbc..91422195d 100644 --- a/ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.asciidoc +++ b/src/main/rules/GCI522/swift/GCI522.asciidoc @@ -2,9 +2,10 @@ To avoid draining the battery, an iOS device adapt its brightness to the environ Hence, keeping forcing the screen brightness on should be avoided, unless it is absolutely necessary. If so, developers typically force the Brightness to 1 with `UIScreen.main.brightness = a float`. -## Noncompliant Code Example +== Non compliant Code Example -```swift +[source,swift] +---- UIScreen.main.brightness = CGFloat(0.3) -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.json b/src/main/rules/GCI522/swift/GCI522.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC522/swift/EC522.json rename to src/main/rules/GCI522/swift/GCI522.json diff --git a/ecocode-rules-specifications/src/main/rules/EC523/EC523.json b/src/main/rules/GCI523/GCI523.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC523/EC523.json rename to src/main/rules/GCI523/GCI523.json diff --git a/ecocode-rules-specifications/src/main/rules/EC527/java/EC527.asciidoc b/src/main/rules/GCI523/java/GCI523.asciidoc similarity index 87% rename from ecocode-rules-specifications/src/main/rules/EC527/java/EC527.asciidoc rename to src/main/rules/GCI523/java/GCI523.asciidoc index 2fb54ab84..de19e643b 100644 --- a/ecocode-rules-specifications/src/main/rules/EC527/java/EC527.asciidoc +++ b/src/main/rules/GCI523/java/GCI523.asciidoc @@ -2,20 +2,22 @@ With a call to `LocationManager#requestLocationUpdates(String provider, long min These two must imperatively be greater than 0. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000L, // refresh location at least each 60000ms 10.0f, // refresh location at least each 10 meters this); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC523/java/EC523.json b/src/main/rules/GCI523/java/GCI523.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC523/java/EC523.json rename to src/main/rules/GCI523/java/GCI523.json diff --git a/ecocode-rules-specifications/src/main/rules/EC523/javascript/EC523.asciidoc b/src/main/rules/GCI523/javascript/GCI523.asciidoc similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC523/javascript/EC523.asciidoc rename to src/main/rules/GCI523/javascript/GCI523.asciidoc diff --git a/ecocode-rules-specifications/src/main/rules/EC523/javascript/EC523.json b/src/main/rules/GCI523/javascript/GCI523.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC523/javascript/EC523.json rename to src/main/rules/GCI523/javascript/GCI523.json diff --git a/ecocode-rules-specifications/src/main/rules/EC524/EC524.json b/src/main/rules/GCI524/GCI524.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC524/EC524.json rename to src/main/rules/GCI524/GCI524.json diff --git a/ecocode-rules-specifications/src/main/rules/EC524/java/EC524.asciidoc b/src/main/rules/GCI524/java/GCI524.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC524/java/EC524.asciidoc rename to src/main/rules/GCI524/java/GCI524.asciidoc index 356629524..1cff90f3c 100644 --- a/ecocode-rules-specifications/src/main/rules/EC524/java/EC524.asciidoc +++ b/src/main/rules/GCI524/java/GCI524.asciidoc @@ -2,22 +2,24 @@ Location awareness is one of the most popular features used by apps. An important point is to try to get the best possible provider (`LocationManager#getBestProvider()`) based on an energy criteria thanks to `Criteria#setPowerRequirement(int level)`, using constant `POWER_LOW` instead of `POWER_HIGH` or `POWER_MEDIUM`. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 1.0f, this); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- Criteria criteria = new Criteria(); criteria.setPowerRequirement(Criteria.POWER_LOW); locationManager.requestLocationUpdates(locationManager.getBestProvider(criteria,true), 1000L, 1.0f, this); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC524/swift/EC524.asciidoc b/src/main/rules/GCI524/swift/GCI524.asciidoc similarity index 94% rename from ecocode-rules-specifications/src/main/rules/EC524/swift/EC524.asciidoc rename to src/main/rules/GCI524/swift/GCI524.asciidoc index 75a998f71..6d754862a 100644 --- a/ecocode-rules-specifications/src/main/rules/EC524/swift/EC524.asciidoc +++ b/src/main/rules/GCI524/swift/GCI524.asciidoc @@ -6,10 +6,11 @@ Requesting higher accuracy than you need causes the system to power up additiona Also, setting the `CLLocationManager#activityType` property will let the system knows what type of location activity your app is performing and helps it determine the most appropriate time to perform location updates. Finally, if your app just needs a quick fix on the user’s location, it’s best to call the `CLLocationManager#requestLocation` method, that will deliver a single location update. -## Compliant Code Example +== Compliant Code Example -```swift +[source,swift] +---- let manager = CLLocationManager() manager.desiredAccuracy = 2 -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC525/EC525.json b/src/main/rules/GCI525/GCI525.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC525/EC525.json rename to src/main/rules/GCI525/GCI525.json diff --git a/ecocode-rules-specifications/src/main/rules/EC525/java/EC525.asciidoc b/src/main/rules/GCI525/java/GCI525.asciidoc similarity index 87% rename from ecocode-rules-specifications/src/main/rules/EC525/java/EC525.asciidoc rename to src/main/rules/GCI525/java/GCI525.asciidoc index a1e2af352..44fd03f3f 100644 --- a/ecocode-rules-specifications/src/main/rules/EC525/java/EC525.asciidoc +++ b/src/main/rules/GCI525/java/GCI525.asciidoc @@ -2,16 +2,18 @@ With Bluetooth Low Energy technology, a Bluetooth Smart Ready device (the master The default and preferred advertising mode is `ADVERTISE_MODE_LOW_POWER` when calling `AdvertiseSettings.Builder#setAdvertiseMode(int advertiseMode).` -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder(); builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder(); builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC526/EC526.json b/src/main/rules/GCI526/GCI526.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC526/EC526.json rename to src/main/rules/GCI526/GCI526.json diff --git a/ecocode-rules-specifications/src/main/rules/EC526/java/EC526.asciidoc b/src/main/rules/GCI526/java/GCI526.asciidoc similarity index 86% rename from ecocode-rules-specifications/src/main/rules/EC526/java/EC526.asciidoc rename to src/main/rules/GCI526/java/GCI526.asciidoc index 36b25cef1..06ac09e25 100644 --- a/ecocode-rules-specifications/src/main/rules/EC526/java/EC526.asciidoc +++ b/src/main/rules/GCI526/java/GCI526.asciidoc @@ -4,16 +4,18 @@ Most often, the slave is a GATT server and the master is a GATT client. GATT cap Invoking `BluetoothGatt#requestConnectionPriority(int connectionPriority)` with the value `CONNECTION_PRIORITY_LOW_POWER`, is recommended to reduce power consumption. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- BluetoothGatt gatt = new BluetoothGatt(); gatt.requestConnectionPriority(CONNECTION_PRIORITY_HIGH); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- BluetoothGatt gatt = new BluetoothGatt(); gatt.requestConnectionPriority(CONNECTION_PRIORITY_LOW_POWER); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC527/EC527.json b/src/main/rules/GCI527/GCI527.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC527/EC527.json rename to src/main/rules/GCI527/GCI527.json diff --git a/ecocode-rules-specifications/src/main/rules/EC523/java/EC523.asciidoc b/src/main/rules/GCI527/java/GCI527.asciidoc similarity index 87% rename from ecocode-rules-specifications/src/main/rules/EC523/java/EC523.asciidoc rename to src/main/rules/GCI527/java/GCI527.asciidoc index 2fb54ab84..de19e643b 100644 --- a/ecocode-rules-specifications/src/main/rules/EC523/java/EC523.asciidoc +++ b/src/main/rules/GCI527/java/GCI527.asciidoc @@ -2,20 +2,22 @@ With a call to `LocationManager#requestLocationUpdates(String provider, long min These two must imperatively be greater than 0. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000L, // refresh location at least each 60000ms 10.0f, // refresh location at least each 10 meters this); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC528/EC528.json b/src/main/rules/GCI528/GCI528.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC528/EC528.json rename to src/main/rules/GCI528/GCI528.json diff --git a/ecocode-rules-specifications/src/main/rules/EC528/java/EC528.asciidoc b/src/main/rules/GCI528/java/GCI528.asciidoc similarity index 90% rename from ecocode-rules-specifications/src/main/rules/EC528/java/EC528.asciidoc rename to src/main/rules/GCI528/java/GCI528.asciidoc index 5698168e1..df93afbdb 100644 --- a/ecocode-rules-specifications/src/main/rules/EC528/java/EC528.asciidoc +++ b/src/main/rules/GCI528/java/GCI528.asciidoc @@ -2,16 +2,18 @@ Shaking of an Android device is possible in all circumstances with a call to `ge Behind this effect stands a specific miniature hardware component, motor or actuator, that consumes power. As a consequence, its usage must be discouraged, especially since its added value is not clear. -## Noncompliant Code Example +== Non compliant Code Example API 26: -```java +[source,java] +---- Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(400); -``` +---- API 31: -```java +[source,java] +---- VibratorManager vm = (VibratorManager) getSystemService(Context.VIBRATOR_MANAGER_SERVICE); vm.getDefaultVibrator().vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC529/EC529.json b/src/main/rules/GCI529/GCI529.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC529/EC529.json rename to src/main/rules/GCI529/GCI529.json diff --git a/ecocode-rules-specifications/src/main/rules/EC529/java/EC529.asciidoc b/src/main/rules/GCI529/java/GCI529.asciidoc similarity index 93% rename from ecocode-rules-specifications/src/main/rules/EC529/java/EC529.asciidoc rename to src/main/rules/GCI529/java/GCI529.asciidoc index 9dcff316a..9d64cd7bf 100644 --- a/ecocode-rules-specifications/src/main/rules/EC529/java/EC529.asciidoc +++ b/src/main/rules/GCI529/java/GCI529.asciidoc @@ -2,22 +2,24 @@ Giving information to the end-user through notifications is an important aspect However, a notification does not necessarily need to be loud and vibrant to achieve its purpose. Default mode is enough. That is why when building a notification with `NotificationManager` there should be no extra calls to the methods `setSound()` nor `setVibrate()` (API26) nor `setVibrationPattern()` (API31) on the builder object. -## Noncompliant Code Example +== Non compliant Code Example API 26: -```java +[source,java] +---- Notification.Builder notificationBuilder = new Notification.Builder(getApplicationContext(), "42"); notificationBuilder.setVibrate(new long[] {1000, 1000, 1000, 1000, 1000}); notificationBuilder.setSound( RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), Notification.AUDIO_ATTRIBUTES_DEFAULT ); -``` +---- API 31: -```java +[source,java] +---- NotificationChannel notification = new NotificationChannel("42", "test", NotificationManager.IMPORTANCE_DEFAULT @@ -27,4 +29,4 @@ notification.setSound( RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), Notification.AUDIO_ATTRIBUTES_DEFAULT ); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC530/EC530.json b/src/main/rules/GCI530/GCI530.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC530/EC530.json rename to src/main/rules/GCI530/GCI530.json diff --git a/ecocode-rules-specifications/src/main/rules/EC530/java/EC530.asciidoc b/src/main/rules/GCI530/java/GCI530.asciidoc similarity index 89% rename from ecocode-rules-specifications/src/main/rules/EC530/java/EC530.asciidoc rename to src/main/rules/GCI530/java/GCI530.asciidoc index 9357810a6..55b701d0c 100644 --- a/ecocode-rules-specifications/src/main/rules/EC530/java/EC530.asciidoc +++ b/src/main/rules/GCI530/java/GCI530.asciidoc @@ -1,8 +1,9 @@ Turning on the torch mode programmatically with `CameraManager#setTorchMode(..., true)` must absolutely be avoided because the flashlight is one of the most energy-intensive component. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- CameraManager camManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); String cameraId = null; try { @@ -11,4 +12,4 @@ try { } catch (CameraAccessException e) { e.printStackTrace(); } -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC530/java/EC530.json b/src/main/rules/GCI530/java/GCI530.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC530/java/EC530.json rename to src/main/rules/GCI530/java/GCI530.json diff --git a/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc b/src/main/rules/GCI530/javascript/GCI530.asciidoc similarity index 94% rename from ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc rename to src/main/rules/GCI530/javascript/GCI530.asciidoc index 830784d73..1e80152aa 100644 --- a/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.asciidoc +++ b/src/main/rules/GCI530/javascript/GCI530.asciidoc @@ -2,7 +2,7 @@ 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 +== Non compliant Code Example [source,js,data-diff-id="2",data-diff-type="noncompliant"] ---- diff --git a/ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.json b/src/main/rules/GCI530/javascript/GCI530.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC530/javascript/EC530.json rename to src/main/rules/GCI530/javascript/GCI530.json diff --git a/ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.asciidoc b/src/main/rules/GCI530/swift/GCI530.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.asciidoc rename to src/main/rules/GCI530/swift/GCI530.asciidoc index 0cc3c0778..559e85bce 100644 --- a/ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.asciidoc +++ b/src/main/rules/GCI530/swift/GCI530.asciidoc @@ -1,9 +1,10 @@ Turning on the torch mode programmatically using `AVCaptureDevice#torchMode` or `AVCaptureDevice#setTorchModeOn(level:)` methods must absolutely be avoided because the flashlight is one of the most energy-intensive component. -## Non-Compliant Code Example +== Non compliant Code Example -```swift +[source,swift] +---- guard let videoDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) else { return } guard videoDevice.hasTorch else { return } @@ -11,4 +12,4 @@ videoDevice.lockForConfiguration() videoDevice.torchMode = .on // non-compliant videoDevice.setTorchModeOn(level: 1.0) // non-compliant videoDevice.unlockForConfiguration() -``` \ No newline at end of file +---- \ No newline at end of file diff --git a/ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.json b/src/main/rules/GCI530/swift/GCI530.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC530/swift/EC530.json rename to src/main/rules/GCI530/swift/GCI530.json diff --git a/ecocode-rules-specifications/src/main/rules/EC531/EC531.json b/src/main/rules/GCI531/GCI531.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC531/EC531.json rename to src/main/rules/GCI531/GCI531.json diff --git a/ecocode-rules-specifications/src/main/rules/EC531/java/EC531.asciidoc b/src/main/rules/GCI531/java/GCI531.asciidoc similarity index 83% rename from ecocode-rules-specifications/src/main/rules/EC531/java/EC531.asciidoc rename to src/main/rules/GCI531/java/GCI531.asciidoc index a12e6a75f..df2d3beb5 100644 --- a/ecocode-rules-specifications/src/main/rules/EC531/java/EC531.asciidoc +++ b/src/main/rules/GCI531/java/GCI531.asciidoc @@ -1,13 +1,15 @@ In Android 11 (API level 30) or higher, a call to `Surface#setFrameRate(float frameRate, int compatibility)` results in a change to the display refresh rate. However, a regular app displays 60 frames per second (60Hz). In order to optimize content refreshes and hence saving energy, this frequency should not be raised to 90Hz or 120Hz, despite this is now supported by many devices. -## Noncompliant Code Example +== Non compliant Code Example -```java +[source,java] +---- surface.setFrameRate(120f, FRAME_RATE_COMPATIBILITY_DEFAULT); -``` +---- -## Compliant Code Example +== Compliant Code Example -```java +[source,java] +---- surface.setFrameRate(60f, FRAME_RATE_COMPATIBILITY_DEFAULT); -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC532/EC532.json b/src/main/rules/GCI532/GCI532.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC532/EC532.json rename to src/main/rules/GCI532/GCI532.json diff --git a/ecocode-rules-specifications/src/main/rules/EC532/java/EC532.asciidoc b/src/main/rules/GCI532/java/GCI532.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC532/java/EC532.asciidoc rename to src/main/rules/GCI532/java/GCI532.asciidoc index 8cec4d695..f8234022d 100644 --- a/ecocode-rules-specifications/src/main/rules/EC532/java/EC532.asciidoc +++ b/src/main/rules/GCI532/java/GCI532.asciidoc @@ -1,15 +1,17 @@ Importing the `com.google.android.gms.analytics.Tracker` or `com.google.firebase.analytics.FirebaseAnalytics` classes means that the app sends hits to Google Analytics. It is not necessarily sensitive information, but it is a first step towards Google Ads and hence this practice should be discouraged at early stage. -## Noncompliant Code Example +== Non compliant Code Example Import of Google Analytics : -```java +[source,java] +---- import com.google.android.gms.analytics.Tracker -``` +---- Import of Firebase Analytics : -```java +[source,java] +---- import com.google.firebase.analytics -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC533/EC533.json b/src/main/rules/GCI533/GCI533.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC533/EC533.json rename to src/main/rules/GCI533/GCI533.json diff --git a/ecocode-rules-specifications/src/main/rules/EC533/swift/EC533.asciidoc b/src/main/rules/GCI533/swift/GCI533.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC533/swift/EC533.asciidoc rename to src/main/rules/GCI533/swift/GCI533.asciidoc index fd19cdcfe..7942a874d 100644 --- a/ecocode-rules-specifications/src/main/rules/EC533/swift/EC533.asciidoc +++ b/src/main/rules/GCI533/swift/GCI533.asciidoc @@ -1,9 +1,10 @@ Allowing the system to pause location updates, at times when the location data is unlikely to change, can improve battery life without sacrificing location data. This is the default behavior. For example, if the user stops for food while using a navigation app, the location manager might pause updates for a period of time. It is possible to disable this behavior, by setting the `CLLocationManager#pausesLocationUpdatesAutomatically` property to `false`, but applications are strongly discouraged of doing it. -## Noncompliant Code Example +== Non compliant Code Example -```swift +[source,swift] +---- let manager = CLLocationManager() manager.pausesLocationUpdatesAutomatically = false -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC534/EC534.json b/src/main/rules/GCI534/GCI534.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC534/EC534.json rename to src/main/rules/GCI534/GCI534.json diff --git a/ecocode-rules-specifications/src/main/rules/EC534/swift/EC534.asciidoc b/src/main/rules/GCI534/swift/GCI534.asciidoc similarity index 95% rename from ecocode-rules-specifications/src/main/rules/EC534/swift/EC534.asciidoc rename to src/main/rules/GCI534/swift/GCI534.asciidoc index 06310b54c..283e100a8 100644 --- a/ecocode-rules-specifications/src/main/rules/EC534/swift/EC534.asciidoc +++ b/src/main/rules/GCI534/swift/GCI534.asciidoc @@ -1,10 +1,11 @@ Using the Core Motion API, your app can receive continuous motion updates in the form of accelerometer, gyroscope, and device motion (rotation, acceleration, and more) events. Yet you don't often need these updates as soon as they are generated. Before registering to receive these recurring motion updates, you can specify an interval that meets your app’s needs, using `CMMotionManager#accelerometerUpdateInterval`, `CMMotionManager#gyroUpdateInterval`, `CMMotionManager#deviceMotionUpdateInterval` and `CMMotionManager#magnetometerUpdateInterval` properties. The larger the interval, the fewer events are delivered to your app, improving battery life. -## Compliant Code +== Compliant Code -```swift +[source,swift] +---- CMMotionManager.accelerometerUpdateInterval = 1000 CMMotionManager.gyroUpdateInterval = 1000 CMMotionManager.deviceMotionUpdateInterval = 1000 CMMotionManager.magnetometerUpdateInterval = 1000 -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC540/EC540.json b/src/main/rules/GCI540/GCI540.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC540/EC540.json rename to src/main/rules/GCI540/GCI540.json diff --git a/ecocode-rules-specifications/src/main/rules/EC540/xml/EC540.asciidoc b/src/main/rules/GCI540/xml/GCI540.asciidoc similarity index 91% rename from ecocode-rules-specifications/src/main/rules/EC540/xml/EC540.asciidoc rename to src/main/rules/GCI540/xml/GCI540.asciidoc index 722d5d683..77de0a9ab 100644 --- a/ecocode-rules-specifications/src/main/rules/EC540/xml/EC540.asciidoc +++ b/src/main/rules/GCI540/xml/GCI540.asciidoc @@ -1,4 +1,4 @@ -Score ecoCode: 2sur5 +Score creedengo: 2sur5 Services are long-living operations, as components of the apps. However, they can be started in isolation each time the device is next started, without the user's acknowledgement. @@ -8,12 +8,13 @@ In addition, end-users know how to kill applications, but more rarely how to kil Thus, any developer should avoid having a call to `Context#startService()` from a Broadcast Receiver component that has specified an intent-filter for the `BOOT_COMPLETED` action in the manifest. -## Noncompliant Code Example +== Non compliant Code Example -```xml +[source,xml] +---- -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC543/EC543.json b/src/main/rules/GCI543/GCI543.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC543/EC543.json rename to src/main/rules/GCI543/GCI543.json diff --git a/ecocode-rules-specifications/src/main/rules/EC543/xml/EC543.asciidoc b/src/main/rules/GCI543/xml/GCI543.asciidoc similarity index 84% rename from ecocode-rules-specifications/src/main/rules/EC543/xml/EC543.asciidoc rename to src/main/rules/GCI543/xml/GCI543.asciidoc index 5eec80ead..953530926 100644 --- a/ecocode-rules-specifications/src/main/rules/EC543/xml/EC543.asciidoc +++ b/src/main/rules/GCI543/xml/GCI543.asciidoc @@ -1,11 +1,12 @@ -Score ecoCode: 2sur5 +Score creedengo: 2sur5 A negative effect on the device s battery is when an app is paired with a companion device (over Bluetooth, BLE, or Wi-Fi) and that it has been excluded from battery optimizations (run in the background) using the declaration `Manifest.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND`. -## Noncompliant Code Example +== Non compliant Code Example -```xml +[source,xml] +---- -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC544/EC544.json b/src/main/rules/GCI544/GCI544.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC544/EC544.json rename to src/main/rules/GCI544/GCI544.json diff --git a/ecocode-rules-specifications/src/main/rules/EC544/xml/EC544.asciidoc b/src/main/rules/GCI544/xml/GCI544.asciidoc similarity index 85% rename from ecocode-rules-specifications/src/main/rules/EC544/xml/EC544.asciidoc rename to src/main/rules/GCI544/xml/GCI544.asciidoc index 3abdafaf2..1be56c9a3 100644 --- a/ecocode-rules-specifications/src/main/rules/EC544/xml/EC544.asciidoc +++ b/src/main/rules/GCI544/xml/GCI544.asciidoc @@ -1,13 +1,14 @@ -Score ecoCode: 2sur5 +Score creedengo: 2sur5 An app holding the permission `REQUEST_IGNORE_BATTERY_OPTIMIZATIONS` asks the user to allow it to ignore battery optimizations (that is, put them on the whitelist of apps). Most applications should not use this; there are many facilities provided by the platform for applications to operate correctly in the various power saving modes. -## Noncompliant Code Example +== Non compliant Code Example -```xml +[source,xml] +---- -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC547/EC547.json b/src/main/rules/GCI547/GCI547.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC547/EC547.json rename to src/main/rules/GCI547/GCI547.json diff --git a/ecocode-rules-specifications/src/main/rules/EC547/xml/EC547.asciidoc b/src/main/rules/GCI547/xml/GCI547.asciidoc similarity index 83% rename from ecocode-rules-specifications/src/main/rules/EC547/xml/EC547.asciidoc rename to src/main/rules/GCI547/xml/GCI547.asciidoc index 4b8bcc02e..6ec7831d0 100644 --- a/ecocode-rules-specifications/src/main/rules/EC547/xml/EC547.asciidoc +++ b/src/main/rules/GCI547/xml/GCI547.asciidoc @@ -1,16 +1,17 @@ -Score ecoCode: 2sur5 +Score creedengo: 2sur5 Displaying dark colors is particularly beneficial for mobile devices with (AM)OLED screens. Consequently, custom resources like bright colors values and bitmap images with too high luminance should be avoided. -## Noncompliant Code Example +== Non compliant Code Example -```xml +[source,xml] +---- -``` +---- diff --git a/ecocode-rules-specifications/src/main/rules/EC548/EC548.json b/src/main/rules/GCI548/GCI548.json similarity index 100% rename from ecocode-rules-specifications/src/main/rules/EC548/EC548.json rename to src/main/rules/GCI548/GCI548.json diff --git a/ecocode-rules-specifications/src/main/rules/EC548/xml/EC548.asciidoc b/src/main/rules/GCI548/xml/GCI548.asciidoc similarity index 82% rename from ecocode-rules-specifications/src/main/rules/EC548/xml/EC548.asciidoc rename to src/main/rules/GCI548/xml/GCI548.asciidoc index 5ea8017df..4dcb0ecc0 100644 --- a/ecocode-rules-specifications/src/main/rules/EC548/xml/EC548.asciidoc +++ b/src/main/rules/GCI548/xml/GCI548.asciidoc @@ -1,29 +1,33 @@ -Score ecoCode: 2sur5 +Score creedengo: 2sur5 Developers are allowed to apply native themes for their app, or derive new ones through inheritance. This decision has a significant impact on energy consumption since displaying dark colors is particularly beneficial for mobile devices with (AM)OLED screens. By default, Android will set Holo to the Dark theme (parent style `Theme.Holo`) and hence switching to the light theme (parent style `Theme.Holo.Light`) within the manifest or in xml themes should be avoided. -## Noncompliant Code Example +== Non compliant Code Example -```xml +[source,xml] +----