mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
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:
@@ -3,7 +3,7 @@
|
||||
[](https://kotlinlang.slack.com/messages/C88E12QH4/convo/C0BQ5GZ0S-1511956674.000289/)
|
||||
[](https://arturbosch.github.io/detekt/)
|
||||
[ ](https://bintray.com/arturbosch/code-analysis/detekt/_latestVersion)
|
||||
[](https://plugins.gradle.org/plugin/io.gitlab.arturbosch.detekt)
|
||||
[](https://plugins.gradle.org/plugin/io.gitlab.arturbosch.detekt)
|
||||
<!-- Version needs to be hardcoded until rc phase is over. Change to '-'RC for semantic versioning broke the badge. [](https://plugins.gradle.org/plugin/io.gitlab.arturbosch.detekt)-->
|
||||
|
||||
[](https://travis-ci.org/arturbosch/detekt)
|
||||
@@ -20,13 +20,13 @@ It operates on the abstract syntax tree provided by the Kotlin compiler.
|
||||
### Features
|
||||
|
||||
- Code smell analysis for your Kotlin projects
|
||||
- Complexity report based on logical lines of code, McCabe complexity and amount of code smells
|
||||
- Highly configurable
|
||||
- Complexity reports based on lines of code, cyclomatic complexity and amount of code smells
|
||||
- Highly configurable rule sets
|
||||
- Suppress findings with Kotlin's `@Suppress` and Java's `@SuppressWarnings` annotations
|
||||
- Specify code smell thresholds to break your build
|
||||
- Code Smell baseline and ignore lists for legacy projects
|
||||
- [Gradle plugin](#with-gradle) for code analysis via Gradle builds
|
||||
- Gradle tasks to use local `IntelliJ` distribution for [formatting and inspecting](#idea) Kotlin code
|
||||
- Gradle tasks to use local `IntelliJ` distribution for formatting and inspecting Kotlin code
|
||||
- [SonarQube integration](https://github.com/arturbosch/sonar-kotlin)
|
||||
- Extensible by own rule sets, `FileProcessListener's` and `OutputReport's`
|
||||
- [IntelliJ integration](https://github.com/arturbosch/detekt-intellij-plugin)
|
||||
|
||||
@@ -29,7 +29,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "io.gitlab.arturbosch.detekt"
|
||||
version = "1.0.0-RC16"
|
||||
version = "1.0.0"
|
||||
|
||||
val detektGradleVersion: String by project
|
||||
val jcommanderVersion: String by project
|
||||
|
||||
@@ -14,7 +14,7 @@ class GenerateConfigTaskTest : Spek({
|
||||
|
||||
gradleRunner.runTasksAndCheckResult("detektGenerateConfig") { result ->
|
||||
assertThat(result.task(":detektGenerateConfig")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
|
||||
assertThat(projectFile("default-detekt-config.yml")).exists()
|
||||
assertThat(projectFile("config/detekt/detekt.yml")).exists()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
71
docs/_posts/2019-08-04-calling-it-one-zero.md
Normal file
71
docs/_posts/2019-08-04-calling-it-one-zero.md
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: "Calling it One Zero"
|
||||
published: true
|
||||
permalink: calling-it-one-zero.html
|
||||
summary: "So we finally made it. One zero."
|
||||
tags: [news]
|
||||
---
|
||||
|
||||
Today we are announcing the **1.0** release of detekt, a static code analysis tool for Kotlin.
|
||||
It operates on the abstract syntax tree provided by the Kotlin compiler and finds common
|
||||
programming flaws like unused or too complex constructs. Think as *pmd* or *checkstyle* but for Kotlin.
|
||||
|
||||
**1.0** brings following features:
|
||||
|
||||
- Code smell analysis for your Kotlin projects
|
||||
- Complexity reports based on lines of code, cyclomatic complexity and amount of code smells
|
||||
- Highly configurable rule sets
|
||||
- Suppress findings with Kotlin's `@Suppress` and Java's `@SuppressWarnings` annotations
|
||||
- Specify code smell thresholds to break your build
|
||||
- Code Smell baseline and ignore lists for legacy projects
|
||||
- [Gradle plugin](#with-gradle) for code analysis via Gradle builds
|
||||
- Gradle tasks to use local `IntelliJ` distribution for formatting and inspecting Kotlin code
|
||||
- [SonarQube integration](https://github.com/arturbosch/sonar-kotlin)
|
||||
- Extensible by own rule sets, `FileProcessListener's` and `OutputReport's`
|
||||
- [IntelliJ integration](https://github.com/arturbosch/detekt-intellij-plugin)
|
||||
- Unofficial [Maven plugin](https://github.com/Ozsie/detekt-maven-plugin) by [Ozsie](https://github.com/Ozsie)
|
||||
|
||||
Here are some metrics describing detekt's lifespan so far:
|
||||
|
||||

|
||||
|
||||
detekt is nearly **3** years old already!
|
||||
As GitHub tells us the project is pretty active.
|
||||
You may say that in 2018 it was more active telling by the number of commits, however that year
|
||||
we also changed our merge strategy from merge-with-rebase to squash-and-merge.
|
||||
That said, it is much harder to achieve these high commit numbers now ;).
|
||||
|
||||

|
||||
|
||||
There are **2516** commits, **52** releases on GitHub and a total **93** contributors by the time of writing.
|
||||
**20** out of the 93 authors contributed once or more in the last three months.
|
||||
|
||||

|
||||
|
||||
**~780k** downloads in the last **30 days** is a pretty high number ... three months ago it was like **500k**.
|
||||
One can clearly see when weekends are ;).
|
||||
|
||||
This does however not mean "1 download = 1 user". There are like eight detekt modules each with a jar and pom which needs to be downloaded.
|
||||
Most of the downloads should be coming from CI which makes it hard to calculate the number of users detekt actually has.
|
||||
|
||||

|
||||
|
||||
What I also noticed is the high number of "early adopters" in the Kotlin world (or just detekt).
|
||||
- RC09 was released in Sep 2018
|
||||
- RC10 was released in Nov 2018
|
||||
- RC11 was released in Nov 2018
|
||||
- RC12 was released in Dec 2018
|
||||
- RC14 was released in Feb 2019
|
||||
- RC15 was released in Jun 2019
|
||||
- RC16 was released in Jun 2019
|
||||
|
||||
**65%** of users are on a version published in 2019. But we clearly lost some users in the older versions due to breaking changes in RC13 and RC15.
|
||||
We are excited to see how many users will jump to the 1.x.x release train and how these numbers will look like.
|
||||
|
||||
Last but not least here is a worldmap of where detekt users are coming from.
|
||||
|
||||

|
||||
|
||||
References:
|
||||
- https://bintray.com/arturbosch/code-analysis/detekt#statistics
|
||||
- https://github.com/arturbosch/detekt/graphs/contributors
|
||||
BIN
docs/images/one-zero/1-lifespan.png
Normal file
BIN
docs/images/one-zero/1-lifespan.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
docs/images/one-zero/2-numbers.png
Normal file
BIN
docs/images/one-zero/2-numbers.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
BIN
docs/images/one-zero/3-bintray-absolute.png
Normal file
BIN
docs/images/one-zero/3-bintray-absolute.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
docs/images/one-zero/4-bintray-percent.png
Normal file
BIN
docs/images/one-zero/4-bintray-percent.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
BIN
docs/images/one-zero/5-bintray-world.png
Normal file
BIN
docs/images/one-zero/5-bintray-world.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
@@ -6,11 +6,49 @@ permalink: changelog.html
|
||||
toc: true
|
||||
---
|
||||
|
||||
<!--
|
||||
#### Coming up
|
||||
|
||||
##### Migration
|
||||
-->
|
||||
#### 1.0.0
|
||||
|
||||
*Coming soon*
|
||||
##### Migration
|
||||
|
||||
- Gradle Plugin: removed report consolidation. It was flawed and some users were stuck with RC14. It will be replaced in a further version.
|
||||
- Gradle Plugin: `autoCorrect` property is not allowed on the detekt extension. No need to create a new task anymore.
|
||||
- Formatting: updated to KtLint 0.34.2 which removed the two rules `NoItParamInMultilineLambda` and `SpacingAroundUnaryOperators`.
|
||||
|
||||
##### Changelog
|
||||
|
||||
- Gradle plugin: Set default path for "config" parameter - [#1801](https://github.com/arturbosch/detekt/pull/1801)
|
||||
- Don't use provider value that may not have been set - [#1800](https://github.com/arturbosch/detekt/pull/1800)
|
||||
- Remove raw URLs from README - [#1799](https://github.com/arturbosch/detekt/pull/1799)
|
||||
- Add missing autoCorrect declarations - [#1798](https://github.com/arturbosch/detekt/pull/1798)
|
||||
- Docs: Missing autoCorrect option for various rules - [#1796](https://github.com/arturbosch/detekt/issues/1796)
|
||||
- Update to KtLint 0.34.2 - [#1791](https://github.com/arturbosch/detekt/pull/1791)
|
||||
- Add auto correct flag to detekt extension - [#1790](https://github.com/arturbosch/detekt/pull/1790)
|
||||
- Gradle plugin: Fix visibility of internal properties - [#1789](https://github.com/arturbosch/detekt/pull/1789)
|
||||
- Check classes and functions documented for api module - [#1788](https://github.com/arturbosch/detekt/pull/1788)
|
||||
- Provide default value for ignoreFailures - [#1787](https://github.com/arturbosch/detekt/pull/1787)
|
||||
- Update detekt-api documentation - [#1786](https://github.com/arturbosch/detekt/pull/1786)
|
||||
- Document meanings of rule severity levels - [#1785](https://github.com/arturbosch/detekt/pull/1785)
|
||||
- Remove unused code - [#1784](https://github.com/arturbosch/detekt/pull/1784)
|
||||
- Fix UseDataClass false positive (delegation) - [#1783](https://github.com/arturbosch/detekt/pull/1783)
|
||||
- Add ignore pattern to SwallowedException - [#1782](https://github.com/arturbosch/detekt/pull/1782)
|
||||
- Prevent adding author tags in code - [#1776](https://github.com/arturbosch/detekt/pull/1776)
|
||||
- Remove xml report consolidation. - [#1774](https://github.com/arturbosch/detekt/pull/1774)
|
||||
- Update Complex Method doc - closes #1009 - [#1773](https://github.com/arturbosch/detekt/pull/1773)
|
||||
- Implement dry-run option for detekt gradle tasks. - [#1769](https://github.com/arturbosch/detekt/pull/1769)
|
||||
- Fix missing report file issue. - [#1767](https://github.com/arturbosch/detekt/pull/1767)
|
||||
- Not running formatting autocorrect - [#1766](https://github.com/arturbosch/detekt/issues/1766)
|
||||
- Check if file exists before considering it for report merges - [#1763](https://github.com/arturbosch/detekt/pull/1763)
|
||||
- Preset ignoreFailures property with false as it is also used by Gradle - [#1762](https://github.com/arturbosch/detekt/pull/1762)
|
||||
- Rearrange badges, add codefactor - [#1760](https://github.com/arturbosch/detekt/pull/1760)
|
||||
- Update Kotlin to 1.3.41 - [#1759](https://github.com/arturbosch/detekt/pull/1759)
|
||||
- Update EmptyClassBlock to skip classes with comments in the body - [#1758](https://github.com/arturbosch/detekt/pull/1758)
|
||||
- EmptyClassBlock should consider comment as "body" (via option?) - [#1756](https://github.com/arturbosch/detekt/issues/1756)
|
||||
- Remove obsolete NoWildcardImports autoCorrect param - [#1751](https://github.com/arturbosch/detekt/pull/1751)
|
||||
- Kotlin language version handling - [#1748](https://github.com/arturbosch/detekt/pull/1748)
|
||||
- Fix cli execution doc - [#1747](https://github.com/arturbosch/detekt/pull/1747)
|
||||
- Add naming test for ForbiddenVoid rule - [#1740](https://github.com/arturbosch/detekt/pull/1740)
|
||||
- ForbiddenVoid: New option 'ignoreUsageInGenerics' - [#1738](https://github.com/arturbosch/detekt/pull/1738)
|
||||
- Default Gradle config path should be config/detekt/config.yml - [#1262](https://github.com/arturbosch/detekt/issues/1262)
|
||||
|
||||
See all issues at: [1.0.0](https://github.com/arturbosch/detekt/milestone/46)
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
title: SplitPattern.any - detekt-api
|
||||
---
|
||||
|
||||
[detekt-api](../../index.html) / [io.gitlab.arturbosch.detekt.api](../index.html) / [SplitPattern](index.html) / [any](./any.html)
|
||||
|
||||
# any
|
||||
|
||||
`fun any(value: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`?): `[`Boolean`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)
|
||||
|
||||
Is there any element which matches the given [value](any.html#io.gitlab.arturbosch.detekt.api.SplitPattern$any(kotlin.String)/value)?
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
detektVersion=1.0.0-RC16
|
||||
detektVersion=1.0.0
|
||||
ktlintVersion=0.34.2
|
||||
spekVersion=2.0.2
|
||||
junitPlatformVersion=1.4.1
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user