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(