Skip to content
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

Let API Consumer decide whether a LintError has to be autocorrected, or not #2671

Merged
merged 33 commits into from
May 28, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9b57c23
Add RuleAutocorrectApproveHandler interface
paul-dingemans May 15, 2024
dbb21c5
Extract CodeLinter and CodeFormatter from KtLintRuleEngine
paul-dingemans May 18, 2024
8710723
Make interactiveFormat actually work
paul-dingemans May 19, 2024
faef0a4
Simplifly SuppressHandler
paul-dingemans May 19, 2024
a930246
Update api contract
paul-dingemans May 19, 2024
8187494
Refactor and remove SuppressHandler
paul-dingemans May 19, 2024
358087d
Refactor AutoCorrectOffsetRangeHandler to RangeAutoCorrectHandler so …
paul-dingemans May 19, 2024
f27e4ff
Disable autocorrect in rules that do not implement the RuleApproveAut…
paul-dingemans May 22, 2024
b5cc08b
Ensure backward compatibility by adding parameter used to set the def…
paul-dingemans May 23, 2024
8084c01
Add FormatDecision as return result from callback used in format func…
paul-dingemans May 23, 2024
38f27d2
Update documentation
paul-dingemans May 24, 2024
998bc31
Refactor FormatDecision to AutocorrectDecision
paul-dingemans May 24, 2024
c8c9f51
Update ktlint-api-consumer
paul-dingemans May 25, 2024
913d259
Fix all rules
paul-dingemans May 25, 2024
171e9d2
Fix "cannot be auto-corrected" in lint error log
paul-dingemans May 26, 2024
1db5cae
Use new format function in ktlint CLI
paul-dingemans May 26, 2024
4b3c5ea
Rename variable
paul-dingemans May 26, 2024
fe6e0fd
Fix documentation
paul-dingemans May 26, 2024
a89d9ab
Add deprecation notice
paul-dingemans May 26, 2024
10c2236
Improve API documentation
paul-dingemans May 26, 2024
8aa7bf0
Update API contract
paul-dingemans May 26, 2024
a54218e
Update documentation
paul-dingemans May 27, 2024
c3504d0
Remove CodeLinter
paul-dingemans May 27, 2024
dede1d4
Update log message
paul-dingemans May 28, 2024
22b0efc
Inline extension methods
paul-dingemans May 28, 2024
ec0b87f
Rename methods
paul-dingemans May 28, 2024
004c7a7
Try to fix test on Windows
paul-dingemans May 28, 2024
9363bda
Try to fix test on Windows
paul-dingemans May 28, 2024
78cb2d8
Replace call to deprecated "format", except the one that need to test…
paul-dingemans May 28, 2024
036fcbb
Try to fix test Windows OS
paul-dingemans May 28, 2024
f9f7847
Try to fix test Windows OS
paul-dingemans May 28, 2024
ab72b63
Try to fix test Windows OS
paul-dingemans May 28, 2024
3460464
Try to fix test Windows OS
paul-dingemans May 28, 2024
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
Prev Previous commit
Next Next commit
Try to fix test Windows OS
Closes #2658
  • Loading branch information
paul-dingemans committed May 28, 2024
commit f9f7847268c47790ee8ec7549bf39a829911e754
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.pinterest.ktlint.rule.engine.core.api.editorconfig.END_OF_LINE_PROPER
import com.pinterest.ktlint.rule.engine.core.api.editorconfig.EditorConfig
import com.pinterest.ktlint.rule.engine.core.api.ifAutocorrectAllowed
import com.pinterest.ktlint.rule.engine.core.api.isRoot
import io.github.oshai.kotlinlogging.KotlinLogging
import org.assertj.core.api.Assertions.assertThat
import org.ec4j.core.model.PropertyType
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
Expand All @@ -36,6 +37,8 @@ import org.jetbrains.kotlin.com.intellij.psi.tree.IElementType
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test

private val LOGGER = KotlinLogging.logger {}.initKtLintKLogger()

class KtLintTest {
/**
* API Consumers directly use the ktlint-rule-engine module. Tests in this module should guarantee that the API is kept stable.
Expand Down Expand Up @@ -292,7 +295,20 @@ class KtLintTest {

@Test
fun testFormatUnicodeBom() {
val code = getResourceAsText("spec/format-unicode-bom.kt.spec")
val originalCode =
getResourceAsText("spec/format-unicode-bom.kt.spec")
val code =
originalCode
.replace("\r\n", "\n")
.replace("\r", "\n")
if (code != originalCode) {
LOGGER.debug {
"""
Original code: ${originalCode.toByteArray()}
Changed code : ${code.toByteArray()}
""".trimIndent()
}
}

val actual =
KtLintRuleEngine(
Expand Down
Loading