Prepare 1.0 (#1802)

* Prepare changelog

* Update versions to 1.0.0

* Fix testcase to use the new default configuration file

* Update comparison script to contain more projects and be compatible with detekt > RC15

* Write a news article for 1.0

* Correct spelling

* Introduce detekt before enumerate metrics

* Checkin forgotten "any" function documentation
This commit is contained in:
Artur Bosch
2019-08-08 21:46:21 +02:00
committed by GitHub
parent acf2e3b7b0
commit 996139d507
15 changed files with 212 additions and 41 deletions

View File

@@ -1,29 +1,50 @@
// kotlinc throws a "const is only allowed for top level properties" for unknown reasons
@file:Suppress("detekt.VariableNaming")
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.regex.Pattern
val arguments = args.toList()
@Suppress("detekt.MagicNumber")
check(arguments.size >= 3) { "Usage: [version1] [version2] [analysis-path] [diff-tool]?" }
/*
Working directory is expected to be [path/to/detekt].
When running the script from IntelliJ (Ctrl+Shift+F10), you have to change the working directory before.
Setup: "Shift+Alt+F10 -> Right -> Edit... -> Working Directory"
val analysisPath = Paths.get(arguments[2]).toAbsolutePath().normalize()
This script must find '/scripts/compare_releases_config.yml' and the detekt-cli module.
It automatically picks up the shadowJar's called "detekt-cli-[version]-all.jar", runs them
and uses 'diff' or a given diff tool to compare the results.
*/
val NUMBER_OF_ARGUMENTS_EXPECTED = 3
val FIRST_VERSION_ARG = 0
val SECOND_VERSION_ARG = 1
val ANALYSIS_PROJECT_ARG = 2
val IS_CUSTOM_DIFF_TOOL_USED = 4
val DIFF_TOOL = 3
val arguments = args.toList()
check(arguments.size >= NUMBER_OF_ARGUMENTS_EXPECTED) {
"Usage: [version1] [version2] [analysis-path] [diff-tool]?"
}
val analysisPath = Paths.get(arguments[ANALYSIS_PROJECT_ARG]).toAbsolutePath().normalize()
check(Files.exists(analysisPath)) { "analysis path '$analysisPath' does not exist" }
val configPath = Paths.get(".", "scripts/compare_releases_config.yml")
.toAbsolutePath().normalize()
.toAbsolutePath().normalize()
check(Files.exists(configPath)) { "config at '$configPath' must exist" }
// the diff tool is expected to exist and accept two files
// default is to use 'diff' which should exist on unix systems
val diffTool = if (arguments.size == 4) arguments[3] else "diff"
val diffTool = if (arguments.size == IS_CUSTOM_DIFF_TOOL_USED) arguments[DIFF_TOOL] else "diff"
fun findJar(root: Path, version: String): Path {
val pattern = Pattern.compile("detekt-cli-$version-all.jar").asPredicate()
return Files.walk(root)
.filter { pattern.test(it.fileName.toString()) }
.findFirst()
.orElseThrow { IllegalArgumentException("no jar with version $version found") }
.filter { pattern.test(it.fileName.toString()) }
.findFirst()
.orElseThrow { IllegalArgumentException("no jar with version $version found") }
}
val rootForJars = Paths.get(".", "detekt-cli/build/libs")
@@ -37,23 +58,25 @@ println("Comparing: \n$jar1\n$jar2")
fun javaExec(jar: Path, output: Path) {
val command = listOf(
"java",
"-jar",
jar.toString(),
"--input",
analysisPath.toString(),
"--config",
configPath.toString(),
"--filters",
".*/resources/.*,.*/build/.*,.*/out/.*,.*/test/.*",
"--report",
"txt:$output"
"java",
"-jar",
jar.toString(),
"--input",
analysisPath.toString(),
"--build-upon-default-config",
"--fail-fast",
"--config",
configPath.toString(),
"--excludes",
"**/resources/**,**/build/**,**/out/**,**/target/**",
"--report",
"txt:$output"
)
println("Executing ${command.joinToString(" ")}")
ProcessBuilder(command)
.inheritIO()
.start()
.waitFor()
.inheritIO()
.start()
.waitFor()
}
val diff1 = Files.createTempFile("detekt", "compare")
@@ -71,9 +94,9 @@ fun performDiff() {
val command = listOf("diff", diff1.toString(), diff2.toString())
val diffResult = Files.createTempFile("detekt", "diff").toFile()
ProcessBuilder(command)
.redirectOutput(diffResult)
.start()
.waitFor()
.redirectOutput(diffResult)
.start()
.waitFor()
val diff = diffResult.readText().trim()
if (diff.isNotEmpty()) {
println(diff)

View File

@@ -1 +1,23 @@
failFast: true
build:
# analysis time is not printed on build failure
maxIssues: 9999999
processors:
active: true
exclude:
# IntelliJ terminal scrolls to much to the right
- 'DetektProgressListener'
console-reports:
active: true
exclude:
# we do not have everything correctly configured
# though there may be too many findings in a project
# we just look at the diff and manually watch the generated txt report
- 'FindingsReport'
# not so interesting findings and easy to spot a failure in the rule
style:
MaxLineLength:
active: false

View File

@@ -20,7 +20,12 @@ def projects = [
"git@github.com:spekframework/spek.git",
"git@github.com:Kotlin/kotlinx.coroutines.git",
"git@github.com:kotlintest/kotlintest.git",
"git@github.com:tipsy/javalin.git"
"git@github.com:tipsy/javalin.git",
"git@github.com:arturbosch/ksh.git",
"git@github.com:arturbosch/kutils.git",
"git@github.com:arturbosch/deps.git",
"git@github.com:arturbosch/detekt.git",
"git@github.com:arturbosch/sonar-kotlin.git"
]
if (args.size() == 0) {