<@U02R8E8EMGR> another question re `Rule`: previou...
# ktlint
s
@Paul Dingemans another question re `Rule`: previously the final rule name would be a combination of the RuleSet name + the Rule name, e.g.
my-custom-ruleset:my-custom-rule
. now it seems we explicitly put the ruleset name in the
Rule
(e.g. https://github.com/pinterest/ktlint/blame/master/ktlint-ruleset-experimental/src/m[…]t/ktlint/ruleset/experimental/DiscouragedCommentLocationRule.kt) which seems to make any given
Rule
class less portable. can you describe why we made that change?
p
Yes that is correct. The reason for this is multifold. Moving rules from one ruleset to another ruleset causes problems both internally in ktlint as well as for developers that use those rules. Not only references in the
.editorconfig
property
ktlint_disable_rules
but also all references in ktlint suppression statements have to be changed as well. In case a rule is referenced in a
VisitorModifier
then also this reference has to change. Some API consumers, define custom ruleset providers but re-use a selection of ktlint rules. Although it is fine that API consumers do so, this should never affect the
VisitorModifier
rules which were defined for that rule inside ktlint. Another reason is related to Unit testing. The majority of the tests only run one specific rule. A minority of the tests however require to run a collection of rules. In those cases it is necessary to run the rules in the exact same order as they would have be run by the CLI/API version. When running the unit tests, the ruleset providers are not used (see https://github.com/pinterest/ktlint/commit/5eef6a7843eca7897d50e86440e3bab34bdb19a5). In one of upcoming releases, I intend to remove the notion of the
experimental
ruleset in ktlint entirely. Instead, a new rule will be incorporated directly into the
standard
ruleset but it will be marked with a
tag
holding value
experimental
. The current logic which add/removes the experimental rules set will be replaced with filtering based on the
tag
.
s
that's fair. and yes i discovered this because our inline
// ktlint-disable
imperatives stopped working for our custom rulesets
p
Didn’t you read the release notes? 🤪