Skip to content

Commit

Permalink
Remove groovy rule EC5002 since it is not in the best practices anymo…
Browse files Browse the repository at this point in the history
…re. Create a Codenarc new version (2.2.5) with the rule deletion.
  • Loading branch information
jhertout committed Jan 8, 2024
1 parent 4328aa2 commit b3f41d4
Show file tree
Hide file tree
Showing 22 changed files with 15 additions and 304 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deleted

- [#80](https://github.com/green-code-initiative/ecoCode-android/issues/80) Delete rule EC5002 (SDK range) since it not in
the [best practices mobile](https://github.com/cnumr/best-practices-mobile) anymore

## [1.1.0] - 2023-11-17

### Added
Expand Down
2 changes: 1 addition & 1 deletion android-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<dependency>
<groupId>org.codenarc</groupId>
<artifactId>CodeNarc</artifactId>
<version>2.2.4</version>
<version>2.2.5</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ruleKey;remediationFunction;remediationFactor
EC5001;linear;1h
EC5002;linear;10min
EC5003;linear;10min
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
EC5001
EC5002
EC5003
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,6 @@
<tag>code-smell</tag>
</rule>

<!-- since 2.2.1 -->
<rule>
<key>EC5002</key>
<severity>MINOR</severity>
<name><![CDATA[Supported Version Range]]></name>
<internalKey><![CDATA[EC5002]]></internalKey>
<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>
<p>Example of violations:</p>
<pre><code>android {
compileSdk 32
defaultConfig {
applicationId &quot;com.example.sampleForSonar&quot;
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName &quot;1.0&quot;
testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
</code></pre>
]]></description>
<tag>code-smell</tag>
</rule>

<!-- since 2.2.3 -->
<rule>
<key>EC5003</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public void test() {
assertThat(repository.language()).isEqualTo(Groovy.KEY);

List<Rule> rules = repository.rules();
assertThat(rules).hasSize(3);
assertThat(rules).hasSize(2);
}
}
5 changes: 5 additions & 0 deletions codenarc-converter/CodeNarc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!-- markdownlint-disable MD003 MD004 MD007 MD032 -->
# CodeNarc Change Log

Version 2.2.5 (January 2024)
--------------------------------------
Remove rule:
- Supported Version Range -> EC5002

Version 2.2.4 (September 2023)
--------------------------------------
Update key of ecoCode rules:
Expand Down
2 changes: 1 addition & 1 deletion codenarc-converter/CodeNarc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ shadowJar {

group = 'org.codenarc'
archivesBaseName = 'CodeNarc'
version = '2.2.4'
version = '2.2.5'

sourceCompatibility = '1.7'
targetCompatibility = '1.7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ ruleset {
DuplicateSetValue
DuplicateStringLiteral
EC5001
EC5002
EC5003
ElseBlockBraces
EmptyCatchBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ ruleset {

// rulesets/ecocode.xml
EC5001
EC5002
EC5003

// rulesets/enhanced.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ title: CodeNarc - Rule Index by Name
* [DuplicateSetValue](./codenarc-rules-basic.html#duplicatesetvalue-rule)
* [DuplicateStringLiteral](./codenarc-rules-dry.html#duplicatestringliteral-rule)
* [EC5001](./codenarc-rules-ecocode.html#EC5001-rule)
* [EC5002](./codenarc-rules-ecocode.html#EC5002-rule)
* [EC5003](./codenarc-rules-ecocode.html#EC5003-rule)
* [ElseBlockBraces](./codenarc-rules-braces.html#elseblockbraces-rule)
* [EmptyCatchBlock](./codenarc-rules-basic.html#emptycatchblock-rule)
Expand Down
1 change: 0 additions & 1 deletion codenarc-converter/CodeNarc/docs/codenarc-rule-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ title: CodeNarc - Rule Index

## [Ecocode](./codenarc-rules-ecocode.html)
* [EC5001](./codenarc-rules-ecocode.html#EC5001-rule)
* [EC5002](./codenarc-rules-ecocode.html#EC5002-rule)
* [EC5003](./codenarc-rules-ecocode.html#EC5003-rule)

## [Enhanced](./codenarc-rules-enhanced.html)
Expand Down
38 changes: 0 additions & 38 deletions codenarc-converter/CodeNarc/docs/codenarc-rules-ecocode.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,44 +45,6 @@ Example of violations:
}
```

## EC5002 Rule

*Since CodeNarc 2.2.1*

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.

Example of violations:

```
android {
compileSdk 32
defaultConfig {
applicationId "com.example.sampleForSonar"
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
```

## EC5003 Rule

*Since CodeNarc 2.2.3*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
EC5003.description=Using minifyEnabled true will obfuscate code and will have a sligthly negative impact on power consumption at runtime.
EC5003.description.html=Using minifyEnabled true will obfuscate code and will have a sligthly negative impact on power consumption at runtime.

EC5002.description=The amplitude of supported platform versions should not be too wide, at the risk of making the app too heavy to handle all cases.
EC5002.description.html=The amplitude of supported platform versions should not be too wide, at the risk of making the app too heavy to handle all cases.

EC5001.description=Using "multiDexEnabled true" goes against the overall reduction of the weight of the apps and hence must be avoided.
EC5001.description.html=Using "multiDexEnabled true" goes against the overall reduction of the weight of the apps and hence must be avoided.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ DuplicateNumberLiteral = org.codenarc.rule.dry.DuplicateNumberLiteralRule
DuplicateSetValue = org.codenarc.rule.basic.DuplicateSetValueRule
DuplicateStringLiteral = org.codenarc.rule.dry.DuplicateStringLiteralRule
EC5001 = org.codenarc.rule.ecocode.EC5001
EC5002 = org.codenarc.rule.ecocode.EC5002
EC5003 = org.codenarc.rule.ecocode.EC5003
ElseBlockBraces = org.codenarc.rule.braces.ElseBlockBracesRule
EmptyCatchBlock = org.codenarc.rule.basic.EmptyCatchBlockRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.4
2.2.5
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
</description>

<rule class='org.codenarc.rule.ecocode.EC5001'/>
<rule class='org.codenarc.rule.ecocode.EC5002'/>
<rule class='org.codenarc.rule.ecocode.EC5003'/>
</ruleset>
Loading

0 comments on commit b3f41d4

Please sign in to comment.