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

Specify exact files to process in ktlint run #4201

Merged
merged 1 commit into from
Dec 30, 2024

Conversation

0xnm
Copy link
Contributor

@0xnm 0xnm commented Dec 28, 2024

This PR improves ktlint support: it explicitly specifies the files to process.

Without that current mill.kotlinlib.ktlint.KtlintModule/checkFormatAll run, for example, will go through the files under the out folder, which is useless and pollutes logs.

Also this PR removes redundant flags from reformatAll and checkFormatAll: former will always be with format=true by definition, the latter will always be with format=false.

@lihaoyi lihaoyi merged commit f20816c into com-lihaoyi:main Dec 30, 2024
25 of 26 checks passed
@lihaoyi
Copy link
Member

lihaoyi commented Dec 30, 2024

Thanks!

@lefou lefou added this to the 0.12.5 milestone Dec 30, 2024
): Command[Unit] = Task.Command {
ktlintAction(
KtlintArgs(format = false, check = check.value),
KtlintArgs(format = false, check = false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a guess, but isn't this a typo? Shouldn't this be

KtlintArgs(format = false, check = true),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, it is a copy-paste typo here. #4247

): Command[Unit] = Task.Command {
ktlintAction(
KtlintArgs(format = true, check = check.value),
KtlintArgs(format = true, check = true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a guess, but isn't this a typo? Shouldn't this be

KtlintArgs(format = true, check = false),

@0xnm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, because check flag controls exit code handling (see

if (ktlintArgs.check) {
throw new RuntimeException(s"ktlint exited abnormally with exit code = $exitCode")
} else {
ctx.log.error(s"ktlint exited abnormally with exit code = $exitCode")
}
). So if format succeeds, exit code will be 0, but we still want to throw exception if something went wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, cool, thank :)

lihaoyi pushed a commit that referenced this pull request Jan 5, 2025
Fix small typo made in #4201 -
`checkFormalAll` task should fail in case of formatting violations.

Co-authored-by: 0xnm <[email protected]>
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

Successfully merging this pull request may close these issues.

4 participants