From c5600b55124cb3d993076221ad092b996b0ba339 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Fri, 3 Dec 2021 14:20:20 -0800 Subject: [PATCH] Fix spotbugs warning. --- .../glue/ktlint/KtlintFormatterFunc.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java b/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java index 3c47456dce..2147c22e90 100644 --- a/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java +++ b/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java @@ -43,18 +43,20 @@ public class KtlintFormatterFunc implements FormatterFunc.NeedsFile { public KtlintFormatterFunc(boolean isScript, Map userData) { rulesets = Collections.singletonList(new StandardRuleSetProvider().get()); this.userData = userData; - formatterCallback = new Function2() { - @Override - public Unit invoke(LintError lint, Boolean corrected) { - if (!corrected) { - throw new AssertionError("Error on line: " + lint.getLine() + ", column: " + lint.getCol() + "\n" + lint.getDetail()); - } - return null; - } - }; + formatterCallback = new FormatterCallback(); this.isScript = isScript; } + static class FormatterCallback implements Function2 { + @Override + public Unit invoke(LintError lint, Boolean corrected) { + if (!corrected) { + throw new AssertionError("Error on line: " + lint.getLine() + ", column: " + lint.getCol() + "\n" + lint.getDetail()); + } + return null; + } + } + @Override public String applyWithFile(String unix, File file) throws Exception { return KtLint.INSTANCE.format(new Params(