Skip to content

Commit

Permalink
Ktlint 0.43.0
Browse files Browse the repository at this point in the history
### What's done:
* Forbid usage of absolute paths in diktat-gradle-plugin
  • Loading branch information
petertrr committed Nov 8, 2021
1 parent 319864a commit 16acb24
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ open class DiktatJavaExecTaskBase @Inject constructor(
} else {
main = "com.pinterest.ktlint.Main"
}
require(diktatExtension.inputs.none { it.isAbsolute }) {
"Absolute paths are not supported for inputs in diktat-gradle-plugin"
}
require(diktatExtension.excludes.none { it.isAbsolute }) {
"Absolute paths are not supported for excludes in diktat-gradle-plugin"
}

// Plain, checkstyle and json reporter are provided out of the box in ktlint
if (diktatExtension.reporterType == "html") {
diktatConfiguration.dependencies.add(project.dependencies.create("com.pinterest.ktlint:ktlint-reporter-html:$KTLINT_VERSION"))
Expand Down Expand Up @@ -155,18 +162,7 @@ open class DiktatJavaExecTaskBase @Inject constructor(
GradleVersion.version(gradleVersionString) >= GradleVersion.version("6.4")

private fun MutableList<String>.addPattern(pattern: File, negate: Boolean = false) {
val path = if (pattern.isAbsolute) {
project.logger.info("Pattern before normalizing: $pattern")
pattern
.relativeTo(project.projectDir)
/* .normalize()*/
} else {
pattern
}
/* .invariantSeparatorsPath*/.also {
project.logger.info("Pattern after normalizing and changing separators: $it")
}
add((if (negate) "!" else "") + path)
add((if (negate) "!" else "") + pattern)
}

private fun resolveConfigFile(file: File): String {
Expand Down

0 comments on commit 16acb24

Please sign in to comment.