Skip to content

Commit

Permalink
Bump Ktlint to 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Oct 14, 2023
1 parent d346ef8 commit 32d2559
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 16 deletions.
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`. ([#1808](https://github.com/diffplug/spotless/pull/1855))

## [2.42.0] - 2023-09-28
### Added
Expand Down
8 changes: 4 additions & 4 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ versionCompatibility {
'0.48.0',
'0.49.0',
'0.50.0',
'1.0.0',
'1.0.1',
]
targetSourceSetName = 'ktlint'
}
Expand Down Expand Up @@ -110,9 +110,9 @@ dependencies {
compatKtLint0Dot50Dot0CompileAndTestOnly 'com.pinterest.ktlint:ktlint-ruleset-standard:0.50.0'
compatKtLint0Dot50Dot0CompileAndTestOnly 'org.slf4j:slf4j-api:2.0.0'
// ktlint latest supported version
compatKtLint1Dot0Dot0CompileAndTestOnly 'com.pinterest.ktlint:ktlint-rule-engine:1.0.0'
compatKtLint1Dot0Dot0CompileAndTestOnly 'com.pinterest.ktlint:ktlint-ruleset-standard:1.0.0'
compatKtLint1Dot0Dot0CompileAndTestOnly 'org.slf4j:slf4j-api:2.0.0'
compatKtLint1Dot0Dot1CompileAndTestOnly 'com.pinterest.ktlint:ktlint-rule-engine:1.0.1'
compatKtLint1Dot0Dot1CompileAndTestOnly 'com.pinterest.ktlint:ktlint-ruleset-standard:1.0.1'
compatKtLint1Dot0Dot1CompileAndTestOnly 'org.slf4j:slf4j-api:2.0.0'
// palantirJavaFormat
palantirJavaFormatCompileOnly 'com.palantir.javaformat:palantir-java-format:1.1.0' // this version needs to stay compilable against Java 8 for CI Job testNpm
// scalafmt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
import kotlin.Unit;
import kotlin.jvm.functions.Function2;

public class KtLintCompat1Dot0Dot0Adapter implements KtLintCompatAdapter {
public class KtLintCompat1Dot0Dot1Adapter implements KtLintCompatAdapter {

private static final Logger logger = LoggerFactory.getLogger(KtLintCompat1Dot0Dot0Adapter.class);
private static final Logger logger = LoggerFactory.getLogger(KtLintCompat1Dot0Dot1Adapter.class);

private static final List<EditorConfigProperty<?>> DEFAULT_EDITOR_CONFIG_PROPERTIES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public KtlintFormatterFunc(String version, boolean isScript, FileSignature edito
int majorVersion = Integer.parseInt(versions[0]);
int minorVersion = Integer.parseInt(versions[1]);
if (majorVersion == 1) {
this.adapter = new KtLintCompat1Dot0Dot0Adapter();
this.adapter = new KtLintCompat1Dot0Dot1Adapter();
} else {
if (minorVersion >= 50) {
// Fixed `RuleId` and `RuleSetId` issues
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class KtLintCompat1Dot0Dot0AdapterTest {
public class KtLintCompat1Dot0Dot1AdapterTest {
@Test
public void testDefaults(@TempDir Path path) throws IOException {
KtLintCompat1Dot0Dot0Adapter KtLintCompat1Dot0Dot0Adapter = new KtLintCompat1Dot0Dot0Adapter();
KtLintCompat1Dot0Dot1Adapter KtLintCompat1Dot0Dot1Adapter = new KtLintCompat1Dot0Dot1Adapter();
String text = loadAndWriteText(path, "EmptyClassBody.kt");
final Path filePath = Paths.get(path.toString(), "EmptyClassBody.kt");

Map<String, String> userData = new HashMap<>();

Map<String, Object> editorConfigOverrideMap = new HashMap<>();

String formatted = KtLintCompat1Dot0Dot0Adapter.format(text, filePath, false, null, userData, editorConfigOverrideMap);
String formatted = KtLintCompat1Dot0Dot1Adapter.format(text, filePath, false, null, userData, editorConfigOverrideMap);
assertEquals("class EmptyClassBody\n", formatted);
}

@Test
public void testEditorConfigCanDisable(@TempDir Path path) throws IOException {
KtLintCompat1Dot0Dot0Adapter KtLintCompat1Dot0Dot0Adapter = new KtLintCompat1Dot0Dot0Adapter();
KtLintCompat1Dot0Dot1Adapter KtLintCompat1Dot0Dot1Adapter = new KtLintCompat1Dot0Dot1Adapter();
String text = loadAndWriteText(path, "FailsNoSemicolons.kt");
final Path filePath = Paths.get(path.toString(), "FailsNoSemicolons.kt");

Expand All @@ -56,12 +56,12 @@ public void testEditorConfigCanDisable(@TempDir Path path) throws IOException {
editorConfigOverrideMap.put("indent_style", "tab");
editorConfigOverrideMap.put("ktlint_standard_no-semi", "disabled");

String formatted = KtLintCompat1Dot0Dot0Adapter.format(text, filePath, false, null, userData, editorConfigOverrideMap);
String formatted = KtLintCompat1Dot0Dot1Adapter.format(text, filePath, false, null, userData, editorConfigOverrideMap);
assertEquals("class FailsNoSemicolons {\n\tval i = 0;\n}\n", formatted);
}

private static String loadAndWriteText(Path path, String name) throws IOException {
try (InputStream is = KtLintCompat1Dot0Dot0AdapterTest.class.getResourceAsStream("/" + name)) {
try (InputStream is = KtLintCompat1Dot0Dot1AdapterTest.class.getResourceAsStream("/" + name)) {
Files.copy(is, path.resolve(name));
}
return new String(Files.readAllBytes(path.resolve(name)), StandardCharsets.UTF_8);
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`. ([#1808](https://github.com/diffplug/spotless/pull/1855))

## [6.22.0] - 2023-09-28
### Added
Expand Down
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`. ([#1808](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 @@ -75,8 +75,8 @@ void works0_50_0() {
}

@Test
void works1_0_0() {
FormatterStep step = KtLintStep.create("1.0.0", TestProvisioner.mavenCentral());
void works1_0_1() {
FormatterStep step = KtLintStep.create("1.0.1", TestProvisioner.mavenCentral());
StepHarnessWithFile.forStep(this, step)
.testResource("kotlin/ktlint/basic.dirty", "kotlin/ktlint/basic.clean")
.testResourceExceptionMsg("kotlin/ktlint/unsolvable.dirty").isEqualTo("Error on line: 1, column: 1\n" +
Expand Down

0 comments on commit 32d2559

Please sign in to comment.