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

ktlint autofix executes on non-file output of ktlint check run #162

Closed
languitar opened this issue May 8, 2023 · 0 comments · Fixed by #163
Closed

ktlint autofix executes on non-file output of ktlint check run #162

languitar opened this issue May 8, 2023 · 0 comments · Fixed by #163

Comments

@languitar
Copy link
Contributor

The ktlint output parsing used to feed files to fix into ktlint includes some non-file output from ktlint that is then feed into the autofix CLI call:

$ /home/johannes/.cache/pre-commit/repojigxkeve/py_env-python3.10/bin/python /home/johannes/.cache/pre-commit/repojigxkeve/py_env-python3.10/bin/pretty-format-kotlin --ktlint-version=0.49.0 --autofix path/TheFile.kt
[cwd=/home/johannes/src/somewhere] Run command: ('java', '-version')
[return_code=0] | Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+0-suse-1.1-x8664)
OpenJDK 64-Bit Server VM (build 11.0.19+0-suse-1.1-x8664, mixed mode)

[cwd=/home/johannes/src/somewhere] Run command: ('java', '--add-opens', 'java.base/java.lang=ALL-UNNAMED', '-jar', '/home/johannes/.cache/pre-commit/ktlint0.49.0.jar', '--log-level', 'debug', '--relative', '--', 'path/TheFile.kt')
[return_code=1] | Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
10:10:47.235 [main] DEBUG com.pinterest.ktlint.cli.internal.KtlintServiceLoader - Discovered RuleSetProviderV3 with id 'standard' in ktlint JAR
10:10:47.352 [main] DEBUG com.pinterest.ktlint.cli.internal.KtlintServiceLoader - Discovered ReporterProviderV2 with id 'baseline' in ktlint JAR
10:10:47.352 [main] DEBUG com.pinterest.ktlint.cli.internal.KtlintServiceLoader - Discovered ReporterProviderV2 with id 'plain' in ktlint JAR

...

10:10:47.740 [pool-1-thread-1] DEBUG com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine - Finished with linting file 'TheFile.kt'
path/TheFile.kt:48:1: Unexpected indentation (10) (should be 8) (standard:indent)

Summary error count (descending) by rule:
  standard:indent: 1
10:10:47.743 [main] DEBUG com.pinterest.ktlint.cli.internal.KtlintCommandLine - Finished processing in 515ms / 1 file(s) scanned / 1 error(s) found
10:10:47.744 [main] DEBUG com.pinterest.ktlint.cli.internal.KtlintCommandLine - Exit ktlint with exit code: 1

Running ktlint format on {'', 'path/TheFile.kt', 'Summary error count (descending) by rule', '10', 'Picked up _JAVA_OPTIONS', '\t', '           - standard', '  standard'}
[cwd=/home/johannes/src/somewhere] Run command: ('java', '--add-opens', 'java.base/java.lang=ALL-UNNAMED', '-jar', '/home/johannes/.cache/pre-commit/ktlint0.49.0.jar', '--log-level', 'debug', '--relative', '--format', '--', '', 'path/TheFile.kt', 'Summary error count (descending) by rule', '10', 'Picked up _JAVA_OPTIONS', '\t', '           - standard', '  standard')

The following shows, that some other output on stdout/stderr got picked up:

Running ktlint format on {'', 'path/TheFile.kt', 'Summary error count (descending) by rule', '10', 'Picked up _JAVA_OPTIONS', '\t', ' - standard', ' standard'}

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 a pull request may close this issue.

1 participant