Skip to content

Feature/rename project #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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
-------------
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand All @@ -45,4 +45,4 @@ class FusedLocationCheck : AbstractCheck() {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "creedengo (Android)",
"ruleKeys": [
"GCI518",
"GCI517"
]
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"tags": [
"optimized-api",
"environment",
"ecocode",
"creedengo",
"android",
"eco-design"
],
"defaultSeverity": "Major",
"sqKey": "EC517"
}
"sqKey": "GCI517"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"tags": [
"optimized-api",
"environment",
"ecocode",
"creedengo",
"android",
"eco-design"
],
"defaultSeverity": "Major",
"sqKey": "EC518"
}
"sqKey": "GCI518"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ 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)
}

@Test
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<String> { obj: BuiltInQualityProfilesDefinition.BuiltInActiveRule -> obj.ruleKey() }
.contains("EC518", "EC517")
.contains("GCI518", "GCI517")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

Expand All @@ -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())
Expand Down