Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable rule for one package #136

Closed
VovaStelmashchuk opened this issue May 16, 2020 · 2 comments
Closed

How to disable rule for one package #136

VovaStelmashchuk opened this issue May 16, 2020 · 2 comments

Comments

@VovaStelmashchuk
Copy link

I need to disable one rule for one package. Can implement this?

@jeremymailen
Copy link
Owner

Hi there. The most straightforward way is to suppress the rule in each source file:
https://ktlint.github.io/#faq-error-suppression

kotlinter includes ktlint's .editorconfig support, but I don't think it understands sophisticated file patterns, only [*{kt,kts}]. So that probably wouldn't work.

Finally, you can customize each link task:
https://github.com/jeremymailen/kotlinter-gradle#customizing-tasks

lintKotlinMain {
  disabledRules = ["rule-1", "rule-1"]
}

But tasks are per-sourceSet, so unless your package of interest is in its own sourceSet, it will affect more files than you want.

Of course you can exclude your package from the sourceSet task it's in, then define a custom lint task to just cover that package with reduced rules, but this starts to feel laborious. It will work though.

@VovaStelmashchuk
Copy link
Author

I created a ticket in ktlint repo. Guys from ktlint say it will be fix in next release (0.37).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants