From a9607fc97eef82bd39d869ee3a296cdfda0d471b Mon Sep 17 00:00:00 2001 From: Stephen Panaro Date: Thu, 18 Aug 2022 20:17:53 -0400 Subject: [PATCH 1/5] Add ktlint rule ID in formatter callback --- .../com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 da3e3ae475..b9b225f35d 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 @@ -111,7 +111,7 @@ 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()); + throw new AssertionError("Error on line: " + lint.getLine() + ", column: " + lint.getCol() + "\n" + lint.getRuleId() + "\n" + lint.getDetail()); } return null; } From 83411a88e88237d15efb0fd22186875fe57bac83 Mon Sep 17 00:00:00 2001 From: Stephen Panaro Date: Thu, 18 Aug 2022 20:51:20 -0400 Subject: [PATCH 2/5] update changes --- CHANGES.md | 1 + plugin-gradle/CHANGES.md | 3 +++ plugin-maven/CHANGES.md | 1 + 3 files changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 751749585f..6e3ac85da7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +* Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279)) ## [2.28.1] - 2022-08-10 ### Fixed diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 3cf249b893..cdb11f83da 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -4,6 +4,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ## [Unreleased] +### Changes +* Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279)) + ## [6.9.1] - 2022-08-10 ### Fixed * Fix Clang not knowing the filename and changing the format ([#1268](https://github.com/diffplug/spotless/pull/1268) fixes [#1267](https://github.com/diffplug/spotless/issues/1267)). diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 59bf722522..b4cb262abd 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,6 +3,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +* Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279)) ## [2.24.1] - 2022-08-10 ### Fixed From 0f296cba1479591dd75749fe234babe900a909b5 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Thu, 18 Aug 2022 22:01:26 -0700 Subject: [PATCH 3/5] Added missing `### Changes` where necessary. --- CHANGES.md | 1 + plugin-gradle/CHANGES.md | 1 - plugin-maven/CHANGES.md | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6e3ac85da7..9e00263a93 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Changes * Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279)) ## [2.28.1] - 2022-08-10 diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index cdb11f83da..72d600688c 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -3,7 +3,6 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`). ## [Unreleased] - ### Changes * Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279)) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index b4cb262abd..7366c3b731 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,6 +3,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] +### Changes * Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279)) ## [2.24.1] - 2022-08-10 From 640d8e7f77ec32f2c9fa8f2f7da6f5844ec2e658 Mon Sep 17 00:00:00 2001 From: Stephen Panaro Date: Fri, 19 Aug 2022 10:22:44 -0400 Subject: [PATCH 4/5] Add rule prefix to message --- .../com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b9b225f35d..e7af558fb5 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 @@ -111,7 +111,7 @@ 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.getRuleId() + "\n" + lint.getDetail()); + throw new AssertionError("Error on line: " + lint.getLine() + ", column: " + lint.getCol() + "\nrule: " + lint.getRuleId() + "\n" + lint.getDetail()); } return null; } From fc1da8d3fbf8a9095419cf1a66bf473516e85c3f Mon Sep 17 00:00:00 2001 From: Stephen Panaro Date: Fri, 19 Aug 2022 10:22:50 -0400 Subject: [PATCH 5/5] Fix tests --- .../test/java/com/diffplug/spotless/kotlin/KtLintStepTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testlib/src/test/java/com/diffplug/spotless/kotlin/KtLintStepTest.java b/testlib/src/test/java/com/diffplug/spotless/kotlin/KtLintStepTest.java index a4a43ef44e..d9e6042c23 100644 --- a/testlib/src/test/java/com/diffplug/spotless/kotlin/KtLintStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/kotlin/KtLintStepTest.java @@ -32,6 +32,7 @@ void behavior() throws Exception { .testResourceException("kotlin/ktlint/unsolvable.dirty", assertion -> { assertion.isInstanceOf(AssertionError.class); assertion.hasMessage("Error on line: 1, column: 1\n" + + "rule: no-wildcard-imports\n" + "Wildcard import"); }); } @@ -44,6 +45,7 @@ void worksPre0_46_1() throws Exception { .testResourceException("kotlin/ktlint/unsolvable.dirty", assertion -> { assertion.isInstanceOf(AssertionError.class); assertion.hasMessage("Error on line: 1, column: 1\n" + + "rule: no-wildcard-imports\n" + "Wildcard import"); }); }