rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

Integrate linting

Open shs96c opened this issue 4 years ago • 11 comments

This builds on top of #528 in order to integrate lint tests. The second commit ("Automatically generate lint tests...") has more information in how to use the generated lint tests, and integrates the feature into the "anvil" demo.

shs96c avatar Apr 15 '21 16:04 shs96c

Note that this breaks the generated documentation - Stardoc doesn't follow the macro indirection.

Kernald avatar Apr 18 '21 21:04 Kernald

That's suboptimal. I'll fix that now.

shs96c avatar Apr 21 '21 12:04 shs96c

I've fixed the problem with docs generation, but I've had to work around an issue in stardoc.

shs96c avatar Apr 21 '21 13:04 shs96c

That workaround is the same thing we do in rules_nodejs. Expose the rule to stardoc and the macro to users

alexeagle avatar Apr 23 '21 16:04 alexeagle

So does this remove the need to manually define kt_lint tests? They get autogenerated now ?

jeffzoch avatar Apr 26 '21 17:04 jeffzoch

This seems like something that should be opt-in so that kt-lint targets aren't being put on the golden path of repositories that don't rely on it.

Bencodes avatar Apr 26 '21 19:04 Bencodes

Note that as I commented on https://github.com/bazelbuild/rules_kotlin/commit/83224e46eee88b208e89b0e329f96e5b33b3f66c#r49787303 (which I don't think anyone noticed as I commented on the commit after it was merged), the logic currently used to implement ktlint_fix breaks with ktlint > 0.40 (https://github.com/pinterest/ktlint/issues/1131). It's probably worth figuring out a solution to this before going forward with this PR as well, as ktlint 0.41, including this change, has been released over a month ago.

Kernald avatar Apr 26 '21 23:04 Kernald

So does this remove the need to manually define kt_lint tests? They get autogenerated now ?

Yes, if you opt in they get autogenerated.

This seems like something that should be opt-in so that kt-lint targets aren't being put on the golden path of repositories that don't rely on it.

Docs in the PR say "This functionality is opt-in", is there a way we could make this more clear?

gibfahn avatar Apr 27 '21 08:04 gibfahn

I see that @gibfahn has beaten me to answering the two most pressing questions.

Since the version of ktlint is pinned in this repo, I think it'd be okay to update it separately to this, but if people feel it's a blocker, I can explore the work that needs to be done and create a separate PR for that, since the ktlint_fix rule has already landed in this repo.

shs96c avatar Apr 27 '21 10:04 shs96c

Since the version of ktlint is pinned in this repo, I think it'd be okay to update it separately to this, but if people feel it's a blocker, I can explore the work that needs to be done and create a separate PR for that, since the ktlint_fix rule has already landed in this repo.

Maybe opening an issue to track this and adding some documentation about this being a known issue and a link to it would be a good compromise?

Kernald avatar Apr 27 '21 11:04 Kernald

That's a great idea. I'm completely onboard with making ktlint_fix work with the recent ktlint release :) Filed #535 to track it, and I intend to work on it this week.

shs96c avatar Apr 27 '21 13:04 shs96c