From 60f897a3a08533688bb476ecefe87e16d7a2e24f Mon Sep 17 00:00:00 2001 From: Aleksandar Dimitrov Date: Sun, 12 Mar 2023 00:46:17 +0100 Subject: [PATCH] Fix ktlint (#159) * Suppress logs for ktlint Recent versions of ktlint (mine's 0.48.2) have started including logs in their output when the `--stdin` flag is given. These logs would end up being included *into the file* by apheleia, which isn't what we want. Since emitting log messages is likely never a good idea when formatting code, I just opted to disable them altogether using a command line flag. This fixes the issue. * Add change log message about ktlint fix --- CHANGELOG.md | 6 ++++++ apheleia.el | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbca5d4..7bde205 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog]. +## Unreleased +### Bugs fixed +* `ktlint` would emit log messages into its stdout when formatting, + and these would get spliced into the source file. This has been fixed + by suppressing all logs from `ktlint`. + ## 3.2 (released 2023-02-25) ### Features * You can use `apheleia-inhibit` as a file-local variable to disable diff --git a/apheleia.el b/apheleia.el index 0e5b5c0..c7faccb 100644 --- a/apheleia.el +++ b/apheleia.el @@ -961,7 +961,7 @@ being run, for diagnostic purposes." (google-java-format . ("google-java-format" "-")) (isort . ("isort" "-")) (lisp-indent . apheleia-indent-lisp-buffer) - (ktlint . ("ktlint" "--stdin" "-F")) + (ktlint . ("ktlint" "--log-level=none" "--stdin" "-F")) (latexindent . ("latexindent" "--logfile=/dev/null")) (mix-format . ("mix" "format" "-")) (nixfmt . ("nixfmt"))