-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ktlint 0.48 and bump default to 0.48.1 (#1456)
- Loading branch information
Showing
11 changed files
with
144 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0AdapterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright 2023 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.diffplug.spotless.glue.ktlint.compat; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
public class KtLintCompat0Dot48Dot0AdapterTest { | ||
@Test | ||
public void testDefaults(@TempDir Path path) throws IOException { | ||
KtLintCompat0Dot48Dot0Adapter ktLintCompat0Dot48Dot0Adapter = new KtLintCompat0Dot48Dot0Adapter(); | ||
String text = loadAndWriteText(path, "empty_class_body.kt"); | ||
|
||
Map<String, String> userData = new HashMap<>(); | ||
|
||
Map<String, Object> editorConfigOverrideMap = new HashMap<>(); | ||
|
||
String formatted = ktLintCompat0Dot48Dot0Adapter.format(text, "empty_class_body.kt", false, false, userData, editorConfigOverrideMap); | ||
assertEquals("class empty_class_body\n", formatted); | ||
} | ||
|
||
@Test | ||
public void testEditorConfigCanDisable(@TempDir Path path) throws IOException { | ||
KtLintCompat0Dot48Dot0Adapter ktLintCompat0Dot48Dot0Adapter = new KtLintCompat0Dot48Dot0Adapter(); | ||
String text = loadAndWriteText(path, "fails_no_semicolons.kt"); | ||
|
||
Map<String, String> userData = new HashMap<>(); | ||
|
||
Map<String, Object> editorConfigOverrideMap = new HashMap<>(); | ||
editorConfigOverrideMap.put("indent_style", "tab"); | ||
editorConfigOverrideMap.put("ktlint_standard_no-semi", "disabled"); | ||
|
||
String formatted = ktLintCompat0Dot48Dot0Adapter.format(text, "fails_no_semicolons.kt", false, false, userData, editorConfigOverrideMap); | ||
assertEquals("class fails_no_semicolons {\n\tval i = 0;\n}\n", formatted); | ||
} | ||
|
||
private static String loadAndWriteText(Path path, String name) throws IOException { | ||
try (InputStream is = KtLintCompat0Dot48Dot0AdapterTest.class.getResourceAsStream("/" + name)) { | ||
Files.copy(is, path.resolve(name)); | ||
} | ||
return new String(Files.readAllBytes(path.resolve(name)), StandardCharsets.UTF_8); | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
lib/src/testCompatKtLint0Dot48Dot0/resources/empty_class_body.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class empty_class_body { | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
lib/src/testCompatKtLint0Dot48Dot0/resources/fails_no_semicolons.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class fails_no_semicolons { | ||
val i = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters