diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3398024..aa51094 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ Contributing ====== -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. Visualizing kotlin ASTs of a file ------------- diff --git a/README.md b/README.md index 297b137..74e34a1 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,16 @@ ====================================== Mobile apps running on top of battery-limited, android-powered devices are more than others concerned by the reduction -of their environmental footprint. Hence, we created `ecoCode android for Kotlin`, the version of ecoCode project fully +of their environmental footprint. Hence, we created `creedengo android for Kotlin`, the version of creedengo project fully dedicated to the Android Kotlin projects. It provides static code analyzers to highlight code structures that may have a negative ecological impact: energy over-consumption, "fatware", shortening devices' lifespan, etc. -ecoCode android for Kotlin is based on an evolving catalog of [best practices for Android](https://github.com/cnumr/best-practices-mobile#-android-platform). +creedengo android for Kotlin is based on an evolving catalog of [best practices for Android](https://github.com/cnumr/best-practices-mobile#-android-platform). A SonarQube plugin then implements this catalog as rules for scanning your native Android projects. -To work on Android projects developed in Java, you can use the [ecoCode Android plugin for Java projects](https://github.com/green-code-initiative/ecoCode-android). +To work on Android projects developed in Java, you can use the [creedengo Android plugin for Java projects](https://github.com/green-code-initiative/creedengo-android). This project is based on [SonarSource - sonar-kotlin project](https://github.com/SonarSource/sonar-kotlin), fork of the version of the 2023/07/03. diff --git a/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/BluetoothBleCheck.kt b/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/BluetoothBleCheck.kt index da25e72..25977a5 100644 --- a/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/BluetoothBleCheck.kt +++ b/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/BluetoothBleCheck.kt @@ -34,7 +34,7 @@ private const val IMPORT_STR_BLE = "android.bluetooth.le" private const val ERROR_MESSAGE = "You are using Bluetooth. Did you take a look at the Bluetooth Low Energy API?" private const val GOOD_PRACTICE_MESSAGE = "Using android.bluetooth.le.* is a good practice." -@Rule(key = "EC518") +@Rule(key = "GCI518") class BluetoothBleCheck : AbstractCheck() { override fun visitImportList(importList: KtImportList, data: KotlinFileContext?) { diff --git a/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/FusedLocationCheck.kt b/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/FusedLocationCheck.kt index 204e7fd..9f87e90 100644 --- a/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/FusedLocationCheck.kt +++ b/sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/environment/optimized_api/FusedLocationCheck.kt @@ -30,7 +30,7 @@ private const val GOOD_IMPORT = "com.google.android.gms.location" private const val ERROR_MESSAGE = "Use com.google.android.gms.location instead of android.location to maximize battery life." -@Rule(key = "EC517") +@Rule(key = "GCI517") class FusedLocationCheck : AbstractCheck() { override fun visitImportList(importList: KtImportList, data: KotlinFileContext?) { @@ -45,4 +45,4 @@ class FusedLocationCheck : AbstractCheck() { } } } -} \ No newline at end of file +} diff --git a/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinPlugin.kt b/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinPlugin.kt index 8579ab5..0a3f6fb 100644 --- a/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinPlugin.kt +++ b/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinPlugin.kt @@ -27,7 +27,7 @@ class KotlinPlugin : Plugin { companion object { // Global constants const val REPOSITORY_NAME = "SonarAnalyzer" - const val PROFILE_NAME = "ecoCode (Android)" + const val PROFILE_NAME = "creedengo (Android)" const val SKIP_UNCHANGED_FILES_OVERRIDE = "sonar.kotlin.skipUnchanged" const val GRADLE_PROJECT_ROOT_PROPERTY = "sonar.kotlin.gradleProjectRoot" } diff --git a/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinition.kt b/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinition.kt index a36fad9..586011e 100644 --- a/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinition.kt +++ b/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinition.kt @@ -26,7 +26,7 @@ import org.sonarsource.kotlin.api.common.KOTLIN_REPOSITORY_KEY class KotlinProfileDefinition : BuiltInQualityProfilesDefinition { companion object { - const val PATH_TO_JSON = "org/sonar/l10n/kotlin/rules/kotlin/Ecocode_profile.json" + const val PATH_TO_JSON = "org/sonar/l10n/kotlin/rules/kotlin/Creedengo_profile.json" } override fun define(context: BuiltInQualityProfilesDefinition.Context) { diff --git a/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinSensor.kt b/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinSensor.kt index de91d10..bf0508a 100644 --- a/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinSensor.kt +++ b/sonar-kotlin-plugin/src/main/java/org/sonarsource/kotlin/plugin/KotlinSensor.kt @@ -58,7 +58,7 @@ class KotlinSensor( override fun describe(descriptor: SensorDescriptor) { descriptor .onlyOnLanguage("kotlin") - .name("ecoCode Kotlin Sensor") + .name("creedengo Kotlin Sensor") } override fun getExecuteContext( diff --git a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/Creedengo_profile.json b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/Creedengo_profile.json new file mode 100644 index 0000000..dd7ba05 --- /dev/null +++ b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/Creedengo_profile.json @@ -0,0 +1,7 @@ +{ + "name": "creedengo (Android)", + "ruleKeys": [ + "GCI518", + "GCI517" + ] +} diff --git a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/Ecocode_profile.json b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/Ecocode_profile.json deleted file mode 100644 index 9602c2e..0000000 --- a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/Ecocode_profile.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "ecoCode (Android)", - "ruleKeys": [ - "EC518", - "EC517" - ] -} diff --git a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC517.html b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI517.html similarity index 100% rename from sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC517.html rename to sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI517.html diff --git a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC517.json b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI517.json similarity index 88% rename from sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC517.json rename to sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI517.json index 70d0c57..d8bdee2 100644 --- a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC517.json +++ b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI517.json @@ -9,10 +9,10 @@ "tags": [ "optimized-api", "environment", - "ecocode", + "creedengo", "android", "eco-design" ], "defaultSeverity": "Major", - "sqKey": "EC517" -} \ No newline at end of file + "sqKey": "GCI517" +} diff --git a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC518.html b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI518.html similarity index 100% rename from sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC518.html rename to sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI518.html diff --git a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC518.json b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI518.json similarity index 88% rename from sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC518.json rename to sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI518.json index d7da6fe..d92e8b0 100644 --- a/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/EC518.json +++ b/sonar-kotlin-plugin/src/main/resources/org/sonar/l10n/kotlin/rules/kotlin/GCI518.json @@ -9,10 +9,10 @@ "tags": [ "optimized-api", "environment", - "ecocode", + "creedengo", "android", "eco-design" ], "defaultSeverity": "Major", - "sqKey": "EC518" -} \ No newline at end of file + "sqKey": "GCI518" +} diff --git a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinitionTest.kt b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinitionTest.kt index 1e124a4..65692e7 100644 --- a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinitionTest.kt +++ b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinProfileDefinitionTest.kt @@ -30,11 +30,11 @@ private const val MIN_RULE_COUNT = 0 internal class KotlinProfileDefinitionTest { @Test - fun `Ecocode_profile is a valid json file`() { + fun `Creedengo_profile is a valid json file`() { val classLoader = KotlinProfileDefinition::class.java.classLoader val jsonContent = classLoader.getResource(KotlinProfileDefinition.PATH_TO_JSON)?.readText() val json = Gson().fromJson(jsonContent, JsonObject::class.java) - assertThat(json.get("name").asString).isEqualTo("ecoCode (Android)") + assertThat(json.get("name").asString).isEqualTo("creedengo (Android)") assertThat(json.get("ruleKeys").asJsonArray).hasSizeGreaterThan(MIN_RULE_COUNT) } @@ -42,10 +42,10 @@ internal class KotlinProfileDefinitionTest { fun profile() { val context = BuiltInQualityProfilesDefinition.Context() KotlinProfileDefinition().define(context) - val profile = context.profile("kotlin", "ecoCode (Android)") + val profile = context.profile("kotlin", "creedengo (Android)") assertThat(profile.rules().size).isGreaterThan(MIN_RULE_COUNT) assertThat(profile.rules()) .extracting { obj: BuiltInQualityProfilesDefinition.BuiltInActiveRule -> obj.ruleKey() } - .contains("EC518", "EC517") + .contains("GCI518", "GCI517") } } diff --git a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt index 872cabd..99be50f 100644 --- a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt +++ b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt @@ -36,7 +36,7 @@ internal class KotlinRulesDefinitionTest { val repository = repositoryForVersion(Version.create(8, 9)) Assertions.assertThat(repository!!.name()).isEqualTo("SonarQube") Assertions.assertThat(repository.language()).isEqualTo("kotlin") - val rule = repository.rule("EC518")!! + val rule = repository.rule("GCI518")!! Assertions.assertThat(rule.name()) .isEqualTo("Optimized API: Bluetooth Low-Energy") Assertions.assertThat(rule.type()).isEqualTo(RuleType.CODE_SMELL) diff --git a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinSensorTest.kt b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinSensorTest.kt index e37416c..6224f9d 100644 --- a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinSensorTest.kt +++ b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinSensorTest.kt @@ -77,7 +77,7 @@ internal class KotlinSensorTest : AbstractSensorTest() { val descriptor = DefaultSensorDescriptor() sensor(checkFactory).describe(descriptor) - assertThat(descriptor.name()).isEqualTo("ecoCode Kotlin Sensor") + assertThat(descriptor.name()).isEqualTo("creedengo Kotlin Sensor") assertThat(descriptor.languages()).isEqualTo(listOf("kotlin")) } @@ -93,12 +93,12 @@ internal class KotlinSensorTest : AbstractSensorTest() { """.trimIndent() ) context.fileSystem().add(inputFile) - val checkFactory = checkFactory("EC518") + val checkFactory = checkFactory("GCI518") sensor(checkFactory).execute(context) val issues = context.allIssues() assertThat(issues).hasSize(1) val issue = issues.iterator().next() - assertThat(issue.ruleKey().rule()).isEqualTo("EC518") + assertThat(issue.ruleKey().rule()).isEqualTo("GCI518") val location = issue.primaryLocation() assertThat(location.inputComponent()).isEqualTo(inputFile) assertThat(location.message())