-
Notifications
You must be signed in to change notification settings - Fork 2
fix: custom ktlint rules #130
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin | |
| * Configure lint rules for the project | ||
| * @param lintPaths list of paths relative to the project root to lint (or not lint). | ||
| */ | ||
| fun Project.configureLinting(lintPaths: List<String>) { | ||
| fun Project.configureLinting(lintPaths: List<String>, repoToolsVersion: String) { | ||
| verifyRootProject { "Kotlin SDK lint configuration is expected to be configured on the root project" } | ||
|
|
||
| val ktlintVersion = object {} // Can't use Project.javaClass because that's using the Gradle classloader | ||
|
|
@@ -32,6 +32,7 @@ fun Project.configureLinting(lintPaths: List<String>) { | |
| attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.SHADOWED)) | ||
| } | ||
| } | ||
| ktlint("aws.sdk.kotlin.gradle:ktlint-rules:$repoToolsVersion") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See: "in case of custom ruleset" |
||
| } | ||
|
|
||
| // add the buildscript classpath which should pick up our custom ktlint-rules (via runtimeOnly dep on this plugin) | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rule ID changes are to comply with Ktlint regex. e.g. see: https://github.com/pinterest/ktlint/blob/cd39c67816dee8c26b19a076eb064c97a248f670/ktlint-ruleset-template/src/main/kotlin/yourpkgname/NoVarRule.kt#L12 |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of having to keep track of aws-kotlin-repo-tools version in a second place. We have access to the
Project, can't we dive in and find the aws-kotlin-repo-tools version?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the caller side, if you can get the aws-kotlin-repo-tools version from
libs.versions.tomland pass it to configureLinting, that would work tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't keep track of the current version in repo tools like we do in the other repos so we can't do that unless we make bigger changes
That's what I'm planning to do, I made sure we can do so before I posted the PR
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Projectin this context is aws-sdk-kotlin, smithy-kotlin, aws-crt-kotlin which do declare a version of aws-kotlin-repo-tools in theirlibs.versions.tomlfile and should be accessible, but your other solution is fine tooOk 👍 , as long as we don't have to configure the aws-kotlin-repo-tools version in two places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get the version from inside
configureLinting?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't as far as I know, this code returns an empty list. The list is already empty by the flatMap call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code worked: