Skip to content

Commit

Permalink
style: fix all new detekt and ktlint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DanySK committed Oct 19, 2023
1 parent 7eb495b commit 6f2a20f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[*.{kt,kts}]
disabled_rules=import-ordering
max_line_length=120
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ kotlin {
compilations.all {
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs = listOf("-XXLanguage:+InlineClasses", "-opt-in=kotlin.RequiresOptIn")
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
}
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@ publishOnCentral {
projectDescription.set(description ?: TODO("Missing description"))
projectUrl.set(info.website)
scmConnection.set(info.scm)
repository("https://maven.pkg.github.com/DanySK/${rootProject.name}".toLowerCase(), name = "github") {
repository("https://maven.pkg.github.com/DanySK/${rootProject.name}".lowercase(), name = "github") {
user.set("danysk")
password.set(System.getenv("GITHUB_TOKEN"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ open class CommonScriptContext(override val name: String) : AbstractScriptContex
then:
${
runCatching { script() }
.getOrElse { "Something whose evaluation this error:\n${it.stackTraceToString()}" }
runCatching { script() }

Check warning on line 40 in src/main/kotlin/org/danilopianini/gradle/git/hooks/CommonScriptContext.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/git/hooks/CommonScriptContext.kt#L40

Added line #L40 was not covered by tests
.getOrElse { "Something whose evaluation this error:\n${it.stackTraceToString()}" }
}
""".trimIndent()
}
this.script = (shebang?.takeIf { it.isNotBlank() }?.let { "$it\n" } ?: "") + script()
this.script = (shebang?.takeIf { it.isNotBlank() }?.let { "$it\n" }.orEmpty()) + script()
}

final override fun processTasks(vararg tasks: Any, requireSuccess: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ open class GitHooksExtension(val settings: Settings) : Serializable {
|
|If you want to overwrite this file on every change add true to the createHooks(true)
|method in your settings.gradle.kts
""".trimMargin().lines().joinToString(separator = "\n") { "WARNING: $it" }
""".trimMargin().lines().joinToString(separator = "\n") {
"WARNING: $it"

Check warning on line 77 in src/main/kotlin/org/danilopianini/gradle/git/hooks/GitHooksExtension.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/danilopianini/gradle/git/hooks/GitHooksExtension.kt#L76-L77

Added lines #L76 - L77 were not covered by tests
},
)
if (overwriteExisting) {
println("WARNING: Overwriting git hook $name")
Expand Down
19 changes: 10 additions & 9 deletions src/test/kotlin/org/danilopianini/gradle/git/hooks/test/Tests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.gradle.internal.impldep.org.junit.rules.TemporaryFolder
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
import java.util.concurrent.TimeUnit
Expand All @@ -25,20 +26,20 @@ class Tests : StringSpec(
.acceptPackages(Tests::class.java.`package`.name)
.scan()
scan.getResourcesWithLeafName("test.yaml")
.flatMap {
log.debug("Found test list in $it")
val yamlFile = File(it.classpathElementFile.absolutePath + "/" + it.path)
.flatMap { resource ->
log.debug("Found test list in {}", resource)
val yamlFile = File(resource.classpathElementFile.absolutePath + "/" + resource.path)
val testConfiguration = Config {
addSpec(Root)
}.from.yaml.inputStream(it.open())
}.from.yaml.inputStream(resource.open())
testConfiguration[Root.tests].map { it to yamlFile.parentFile }
}
.forEach { (test, location) ->
log.debug("Test to be executed: $test from $location")
log.debug("Test to be executed: {} from {}", test, location)
val testFolder = folder {
location.copyRecursively(this.root)
}
log.debug("Test has been copied into $testFolder and is ready to get executed")
log.debug("Test has been copied into {} and is ready to get executed", testFolder)
test.description {
val result = GradleRunner.create()
.withProjectDir(testFolder.root)
Expand Down Expand Up @@ -82,15 +83,15 @@ class Tests : StringSpec(
process.exitValue() shouldBe 0
}
} ?: log.warn(
"No known Unix shell available on this system! Tests with scripts won't be executed"
"No known Unix shell available on this system! Tests with scripts won't be executed",
)
}
}
}
}
},
) {
companion object {
val log = LoggerFactory.getLogger(Tests::class.java)
val log: Logger = LoggerFactory.getLogger(Tests::class.java)
private val shells = listOf("sh", "bash", "zsh", "fish", "csh", "ksh")

private fun BuildResult.outcomeOf(name: String) = requireNotNull(task(":$name")) {
Expand Down

0 comments on commit 6f2a20f

Please sign in to comment.