pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.23k stars 512 forks source link

Feature: Versioned rule sets #2341

Closed peter-evans closed 1 year ago

peter-evans commented 1 year ago

Expected Behavior

It would be great if rules sets could be versioned. Something like:

ktlint_rule_sets_version = 1.0.0

Setting this in config would allow us to upgrade ktlint (via kotlinter-gradle) while keeping the same rule sets. We could then upgrade our rule sets version independently at a more convenient time.

Not specifying this config would just default to the latest rule sets version.

The version could be consistent with the version of ktlint, or independently versioned.

Current Behavior

ktlint (via the kotlinter-gradle plugin) has been great and worked well for us. The only minor inconvenience is the rule changes that have happened on version bumps of ktlint. We automate dependency updates and when rule changes occur it means we have to manually fix PRs to have them merged.

Additional information

paul-dingemans commented 1 year ago

I think this can only be managed via the kotlinter-gradle plugin configuration as described here. The plugin uses the KtlintLintRuleEngine and provides the rules that have to be run. Also, that would work both for the rulesets provided by Ktlint as well as for custom rulesets.

peter-evans commented 1 year ago

Thank you. I wasn't aware of that functionality. Looks like that covers our use case.