macisamuele / language-formatters-pre-commit-hooks

Collection of custom pre-commit hooks.
Apache License 2.0
115 stars 58 forks source link

Ensure only files are passed to ktlint for autofixing #163

Closed languitar closed 1 year ago

languitar commented 1 year ago

Avoids passing random log output from the ktlint check run to the second autofix pass of ktlint. Unfortunately, this requires disabling log output for the check run as ktlint puts logging onto stdout, for whatever reason.

The run_command helper could not be used here anymore as it mixes stdout and stderr.

Fixes: #162

codecov[bot] commented 1 year ago

Codecov Report

Merging #163 (d174652) into master (3192c6c) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #163   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          313       315    +2     
=========================================
+ Hits           313       315    +2     
Impacted Files Coverage Δ
...ormatters_pre_commit_hooks/pretty_format_kotlin.py 100.00% <100.00%> (ø)
languitar commented 1 year ago

The JSON format was added years ago in https://github.com/pinterest/ktlint/releases/tag/0.9.0

languitar commented 1 year ago

I've fixed the linting errors. Similar to the utils file, the bandit rules are disabled with line comments.

languitar commented 1 year ago

Is there anything I can do to get this PR through?

languitar commented 1 year ago

Thanks for merging this. After your clean up. would you mind releasing a new version including this fix?

macisamuele commented 1 year ago

I'm currently out of town for a short trip. I would expect to be able to do the cleanup and release the new version between Friday and Sunday.

In the meantime if you need to have access to the feature, you could update the pre commit hooks config (in your repo) pointing to the commit sha of the merge instead of a named version.