Skip to content

Commit 6d1e35d

Browse files
committed
bump diktat to 1.2.1 and add validation of min version
1 parent f6de4bb commit 6d1e35d

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1313
### Added
1414
* Support for `MAC_CLASSIC` (`\r`) line ending ([#1243](https://github.com/diffplug/spotless/pull/1243) fixes [#1196](https://github.com/diffplug/spotless/issues/1196))
1515
### Fixed
16-
* Bump default `diktat` version to latest `1.1.0` -> `1.2.0`. ([saveourtool/diktat#1399](https://github.com/saveourtool/diktat/issues/1399))
16+
* Bump default `diktat` version to latest `1.1.0` -> `1.2.1`. ([saveourtool/diktat#1399](https://github.com/saveourtool/diktat/issues/1399))
17+
* Note that support `diktat` version `1.2.1` is or higher
18+
* The property `userData` is removed
1719

1820
## [2.26.2] - 2022-06-11
1921
### Fixed

lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public class DiktatStep {
3030
// prevent direct instantiation
3131
private DiktatStep() {}
3232

33-
private static final String DEFAULT_VERSION = "1.2.0";
33+
private static final String MIN_SUPPORTED_VERSION = "1.2.1";
34+
35+
private static final String DEFAULT_VERSION = "1.2.1";
3436
static final String NAME = "diktat";
3537
static final String PACKAGE_DIKTAT = "org.cqfn.diktat";
3638
static final String MAVEN_COORDINATE = PACKAGE_DIKTAT + ":diktat-rules:";
@@ -56,6 +58,9 @@ public static FormatterStep createForScript(String versionDiktat, Provisioner pr
5658
}
5759

5860
public static FormatterStep create(String versionDiktat, Provisioner provisioner, boolean isScript, @Nullable FileSignature config) {
61+
if (BadSemver.version(versionDiktat) < BadSemver.version(MIN_SUPPORTED_VERSION)) {
62+
throw new IllegalStateException("Diktat supported for version " + MIN_SUPPORTED_VERSION + " and later");
63+
}
5964
Objects.requireNonNull(versionDiktat, "versionDiktat");
6065
Objects.requireNonNull(provisioner, "provisioner");
6166
return FormatterStep.createLazy(NAME,

plugin-gradle/CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
66
### Added
77
* Support for `MAC_CLASSIC` (`\r`) line ending ([#1243](https://github.com/diffplug/spotless/pull/1243) fixes [#1196](https://github.com/diffplug/spotless/issues/1196))
88
### Fixed
9-
* Bump default `diktat` version to latest `1.1.0` -> `1.2.0`. ([saveourtool/diktat#1399](https://github.com/saveourtool/diktat/issues/1399))
9+
* Bump default `diktat` version to latest `1.1.0` -> `1.2.1`. ([saveourtool/diktat#1399](https://github.com/saveourtool/diktat/issues/1399))
10+
* Note that support `diktat` version `1.2.1` is or higher
11+
* The property `userData` is removed
1012

1113
## [6.7.2] - 2022-06-11
1214
### Fixed

plugin-maven/CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
66
### Added
77
* Support for `MAC_CLASSIC` (`\r`) line ending ([#1243](https://github.com/diffplug/spotless/pull/1243) fixes [#1196](https://github.com/diffplug/spotless/issues/1196))
88
### Fixed
9-
* Bump default `diktat` version to latest `1.1.0` -> `1.2.0`. ([saveourtool/diktat#1399](https://github.com/saveourtool/diktat/issues/1399))
9+
* Bump default `diktat` version to latest `1.1.0` -> `1.2.1`. ([saveourtool/diktat#1399](https://github.com/saveourtool/diktat/issues/1399))
10+
* Note that support `diktat` version `1.2.1` is or higher
11+
* The property `userData` is removed
1012

1113
## [2.22.8] - 2022-06-11
1214
### Fixed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import static com.diffplug.spotless.FileSignature.signAsList;
1919

2020
import java.io.File;
21-
import java.util.Collections;
2221

22+
import org.junit.jupiter.api.Assertions;
2323
import org.junit.jupiter.api.Test;
2424

2525
import com.diffplug.spotless.FileSignature;
@@ -50,12 +50,11 @@ void behavior() throws Exception {
5050

5151
@Test
5252
void behaviorConf() throws Exception {
53-
5453
String configPath = "src/main/kotlin/diktat-analysis.yml";
5554
File conf = setFile(configPath).toResource("kotlin/diktat/diktat-analysis.yml");
5655
FileSignature config = signAsList(conf);
5756

58-
FormatterStep step = DiktatStep.create("1.2.0", TestProvisioner.mavenCentral(), config);
57+
FormatterStep step = DiktatStep.create("1.2.1", TestProvisioner.mavenCentral(), config);
5958
StepHarness.forStep(step)
6059
.testResourceException("kotlin/diktat/Unsolvable.kt", assertion -> {
6160
assertion.isInstanceOf(AssertionError.class);
@@ -71,4 +70,15 @@ void behaviorConf() throws Exception {
7170
});
7271
}
7372

73+
@Test
74+
void notSupportedVersion() {
75+
final IllegalStateException notSupportedException = Assertions.assertThrows(IllegalStateException.class,
76+
() -> DiktatStep.create("1.2.0", TestProvisioner.mavenCentral()));
77+
Assertions.assertTrue(
78+
notSupportedException.getMessage().contains("Diktat supported for version 1.2.1 and later")
79+
);
80+
81+
Assertions.assertDoesNotThrow(() -> DiktatStep.create("1.2.1", TestProvisioner.mavenCentral()));
82+
Assertions.assertDoesNotThrow(() -> DiktatStep.create("2.0.0", TestProvisioner.mavenCentral()));
83+
}
7484
}

0 commit comments

Comments
 (0)