MaibornWolff / codecharta

CodeCharta visualizes multiple code metrics using 3D tree maps.
https://maibornwolff.github.io/codecharta/
BSD 3-Clause "New" or "Revised" License
178 stars 30 forks source link

Tech: Analysis Code Style - Fix after `ktlint` upgrade #3608

Closed phanlezz closed 1 month ago

phanlezz commented 2 months ago

Research/Tech

After our upgrade to the new ktlint version during the migration to Gradle 8, we adopted the default code style provided by ktlint, as we thought, that rules couldn't be changed or excluded. But there is a way to configure ktlint - inside the .editorconfig.

At the moment, we apply the default rules with a mix of settings from .editorconfig, which results in unreadable formatting.

Open question: Does the Plugin, that integrates Ktlint into our Gradle Project, support configuration through .editorconfig?

Ktlint Rules Page jlleitschuh/ktlint-gradle - Our used Ktlint to Gradle Plugin Other Gradle Plugins

General Idea

Change the linting configuration, resulting in a format that is similar to before the upgrade.

Proposed Solution

⚠️ In a first test, I was able to apply the IntelliJ > Reformat Code option, which then was accepted by Gradle > ktlintCheck.

E.g. add a preset of rules to the .editorconfig:

[*.{kt,kts}]
ktlint_code_style = intellij_idea # or android_studio or ktlint_official (default)

We may want to set and change rules individually.