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

Integrate linting #529

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

shs96c
Copy link
Contributor

@shs96c shs96c commented Apr 15, 2021

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.

The `kotlin_repositories` macro is designed to download the third
party dependencies that rules_kotlin has for itself. Because of the
way that Bazel works, these must first be downloaded before they can
be referred to by build files.
If a user has chosen to enable linting, `rules_kotlin` will now
generate ktlint tests automatically. These can be run with a `bazel
test --test_tag_filters=lint //...`
@Kernald
Copy link
Contributor

Kernald commented Apr 18, 2021

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

@shs96c
Copy link
Contributor Author

shs96c commented Apr 21, 2021

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

Stardoc doesn't allow a macro to wrap a rule and also have the rule's
documentation be generated.

Ideally, we'd simply exclude the lint wrappers and omit the `input`
attribute from the `stardoc` target. However, thanks to [an issue with
stardoc](bazelbuild/stardoc#99) this is not
an option. As an alternative, we provide a verion of `rules.bzl` that
deliberately excludes the lint wrappers.
@shs96c
Copy link
Contributor Author

shs96c commented Apr 21, 2021

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

@alexeagle
Copy link
Contributor

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

@jeffzoch
Copy link
Contributor

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

@Bencodes
Copy link
Collaborator

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.

@Kernald
Copy link
Contributor

Kernald commented Apr 26, 2021

Note that as I commented on 83224e4#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 (pinterest/ktlint#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.

@gibfahn
Copy link

gibfahn commented Apr 27, 2021

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?

@shs96c
Copy link
Contributor Author

shs96c commented Apr 27, 2021

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.

@Kernald
Copy link
Contributor

Kernald commented Apr 27, 2021

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?

@shs96c
Copy link
Contributor Author

shs96c commented Apr 27, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: common status: open - needs triage type: cleanup Refactorings, idiomatic transforms, tech debt payoff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants