diff --git a/CHANGES.md b/CHANGES.md
index 5079d324b1..81b82eaa61 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -10,6 +10,8 @@ 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]
+### Changed
+* 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.
## [2.21.0] - 2021-12-23
### Added
diff --git a/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java b/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java
index 4af23f5559..7f5779cce6 100644
--- a/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java
+++ b/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 DiffPlug
+ * Copyright 2021-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class DiktatStep {
// prevent direct instantiation
private DiktatStep() {}
- private static final String DEFAULT_VERSION = "0.4.0";
+ private static final String DEFAULT_VERSION = "1.0.1";
static final String NAME = "diktat";
static final String PACKAGE_DIKTAT = "org.cqfn.diktat";
static final String PACKAGE_KTLINT = "com.pinterest.ktlint";
diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md
index edb083e692..3b3d35f451 100644
--- a/plugin-gradle/CHANGES.md
+++ b/plugin-gradle/CHANGES.md
@@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
## [Unreleased]
+### Changed
+* 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.
## [6.1.0] - 2021-12-23
### Added
diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java
index 566454527e..c68de0d7e7 100644
--- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java
+++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2021 DiffPlug
+ * Copyright 2016-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,8 +90,7 @@ void integration_default_diktat() throws IOException {
"}");
setFile("configuration.gradle.kts").toResource("kotlin/diktat/basic.dirty");
BuildResult result = gradleRunner().withArguments("spotlessApply").buildAndFail();
- assertThat(result.getOutput()).contains("[HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE] files that contain multiple "
- + "or no classes should contain description of what is inside of this file: there are 0 declared classes and/or objects");
+ assertThat(result.getOutput()).contains("[AVOID_NESTED_FUNCTIONS] try to avoid using nested functions");
}
@Test
diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md
index 800df98dd3..6c95cadc35 100644
--- a/plugin-maven/CHANGES.md
+++ b/plugin-maven/CHANGES.md
@@ -11,6 +11,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
* `src/main/java/**/*.java`
* `src/test/java/**/*.java`
* This release removes the `.java` includes.
+### Changed
+* 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.
## [2.18.0] - 2021-12-23
### Added
diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java
index a79cff3f8d..bd37c5c82e 100644
--- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java
+++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/DiktatTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 DiffPlug
+ * Copyright 2021-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,10 @@ void testDiktat() throws Exception {
@Test
void testDiktatWithVersion() throws Exception {
- writePomWithKotlinSteps("0.4.0");
+ writePomWithKotlinSteps(
+ "",
+ " 1.0.1",
+ "");
String path = "src/main/kotlin/Main.kt";
setFile(path).toResource("kotlin/diktat/main.dirty");
@@ -51,7 +54,11 @@ void testDiktatConfig() throws Exception {
String configPath = "src/main/kotlin/diktat-analysis.yml";
File conf = setFile(configPath).toResource("kotlin/diktat/diktat-analysis.yml");
- writePomWithKotlinSteps("0.4.0" + conf.getAbsolutePath() + "");
+ writePomWithKotlinSteps(
+ "",
+ " 1.0.1",
+ " " + conf.getAbsolutePath() + "",
+ "");
String path = "src/main/kotlin/Main.kt";
setFile(path).toResource("kotlin/diktat/main.dirty");
diff --git a/testlib/src/main/resources/kotlin/diktat/diktat-analysis.yml b/testlib/src/main/resources/kotlin/diktat/diktat-analysis.yml
index 8c88553907..550de716ef 100644
--- a/testlib/src/main/resources/kotlin/diktat/diktat-analysis.yml
+++ b/testlib/src/main/resources/kotlin/diktat/diktat-analysis.yml
@@ -75,13 +75,6 @@
enabled: 'true'
- name: HEADER_WRONG_FORMAT
enabled: true
-- name: HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE
- enabled: true
-- name: HEADER_MISSING_OR_WRONG_COPYRIGHT
- enabled: true
- configuration:
- isCopyrightMandatory: false
- copyrightText: 'Copyright (c) Your Company Name Here. 2010-2021'
- name: HEADER_NOT_BEFORE_PACKAGE
enabled: true
- name: FILE_IS_TOO_LONG
@@ -182,7 +175,7 @@
- name: WRONG_NEWLINES_AROUND_KDOC
enabled: true
# Inspection that checks if there is no blank lines before first comment
-- name: FIRST_COMMENT_NO_SPACES
+- name: FIRST_COMMENT_NO_BLANK_LINE
enabled: true
# Inspection that checks if there are blank lines between code and comment and between code start token and comment's text
- name: COMMENT_WHITE_SPACE
diff --git a/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java b/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java
index 3637b0ccbc..137937beb9 100644
--- a/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java
+++ b/testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2021 DiffPlug
+ * Copyright 2016-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,9 @@
import java.io.File;
import java.io.IOException;
+import java.time.LocalDate;
import java.time.YearMonth;
+import java.time.ZoneOffset;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -227,10 +229,11 @@ void should_apply_license_containing_YEAR_token_in_range() throws Throwable {
@Test
void should_update_year_for_license_with_address() throws Throwable {
+ int currentYear = LocalDate.now(ZoneOffset.UTC).getYear();
FormatterStep step = LicenseHeaderStep.headerDelimiter(header(licenceWithAddress()), package_).withYearMode(YearMode.UPDATE_TO_TODAY).build();
StepHarness.forStep(step).test(
hasHeader(licenceWithAddress().replace("$YEAR", "2015")),
- hasHeader(licenceWithAddress().replace("$YEAR", "2015-2021")));
+ hasHeader(licenceWithAddress().replace("$YEAR", "2015-" + currentYear)));
}
@Test
diff --git a/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java b/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java
index 6a4928c6b7..040a23d0a8 100644
--- a/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java
+++ b/testlib/src/test/java/com/diffplug/spotless/kotlin/DiktatStepTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 DiffPlug
+ * Copyright 2021-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,9 +38,9 @@ void behavior() throws Exception {
assertion.isInstanceOf(AssertionError.class);
assertion.hasMessage("There are 2 unfixed errors:" +
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
- System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: testlib" +
+ System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: " +
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
- 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");
+ 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");
});
}
@@ -51,15 +51,15 @@ void behaviorConf() throws Exception {
File conf = setFile(configPath).toResource("kotlin/diktat/diktat-analysis.yml");
FileSignature config = signAsList(conf);
- FormatterStep step = DiktatStep.create("0.3.0", TestProvisioner.mavenCentral(), Collections.emptyMap(), config);
+ FormatterStep step = DiktatStep.create("1.0.1", TestProvisioner.mavenCentral(), Collections.emptyMap(), config);
StepHarness.forStep(step)
.testResourceException("kotlin/diktat/Unsolvable.kt", assertion -> {
assertion.isInstanceOf(AssertionError.class);
assertion.hasMessage("There are 2 unfixed errors:" +
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
- System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: testlib" +
+ System.lineSeparator() + "[FILE_NAME_INCORRECT] file name is incorrect - it should end with .kt extension and be in PascalCase: " +
System.lineSeparator() + "Error on line: 1, column: 1 cannot be fixed automatically" +
- 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");
+ 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");
});
}