Giter Club home page Giter Club logo

Comments (16)

arturbosch avatar arturbosch commented on May 9, 2024 1

Detekt now uses the embeddable compiler. A KtLint rule set is now feasible.

Idea:

  • Create new rule set with wrappers around all KtLint rules
  • Delete spacing, indentation and newline rules from detekt-formatting, just keep the extra rules which feature ast manipulation
  • Users have now the choice between formatting with detektIdeaFormat and detektKtLintFormat

from detekt.

vanniktech avatar vanniktech commented on May 9, 2024 1

I'm at the moment using both tools. Ktlint only for formatting and detekt for everything else. I'd assume that also the way to go for the future.

from detekt.

arturbosch avatar arturbosch commented on May 9, 2024 1

PoC: 18be6bc

Fairly easy to integrate.

from detekt.

arturbosch avatar arturbosch commented on May 9, 2024

ktlint-standard-ruleset is not published to maven central as standalone artifact. Formatting rules were fixed and cleaned up for M11.

from detekt.

shyiko avatar shyiko commented on May 9, 2024

@arturbosch fyi: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22ktlint-ruleset-standard%22

from detekt.

arturbosch avatar arturbosch commented on May 9, 2024

@shyiko nice thx. Did not find it on my own :)

from detekt.

arturbosch avatar arturbosch commented on May 9, 2024

KtLint uses the embeddable kotlin compiler, detekt not.
The new recommend way for formatting is to use the detektIdeaFormat task starting from M11.

from detekt.

vanniktech avatar vanniktech commented on May 9, 2024

So the idea is to get rid of the formatting part in detekt (detekt-formatting) and leave it up to ktlint?

from detekt.

arturbosch avatar arturbosch commented on May 9, 2024

Yeah it would be best. I still do not know what to do with the formatting rules which ktlint does not have. Move them to StyleGuideProvider? Should detekt-rules also support autoCorrect? Should we leave detekt-formatting with all rules and integrate KtLint into that module? Create a new detekt-ktlint-module?

I think a hybrid detekt-formatting module would be best (low change costs). We leave all rules as they are and wait until Ktlint releases new rules or fixes. Then we act and wrap one after the other rules. What do you think?

from detekt.

arturbosch avatar arturbosch commented on May 9, 2024

detekt/sonar-detekt#20

from detekt.

schalkms avatar schalkms commented on May 9, 2024

@arturbosch
I was scanning through the issue list. I think this feature is done, isn't it?

from detekt.

arturbosch avatar arturbosch commented on May 9, 2024

Yes, its done, some documentation is needed, but that can be done when we integrate the module into our CI, thanks for the reminder.

from detekt.

dimsuz avatar dimsuz commented on May 9, 2024

I am new to the project (just integrated it) and I'm a bit lost about role of ktlint in detekt.
So documentation would be helpful indeed.

I was researching why does detekt currently have to very similar rules NoWildcardImports and WildcardImport in its default config, so in the sources I discovered that one is coming from ktlint, another is "native"?

Is this ok, or should I report an issue (or I could submit a PR if you suggest me how this should be resolved).

from detekt.

schalkms avatar schalkms commented on May 9, 2024

@dimsuz
Detekt provides a wrapper over Ktlint.
Thereโ€™s actually some documentation regarding the ktlint integration here.
If you have any suggestions for improvement, please feel free to open an issue. We are grateful for PRs regarding detekt's documentation.

from detekt.

idrisadetunmbi avatar idrisadetunmbi commented on May 9, 2024

Not too sure I understand how this ktlint integration works. If I add the ktlint integration as a formatting ruleset, does it mean detekt will report formatting errors, and if I do not add it, it won't report them? Can I possibly run code formatting with detekt once I add the ktlint integration?

from detekt.

schalkms avatar schalkms commented on May 9, 2024

@idrisadetunmbi I don't quite understand your question.
Detekt provides a wrapper over ktlint's rules with the formatting ruleset.
It depends on whether you have the autoCorrect and active setting set to true in the formatting ruleset.

from detekt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.