Skip to content

Commit 99950e7

Browse files
authored
Add ktlint rule ID in formatter callback exception (#1279)
2 parents b535dce + 85e7cd3 commit 99950e7

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This document is intended for Spotless developers.
1010
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
1111

1212
## [Unreleased]
13+
### Changes
14+
* Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279))
1315

1416
## [2.28.1] - 2022-08-10
1517
### Fixed

lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static class FormatterCallback implements Function2<LintError, Boolean, Unit> {
111111
@Override
112112
public Unit invoke(LintError lint, Boolean corrected) {
113113
if (!corrected) {
114-
throw new AssertionError("Error on line: " + lint.getLine() + ", column: " + lint.getCol() + "\n" + lint.getDetail());
114+
throw new AssertionError("Error on line: " + lint.getLine() + ", column: " + lint.getCol() + "\nrule: " + lint.getRuleId() + "\n" + lint.getDetail());
115115
}
116116
return null;
117117
}

plugin-gradle/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Changes
7+
* Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279))
68

79
## [6.9.1] - 2022-08-10
810
### Fixed

plugin-maven/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
44

55
## [Unreleased]
6+
### Changes
7+
* Add the `ktlint` rule in error messages when `ktlint` fails to apply a fix ([#1279](https://github.com/diffplug/spotless/pull/1279))
68

79
## [2.24.1] - 2022-08-10
810
### Fixed

testlib/src/test/java/com/diffplug/spotless/kotlin/KtLintStepTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void behavior() throws Exception {
3232
.testResourceException("kotlin/ktlint/unsolvable.dirty", assertion -> {
3333
assertion.isInstanceOf(AssertionError.class);
3434
assertion.hasMessage("Error on line: 1, column: 1\n" +
35+
"rule: no-wildcard-imports\n" +
3536
"Wildcard import");
3637
});
3738
}
@@ -44,6 +45,7 @@ void worksPre0_46_1() throws Exception {
4445
.testResourceException("kotlin/ktlint/unsolvable.dirty", assertion -> {
4546
assertion.isInstanceOf(AssertionError.class);
4647
assertion.hasMessage("Error on line: 1, column: 1\n" +
48+
"rule: no-wildcard-imports\n" +
4749
"Wildcard import");
4850
});
4951
}

0 commit comments

Comments
 (0)