Skip to content

Commit 466a7db

Browse files
authored
Bump default DiKTat 0.4.0 -> 1.0.1 to fix build failures caused by 2022 (#1066)
2 parents a749928 + a78e396 commit 466a7db

File tree

9 files changed

+32
-24
lines changed

9 files changed

+32
-24
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
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+
### Changed
14+
* Bumped default DiKTat from `0.4.0` to `1.0.1`. This is a breaking change for DiKTat users on the default version, because some rules were renamed/changed. Check [DiKTat changelog](https://github.com/analysis-dev/diktat/releases) for details.
1315

1416
## [2.21.0] - 2021-12-23
1517
### Added

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class DiktatStep {
3333
// prevent direct instantiation
3434
private DiktatStep() {}
3535

36-
private static final String DEFAULT_VERSION = "0.4.0";
36+
private static final String DEFAULT_VERSION = "1.0.1";
3737
static final String NAME = "diktat";
3838
static final String PACKAGE_DIKTAT = "org.cqfn.diktat";
3939
static final String PACKAGE_KTLINT = "com.pinterest.ktlint";

plugin-gradle/CHANGES.md

Lines changed: 2 additions & 0 deletions
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+
### Changed
7+
* Bumped default DiKTat from `0.4.0` to `1.0.1`. This is a breaking change for DiKTat users on the default version, because some rules were renamed/changed. Check [DiKTat changelog](https://github.com/analysis-dev/diktat/releases) for details.
68

79
## [6.1.0] - 2021-12-23
810
### Added

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -90,8 +90,7 @@ void integration_default_diktat() throws IOException {
9090
"}");
9191
setFile("configuration.gradle.kts").toResource("kotlin/diktat/basic.dirty");
9292
BuildResult result = gradleRunner().withArguments("spotlessApply").buildAndFail();
93-
assertThat(result.getOutput()).contains("[HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE] files that contain multiple "
94-
+ "or no classes should contain description of what is inside of this file: there are 0 declared classes and/or objects");
93+
assertThat(result.getOutput()).contains("[AVOID_NESTED_FUNCTIONS] try to avoid using nested functions");
9594
}
9695

9796
@Test

plugin-maven/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1111
* `src/main/java/**/*.java`
1212
* `src/test/java/**/*.java`
1313
* This release removes the `.java` includes.
14+
### Changed
15+
* Bumped default DiKTat from `0.4.0` to `1.0.1`. This is a breaking change for DiKTat users on the default version, because some rules were renamed/changed. Check [DiKTat changelog](https://github.com/analysis-dev/diktat/releases) for details.
1416

1517
## [2.18.0] - 2021-12-23
1618
### Added

plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,10 @@ void testDiktat() throws Exception {
3838
@Test
3939
void testDiktatWithVersion() throws Exception {
4040

41-
writePomWithKotlinSteps("<diktat><version>0.4.0</version></diktat>");
41+
writePomWithKotlinSteps(
42+
"<diktat>",
43+
" <version>1.0.1</version>",
44+
"</diktat>");
4245

4346
String path = "src/main/kotlin/Main.kt";
4447
setFile(path).toResource("kotlin/diktat/main.dirty");
@@ -51,7 +54,11 @@ void testDiktatConfig() throws Exception {
5154

5255
String configPath = "src/main/kotlin/diktat-analysis.yml";
5356
File conf = setFile(configPath).toResource("kotlin/diktat/diktat-analysis.yml");
54-
writePomWithKotlinSteps("<diktat><version>0.4.0</version><configFile>" + conf.getAbsolutePath() + "</configFile></diktat>");
57+
writePomWithKotlinSteps(
58+
"<diktat>",
59+
" <version>1.0.1</version>",
60+
" <configFile>" + conf.getAbsolutePath() + "</configFile>",
61+
"</diktat>");
5562

5663
String path = "src/main/kotlin/Main.kt";
5764
setFile(path).toResource("kotlin/diktat/main.dirty");

testlib/src/main/resources/kotlin/diktat/diktat-analysis.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@
7575
enabled: 'true'
7676
- name: HEADER_WRONG_FORMAT
7777
enabled: true
78-
- name: HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE
79-
enabled: true
80-
- name: HEADER_MISSING_OR_WRONG_COPYRIGHT
81-
enabled: true
82-
configuration:
83-
isCopyrightMandatory: false
84-
copyrightText: 'Copyright (c) Your Company Name Here. 2010-2021'
8578
- name: HEADER_NOT_BEFORE_PACKAGE
8679
enabled: true
8780
- name: FILE_IS_TOO_LONG
@@ -182,7 +175,7 @@
182175
- name: WRONG_NEWLINES_AROUND_KDOC
183176
enabled: true
184177
# Inspection that checks if there is no blank lines before first comment
185-
- name: FIRST_COMMENT_NO_SPACES
178+
- name: FIRST_COMMENT_NO_BLANK_LINE
186179
enabled: true
187180
# Inspection that checks if there are blank lines between code and comment and between code start token and comment's text
188181
- name: COMMENT_WHITE_SPACE

testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,9 @@
1717

1818
import java.io.File;
1919
import java.io.IOException;
20+
import java.time.LocalDate;
2021
import java.time.YearMonth;
22+
import java.time.ZoneOffset;
2123

2224
import org.junit.jupiter.api.Assertions;
2325
import org.junit.jupiter.api.Test;
@@ -227,10 +229,11 @@ void should_apply_license_containing_YEAR_token_in_range() throws Throwable {
227229

228230
@Test
229231
void should_update_year_for_license_with_address() throws Throwable {
232+
int currentYear = LocalDate.now(ZoneOffset.UTC).getYear();
230233
FormatterStep step = LicenseHeaderStep.headerDelimiter(header(licenceWithAddress()), package_).withYearMode(YearMode.UPDATE_TO_TODAY).build();
231234
StepHarness.forStep(step).test(
232235
hasHeader(licenceWithAddress().replace("$YEAR", "2015")),
233-
hasHeader(licenceWithAddress().replace("$YEAR", "2015-2021")));
236+
hasHeader(licenceWithAddress().replace("$YEAR", "2015-" + currentYear)));
234237
}
235238

236239
@Test

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2022 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,9 +38,9 @@ void behavior() throws Exception {
3838
assertion.isInstanceOf(AssertionError.class);
3939
assertion.hasMessage("There are 2 unfixed errors:" +
4040
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
41-
System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: testlib" +
41+
System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: " +
4242
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
43-
System.lineSeparator() + "[FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: testlib vs Unsolvable");
43+
System.lineSeparator() + "[FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: vs Unsolvable");
4444
});
4545
}
4646

@@ -51,15 +51,15 @@ void behaviorConf() throws Exception {
5151
File conf = setFile(configPath).toResource("kotlin/diktat/diktat-analysis.yml");
5252
FileSignature config = signAsList(conf);
5353

54-
FormatterStep step = DiktatStep.create("0.3.0", TestProvisioner.mavenCentral(), Collections.emptyMap(), config);
54+
FormatterStep step = DiktatStep.create("1.0.1", TestProvisioner.mavenCentral(), Collections.emptyMap(), config);
5555
StepHarness.forStep(step)
5656
.testResourceException("kotlin/diktat/Unsolvable.kt", assertion -> {
5757
assertion.isInstanceOf(AssertionError.class);
5858
assertion.hasMessage("There are 2 unfixed errors:" +
5959
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
60-
System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: testlib" +
60+
System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: " +
6161
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
62-
System.lineSeparator() + "[FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: testlib vs Unsolvable");
62+
System.lineSeparator() + "[FILE_NAME_MATCH_CLASS] file name is incorrect - it should match with the class described in it if there is the only one class declared: vs Unsolvable");
6363
});
6464
}
6565

0 commit comments

Comments
 (0)