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

Avoid changing newlines #1830

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import com.saveourtool.diktat.api.DiktatRuleSet
import com.saveourtool.diktat.ktlint.KtLintRuleWrapper.Companion.toKtLint
import com.pinterest.ktlint.rule.engine.api.Code
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults
import com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine
import com.pinterest.ktlint.rule.engine.api.LintError
import org.ec4j.core.model.EditorConfig
import org.ec4j.core.model.Glob
import org.ec4j.core.model.Property
import org.ec4j.core.model.PropertyType
import java.nio.file.Path

private typealias LintCallback = (LintError) -> Unit
Expand Down Expand Up @@ -41,7 +46,23 @@
}

companion object {
private fun DiktatRuleSet.toKtLintEngine(): KtLintRuleEngine = KtLintRuleEngine(ruleProviders = toKtLint())
private fun DiktatRuleSet.toKtLintEngine(): KtLintRuleEngine = KtLintRuleEngine(
ruleProviders = toKtLint(),

Check warning on line 50 in diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt

View check run for this annotation

Codecov / codecov/patch

diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt#L49-L50

Added lines #L49 - L50 were not covered by tests
// use platform dependent endlines in process of editing
editorConfigDefaults = EditorConfigDefaults(
nulls marked this conversation as resolved.
Show resolved Hide resolved
EditorConfig.builder()
.openSection()
.glob(Glob("**"))
.property(
Property.builder()
.name(PropertyType.end_of_line.name)
.type(PropertyType.end_of_line)

Check warning on line 59 in diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt

View check run for this annotation

Codecov / codecov/patch

diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt#L52-L59

Added lines #L52 - L59 were not covered by tests
.value(PropertyType.EndOfLineValue.ofEndOfLineString(System.lineSeparator())?.name)
)
.closeSection()
.build()

Check warning on line 63 in diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt

View check run for this annotation

Codecov / codecov/patch

diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt#L62-L63

Added lines #L62 - L63 were not covered by tests
)
)

Check warning on line 65 in diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt

View check run for this annotation

Codecov / codecov/patch

diktat-ktlint-engine/src/main/kotlin/com/saveourtool/diktat/ktlint/DiktatProcessorFactoryImpl.kt#L65

Added line #L65 was not covered by tests

private fun Path.toKtLint(): Code = Code.fromFile(this.toFile())

Expand Down
Loading