mrmans0n/compose-rules

Unable to suppress a rule with spotless

Closed this issue · 3 comments

i've added https://mrmans0n.github.io/compose-rules/rules/#hoist-all-the-things custom ruleset to ktlint spotless

but i'm unable to suppress a rule for a function

I tried adding
@Suppress("ktlint:compose:vm-forwarding-check") above the function but it doesn't work

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':spotlessKotlin'.
Error on line: 127, column: 17
rule: compose:vm-forwarding-check
Forwarding a ViewModel/Presenter through multiple https://github.com/composable functions should be avoided. Consider using state hoisting.

See https://mrmans0n.github.io/compose-rules/rules/#hoist-all-the-things for more information.

Try:
Run with --info or --debug option to get more log output.

This is managed by ktlint, these rules don't control their own suppressions at all, it's the job of the linter itself to do so.

can you help me with a sample of how to suppress if you have any?

The suppression annotation you wrote there seems to be correct according to ktlint's latest documentation, but somehow your spotless / ktlint setup is not picking it up. Just make sure that the ktlint version being brought by spotless is one that supports that style of suppressions, and double check your gradle configuration - those are the only things that come to mind, sorry.