Skip to content

Commit 0af75b4

Browse files
authored
Merge pull request #74 from jhertout/groovy_rules_nomenclature
Groovy rules nomenclature
2 parents 0eaf2a6 + b4aab32 commit 0af75b4

File tree

28 files changed

+96
-75
lines changed

28 files changed

+96
-75
lines changed

android-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
<dependency>
185185
<groupId>org.codenarc</groupId>
186186
<artifactId>CodeNarc</artifactId>
187-
<version>2.2.3</version>
187+
<version>2.2.4</version>
188188
</dependency>
189189

190190
<dependency>

android-plugin/src/main/java/org/sonar/plugins/groovy/codenarc/CodeNarcRulesDefinition.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434

3535
public class CodeNarcRulesDefinition implements RulesDefinition {
3636

37-
// TODO: Prefix repository-key with "ecocode-" and make "re-keying" of all contained rules
38-
public static final String REPOSITORY_KEY = Groovy.KEY;
39-
public static final String REPOSITORY_NAME = "ecoCode";
37+
public static final String REPOSITORY_KEY = "ecocode-android-groovy";
38+
public static final String REPOSITORY_NAME = Groovy.PROFILE_NAME;
4039
private static final String COST_FILE_PATH = "/org/sonar/plugins/groovy/cost.csv";
4140

4241
@Override

android-plugin/src/main/java/org/sonar/plugins/groovy/foundation/Groovy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Groovy extends AbstractLanguage {
3131

3232
public static final String KEY = "grvy";
3333
public static final String NAME = "Groovy";
34-
public static final String PROFILE_NAME = "ecoCode";
34+
public static final String PROFILE_NAME = "ecoCode (Android)";
3535
public static final String FILE_SUFFIXES_KEY = "sonar.groovy.file.suffixes";
3636
static final String DEFAULT_FILE_SUFFIXES = ".groovy,.gradle";
3737

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ruleKey;remediationFunction;remediationFactor
2-
org.codenarc.rule.ecocode.FatAppRule;linear;1h
3-
org.codenarc.rule.ecocode.SupportedVersionRangeRule;linear;10min
4-
org.codenarc.rule.ecocode.DisableObfuscationRule;linear;10min
2+
EC5001;linear;1h
3+
EC5002;linear;10min
4+
EC5003;linear;10min
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.codenarc.rule.ecocode.FatAppRule
2-
org.codenarc.rule.ecocode.SupportedVersionRangeRule
3-
org.codenarc.rule.ecocode.DisableObfuscationRule
1+
EC5001
2+
EC5002
3+
EC5003

android-plugin/src/main/resources/org/sonar/plugins/groovy/rules.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
<!-- since 2.2.1 -->
66
<rule>
7-
<key>org.codenarc.rule.ecocode.FatAppRule</key>
7+
<key>EC5001</key>
88
<severity>MINOR</severity>
99
<name><![CDATA[Fat App]]></name>
10-
<internalKey><![CDATA[FatApp]]></internalKey>
10+
<internalKey><![CDATA[EC5001]]></internalKey>
1111
<description><![CDATA[<p>Using &quot;multiDexEnabled true&quot; goes against the overall reduction of the weight of the apps and hence must be avoided.</p>
1212
<p>Example of violations:</p>
1313
<pre><code> android {
@@ -46,10 +46,10 @@
4646

4747
<!-- since 2.2.1 -->
4848
<rule>
49-
<key>org.codenarc.rule.ecocode.SupportedVersionRangeRule</key>
49+
<key>EC5002</key>
5050
<severity>MINOR</severity>
5151
<name><![CDATA[Supported Version Range]]></name>
52-
<internalKey><![CDATA[SupportedVersionRange]]></internalKey>
52+
<internalKey><![CDATA[EC5002]]></internalKey>
5353
<description><![CDATA[<p>When looking at the minSdkVersion and targetSdkVersion (or minSdk, targetSdk) attributes for the <uses-sdk> in the AndroidManifest.xml file, the amplitude of supported platform versions should not be too wide, at the risk of making the app too heavy to handle all cases.</p>
5454
<p>Example of violations:</p>
5555
<pre><code>android {
@@ -86,10 +86,10 @@
8686

8787
<!-- since 2.2.3 -->
8888
<rule>
89-
<key>org.codenarc.rule.ecocode.DisableObfuscationRule</key>
89+
<key>EC5003</key>
9090
<severity>MINOR</severity>
9191
<name><![CDATA[Disable Obfuscation]]></name>
92-
<internalKey><![CDATA[DisableObfuscation]]></internalKey>
92+
<internalKey><![CDATA[EC5003]]></internalKey>
9393
<description><![CDATA[<p>Using minifyEnabled true will obfuscate code and will have a sligthly negative impact on power consumption at runtime.</p>
9494
<p>Example of violations:</p>
9595
<pre><code> android {

codenarc-converter/CodeNarc/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
<!-- markdownlint-disable MD003 MD004 MD007 MD032 -->
33
# CodeNarc Change Log
44

5+
Version 2.2.4 (September 2023)
6+
--------------------------------------
7+
Update key of ecoCode rules:
8+
- Fat App -> EC5001
9+
- Supported Version Range -> EC5002
10+
- Disable Obfuscation -> EC5003
11+
512
Version 2.2.3 (November 2022)
613
--------------------------------------
714
Added rule

codenarc-converter/CodeNarc/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ shadowJar {
1414

1515
group = 'org.codenarc'
1616
archivesBaseName = 'CodeNarc'
17-
version = '2.2.3'
17+
version = '2.2.4'
1818

1919
sourceCompatibility = '1.7'
2020
targetCompatibility = '1.7'

codenarc-converter/CodeNarc/docs/StarterRuleSet-AllRules.groovy.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ ruleset {
7777
CyclomaticComplexity // Requires the GMetrics jar
7878
DeadCode
7979
DirectConnectionManagement
80-
DisableObfuscation
8180
DoubleCheckedLocking
8281
DoubleNegative
8382
DuplicateCaseStatement
@@ -88,6 +87,9 @@ ruleset {
8887
DuplicateNumberLiteral
8988
DuplicateSetValue
9089
DuplicateStringLiteral
90+
EC5001
91+
EC5002
92+
EC5003
9193
ElseBlockBraces
9294
EmptyCatchBlock
9395
EmptyClass
@@ -133,7 +135,6 @@ ruleset {
133135
ExplicitStackInstantiation
134136
ExplicitTreeSetInstantiation
135137
FactoryMethodName
136-
FatApp
137138
FieldName
138139
FieldTypeRequired
139140
FileCreateTempFile
@@ -304,7 +305,6 @@ ruleset {
304305
StaticMatcherField
305306
StaticMethodsBeforeInstanceMethods
306307
StaticSimpleDateFormatField
307-
SupportedVersionRange
308308
SwallowThreadDeath
309309
SynchronizedMethod
310310
SynchronizedOnBoxedPrimitive

codenarc-converter/CodeNarc/docs/StarterRuleSet-AllRulesByCategory.groovy.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ ruleset {
166166
DuplicateStringLiteral
167167

168168
// rulesets/ecocode.xml
169-
FatApp
170-
SupportedVersionRange
171-
DisableObfuscation
169+
EC5001
170+
EC5002
171+
EC5003
172172

173173
// rulesets/enhanced.xml
174174
CloneWithoutCloneable

0 commit comments

Comments
 (0)