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 1 commit
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,22 @@
}

companion object {
private fun DiktatRuleSet.toKtLintEngine(): KtLintRuleEngine = KtLintRuleEngine(ruleProviders = toKtLint())
private fun DiktatRuleSet.toKtLintEngine(): KtLintRuleEngine = KtLintRuleEngine(
ruleProviders = toKtLint(),
editorConfigDefaults = EditorConfigDefaults(
nulls marked this conversation as resolved.
Show resolved Hide resolved
EditorConfig.builder()
.openSection()
.glob(Glob("**"))
Fixed Show fixed Hide fixed
.property(
Fixed Show fixed Hide fixed
Property.builder()
Fixed Show fixed Hide fixed
.name(PropertyType.end_of_line.name)
.type(PropertyType.end_of_line)

Check warning on line 58 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-L58

Added lines #L49 - L58 were not covered by tests
.value(PropertyType.EndOfLineValue.ofEndOfLineString(System.lineSeparator())?.name)
)
Fixed Show fixed Hide fixed
.closeSection()
Fixed Show fixed Hide fixed
.build()

Check warning on line 62 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#L61-L62

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

Check warning on line 64 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#L64

Added line #L64 was not covered by tests

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

Expand Down
Loading