Giter Club home page Giter Club logo

ecocode-kotlin-android's Introduction

Logo

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 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. 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.

This project is based on SonarSource - sonar-kotlin project, fork of the version of the 2023/07/03.

License: GPL v3

๐Ÿš€ Quickstart

To build the project and run the test simply launch:

./gradlew build

Then, a docker file is configured to launch a SonarQube instance with the plugin installed:

docker compose up --build -d

Wait a little bit during first start initialization, and go to http://localhost:9000. Default credentials are admin/admin

๐Ÿงฉ Plugins version compatibility

Plugins Version SonarQube version
0.0.+ SonarQube 9.9.+ LTS to 10.3

ecocode-kotlin-android's People

Contributors

47tibo avatar jberque avatar jhertout avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ecocode-kotlin-android's Issues

EC518 : BluetoothBleCheck - Add descriptions for terms Ble & Bc and optimise rule

current behavior

  1. Ble & Bc terms are used in variables.

  2. Ble & Bc checks are tightly coupled :

if (bleImports.isNotEmpty() || bcImports.isNotEmpty()) {
            if (bleImports.isNotEmpty()) {
                bleImports.forEach {
                    it.importedReference?.let { data?.reportIssue(it, GOOD_PRACTICE_MESSAGE) }
                }
            } else {
                bcImports.forEach {
                    it.importedReference?.let { data?.reportIssue(it, ERROR_MESSAGE) }
                }
            }
        }

enhancement suggested

  1. Ble & Bc terms are technical terms unknown to junior android developers. Their usage is now a standard, so it won't be a good idea to rename all their usage in the codebase to bluetoothLowEnergy & bluetoothClassic.
    So a good compromise will be to add 2 comments at the top of the file :
// ble stands for "Bluetooth Low Energy"
// bc stands for "Bluetooth Classic"

Their use in the codebase are totally independent : we can import the Ble without the Bc and inversely import the Bc without using the Ble. It is also possible to use both of them (really bad practice, but still, possible).
So we can make them totally independent, and remove conditional checks :

bleImports.forEach { import ->
    import.importedReference?.let { data?.reportIssue(it, GOOD_PRACTICE_MESSAGE) }
}

bcImports.forEach { import ->
    import.importedReference?.let { data?.reportIssue(it, ERROR_MESSAGE) }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.