Skip to content

Commit

Permalink
Bump Ktlint to 1.0.1 (#1855)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Nov 2, 2023
2 parents 68e2139 + 87537c0 commit 1b0d489
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 1 deletion.
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

0 comments on commit 1b0d489

Please sign in to comment.