-
Notifications
You must be signed in to change notification settings - Fork 464
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 ktlint 0.48 #1456
Merged
+144
−14
Merged
Fix ktlint 0.48 #1456
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6dc01fa
Fix ktlint 0.48
Sineaggi 4550b66
Add change to changelog
Sineaggi 2936d3c
Add link to issue in changelog
Sineaggi 41c3fe9
Update all change logs
Sineaggi 954e6b5
Run spotless
Sineaggi 1a19da1
Use older format function that doesn't load .editorconfig
Sineaggi 11971ab
Fix UTF-8 encoder errors
Sineaggi b853169
Remove org.gradle settings
Sineaggi b6e9073
Change back to 0.48.0
Sineaggi 6b2e2c3
Use testCommonImplementation configuration
Sineaggi 778f485
Use latest version-compatibility plugin
Sineaggi 3409754
Factor out helper method
Sineaggi 2eebed3
Merge branch 'main' into fix-ktlint-48
nedtwigg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good (other than also being required) :)