Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build failures caused by the New Year #1066

Merged
merged 6 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -38,7 +38,10 @@ void testDiktat() throws Exception {
@Test
void testDiktatWithVersion() throws Exception {

writePomWithKotlinSteps("<diktat><version>0.4.0</version></diktat>");
writePomWithKotlinSteps(
"<diktat>",
" <version>1.0.1</version>",
"</diktat>");

String path = "src/main/kotlin/Main.kt";
setFile(path).toResource("kotlin/diktat/main.dirty");
Expand All @@ -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("<diktat><version>0.4.0</version><configFile>" + conf.getAbsolutePath() + "</configFile></diktat>");
writePomWithKotlinSteps(
"<diktat>",
" <version>1.0.1</version>",
" <configFile>" + conf.getAbsolutePath() + "</configFile>",
"</diktat>");

String path = "src/main/kotlin/Main.kt";
setFile(path).toResource("kotlin/diktat/main.dirty");
Expand Down
9 changes: 1 addition & 8 deletions testlib/src/main/resources/kotlin/diktat/diktat-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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");
});
}

Expand All @@ -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");
});
}

Expand Down