Skip to content

Bump Ktlint to 1.0.1 #1855

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

Merged
merged 2 commits into from
Nov 2, 2023
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]
### Changes
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))

## [2.42.0] - 2023-09-28
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class KtLintStep {
// prevent direct instantiation
private KtLintStep() {}

private static final String DEFAULT_VERSION = "1.0.0";
private static final String DEFAULT_VERSION = "1.0.1";
static final String NAME = "ktlint";
static final String MAVEN_COORDINATE_0_DOT = "com.pinterest:ktlint:";
static final String MAVEN_COORDINATE_1_DOT = "com.pinterest.ktlint:ktlint-cli:";
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]
### Changes
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))

## [6.22.0] - 2023-09-28
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,42 @@ void testWithInvalidEditorConfigFile() throws IOException {
assertThat(buildOutput).contains(invalidPath);
}

@Test
void testReadCodeStyleFromEditorConfigFile() throws IOException {
setFile(".editorconfig").toResource("kotlin/ktlint/ktlint_official/.editorconfig");
setFile("build.gradle").toLines(
"plugins {",
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
"spotless {",
" kotlin {",
" ktlint()",
" }",
"}");
checkKtlintOfficialStyle();
}

@Test
void testSetEditorConfigCanOverrideEditorConfigFile() throws IOException {
setFile(".editorconfig").toResource("kotlin/ktlint/intellij_idea/.editorconfig");
setFile("build.gradle").toLines(
"plugins {",
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
" id 'com.diffplug.spotless'",
"}",
"repositories { mavenCentral() }",
"spotless {",
" kotlin {",
" ktlint().editorConfigOverride([",
" ktlint_code_style: \"ktlint_official\",",
" ])",
" }",
"}");
checkKtlintOfficialStyle();
}

@Test
void testWithHeader() throws IOException {
setFile("build.gradle").toLines(
Expand Down Expand Up @@ -144,4 +180,11 @@ void testWithCustomMaxWidthDefaultStyleKtfmt() throws IOException {
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/max-width.kt").sameAsResource("kotlin/ktfmt/max-width.clean");
}

private void checkKtlintOfficialStyle() throws IOException {
String path = "src/main/kotlin/Main.kt";
setFile(path).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty");
gradleRunner().withArguments("spotlessApply").build();
assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.ktlintOfficial.clean");
}
}
2 changes: 2 additions & 0 deletions plugin-maven/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 `1.27.0`).

## [Unreleased]
### Changes
* Bump default `ktlint` version to latest `1.0.0` -> `1.0.1`. ([#1855](https://github.com/diffplug/spotless/pull/1855))

### Added
* CompileSourceRoots and TestCompileSourceRoots are now respected as default includes. These properties are commonly set when adding extra source directories. ([#1846](https://github.com/diffplug/spotless/issues/1846))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,29 @@ void testKtlintEditorConfigOverride() throws Exception {
mavenRunner().withArguments("spotless:apply").runNoError();
assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.clean");
}

@Test
void testReadCodeStyleFromEditorConfigFile() throws Exception {
setFile(".editorconfig").toResource("kotlin/ktlint/ktlint_official/.editorconfig");
writePomWithKotlinSteps("<ktlint/>");
checkKtlintOfficialStyle();
}

@Test
void testSetEditorConfigCanOverrideEditorConfigFile() throws Exception {
setFile(".editorconfig").toResource("kotlin/ktlint/intellij_idea/.editorconfig");
writePomWithKotlinSteps("<ktlint>\n" +
" <editorConfigOverride>\n" +
" <ktlint_code_style>ktlint_official</ktlint_code_style>\n" +
" </editorConfigOverride>\n" +
"</ktlint>");
checkKtlintOfficialStyle();
}

private void checkKtlintOfficialStyle() throws Exception {
String path = "src/main/kotlin/Main.kt";
setFile(path).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty");
mavenRunner().withArguments("spotless:apply").runNoError();
assertFile(path).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.ktlintOfficial.clean");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fun main() {
val list =
listOf(
"hello",
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
root = true

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ktlint_code_style = intellij_idea
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
root = true

[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ktlint_code_style = ktlint_official