Skip to content

v1.20.0

Compare
Choose a tag to compare
@cortinico cortinico released this 15 Apr 20:11
· 1583 commits to main since this release
8028a06

We're extremely excited to share with you all the next upcoming stable release of Detekt: 1.20.0 πŸŽ‰
This release is coming with 16 new rules, new API and functionalities and several stability improvements.

First, much thanks to our sponsors ❀️ as we were able to buy a domain and move our website to https://detekt.dev/.

As for the feature shipped, we work a lot on the Reporting side: we added a new type of reporting, improved the styling of the existing one and
generally reduced the unnecessary warnings of run with type resolution.

For rules like ForbiddenMethod where you can configure a signature of a method you want to use in your rule, we added a new syntax
that allows to reference generic methods & extension functions.

We update a lot of the libraries we depend on bringing Detekt up to the ecosystem: KtLint 0.45.2, Kotlin 1.6.20 and Gradle 7.4.2 to name a few.

Finally, we also migrated all of our tests from Spek to JUnit. This was a huge effort that will hopefully make easier for contributors
to be involved with Detekt.

As always, we want to take the opportunity to thank our contributors for testing, bug reporting and helping
us release this new version of Detekt. You're more than welcome to join our community on the #detekt channel on KotlinLang's Slack (you can get an invite here).

Notable Changes

  • With this Detekt versions, rule authors can define the default configuration for their custom rules. This default configuration will be merged together with the user configuration and can be overridden by the user if they wish. More on this here #4315. The formatting ruleset provided by Detekt is updated to use this new mechanism - #4352
  • We've added 16 new rules:
    • UnnecessaryInnerClass - #4394
    • CanBeNonNullableProperty - #4379
    • NullCheckOnMutableProperty - #4353
    • SuspendFunWithCoroutineScopeReceiver - #4616
    • ElseCaseInsteadOfExhaustiveWhen - #4632
    • TrailingComma - From KtLint - #4227
    • UnnecessaryParenthesesBeforeTrailingLambda - From KtLint - #4630
    • BlockCommentInitialStarAlignment - From KtLint - #4645
    • CommentWrapping - From KtLint - #4645
    • DiscouragedCommentLocation - From KtLint - #4645
    • FunKeywordSpacing - From KtLint - #4645
    • FunctionTypeReferenceSpacing - From KtLint - #4645
    • KdocWrapping - From KtLint - #4645
    • ModifierListSpacing - From KtLint - #4645
    • TypeArgumentListSpacing - From KtLint - #4645
    • Wrapping - From KtLint - #4645
  • We've made several improvements to the console reporting:
    • The HTML report has now a better CSS styling - #4447
    • The default reporting format is now LiteFindingsReport (which is more compact reporting and similar to other tools in the ecosystem. You can see an example here) - #4449.
    • We've added issue details to findings on FindingsReport and FileBasedFindingsReporter - #4464
    • We suppressed several warnings reported when running with type resolution - #4423
  • We fixed a regression introduced in 1.19.0 for users using ignoreAnnotated running without type resolution - #4570
  • For rules like ForbiddenMethod where you can specify a method name in the config file, now we added support for:
    • Matching functions with generics - #4460
    • Matching extension functions - #4459
  • We've fixed a security vulnerability related to XML parsing - #4499
  • We've changed the behavior of the baseline task. Now the baseline is always update, even if you fixed all the issues in your codebase - #4445
  • We now enable the naming ruleset by default also on tests. Previously they were excluded - #4438
  • This version of Detekt is built with Gradle v7.4.2, AGP 7.1.3 and Kotlin 1.6.20 (see #4530 #4573 #4133 #4277 #4665)
  • This version of Detekt is wrapping KtLint version 0.45.2 (see #4227 #4630 #4645 #4690)
  • For contributors: we migrated all our tests from Spek to JUnit due to better support and tooling #4670.

Changelog

  • Display dynamic --jvm-target values when using --help flag - #4694
  • CanBeNonNullable shouldn't consider abstract properties - #4686
  • NonBooleanPropertyPrefixedWithIs: Allow boolean function reference - #4684
  • [VarCouldBeVal] fix overrides false positives - #4664
  • Add ignoreOverridden support for BooleanPropertyNaming rule - #4654
  • Fix regression generating configuration - #4646
  • Fix concurrency issue when creating PomModel (#4609) - #4631
  • UnnecessaryAbstractClass: fix false positive when the abstract class has properties in the primary constructor - #4628
  • Properly set toolVersion on DetektExtension - #4623
  • NamedArguments: Ignore when argument values are the same as the parameter name - #4613
  • Parallel invocation of AnalysisFacade fails spuriously in 1.20.0-RC1 - #4609
  • NoSuchElementException after updating to 1.20.0-RC1 - #4604
  • Better error classification in Gradle Enterprise. - #4586
  • Fix for missing /kotlin folder when running on Android projects - #4554
  • Deprecate continuationIndentSize from the Indentation rule - #4551
  • Fix performance issue for regexp in Reporting.kt - #4550
  • Revert "trim values when parsing the baseline (#4335)" - #4548
  • Fix AutoCorrection crashing with Missing extension point - #4545
  • Make DoubleMutabilityForCollection configurable and set a DoubleMutability alias - #4541
  • Fix AnnotationExcluder - #4518
  • Fix false positive of UnnecessaryInnerClass - #4509
  • [MaxLineLength] Fix signature in for blank characters in the Baseline - #4504
  • Fix overridden function reporting for CanBeNonNullable rule - #4497
  • Set the name of functions and paramenters between ` to improve the readability - #4488
  • update InvalidPackageDeclaration to report if rootPackage is not present - #4484
  • [VarCouldBeVal] Override vars will not be flagged if bindingContext is not set - #4477
  • Document the overlapping rules from formatting - #4473
  • Match functions signatures with lambdas on it - #4458
  • Add option for OutdatedDocumentation to allow param in constructor pr… - #4453
  • Ignore private operators when we don't have ContextBingding in UnusedPrivateMember - #4441
  • Add documentation for Suppressors - #4440
  • [FunctionNaming] Don't allow the usage of ` in function names - #4439
  • Add list of functions to skip in IgnoredReturnValue rule - #4434
  • Extend CanBeNonNullable rule to check function params - #4431
  • Extend VarCouldBeVal to include analysis of file- and class-level properties - #4424
  • Formulate rule/sample-extensions descriptions consistently - #4412
  • Fix false-positive on ExplicitCollectionElementAccessMethod - #4400
  • Fixes false negatives in UnnecessaryAbstractClass - #4399
  • Add first draft of a rule description style guide - #4386
  • Forbid usage of java.lang.ClassLoader.getResourceAsStream - #4381
  • Update Sponsor button to Detekt's one - #4378
  • [OptionalUnit] Allow a function to declare a Unit return type when it uses a generic function initializer - #4371
  • Completely-empty abstract classes will now be flagged by UnnecessaryAbstractClass - #4370
  • Fix false positive in RethrowCaughtException for try with more than one catch (#4367) - #4369
  • Testing and rule improvement for EmptyElseBlock - #4349
  • UnusedPrivateMember should not report external classes/interfaces - #4347
  • [UseDataClass] Do not report on inner classes - #4344
  • Support jvmTarget 17 - #4287
  • UnderscoresInNumericLiterals: Allow numbers with non standard groupings - #4280
  • Introduce DefaultValue type - #3928

Dependency Updates

  • Update plugin dokka to v1.6.20 - #4717
  • Update dependency com.android.tools.build:gradle to v7.1.3 - #4695
  • JaCoCo 0.8.8 - #4680
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.1 - #4673
  • Update dependency gradle to v7.4.2 - #4658
  • Update dependency org.jetbrains.kotlinx:kotlinx-html-jvm to v0.7.5 - #4657
  • Update dependency gradle to v7.4.1 - #4622
  • Update dependency com.android.tools.build:gradle to v7.1.2 - #4594
  • Update dependency com.android.tools.build:gradle to v7.1.1 - #4561
  • Update plugin pluginPublishing to v0.20.0 - #4502
  • Update JamesIves/github-pages-deploy-action action to v4.2.1 - #4475
  • Update JamesIves/github-pages-deploy-action action to v4.1.9 - #4455
  • Update plugin gradleVersions to v0.41.0 - #4454
  • Revert "Update plugin pluginPublishing to v0.19.0 (#4429)" - #4452
  • Update plugin pluginPublishing to v0.19.0 - #4429
  • Update dependency io.mockk:mockk to v1.12.2 - #4427
  • Shadow 7.1.2 - #4422
  • Update plugin dokka to v1.6.10 - autoclosed - #4407
  • Update dependency org.jetbrains.dokka:jekyll-plugin to v1.6.10 - #4406
  • Update dependency org.jetbrains.kotlinx:kotlinx-coroutines-core to v1.6.0 - #4393
  • Update dependency gradle to v7.3.3 - #4392
  • Update dependency org.yaml:snakeyaml to v1.30 - #4375
  • Update dependency gradle to v7.3.2 - #4374
  • Update plugin shadow to v7.1.1 - #4373
  • Update dependency gradle to v7.3.1 - #4350
  • Update plugin dokka to v1.6.0 - #4328

Housekeeping & Refactorings

  • Add missing Test annotations - #4699
  • Add failure message assertions to Gradle's "expect failure" tests - #4693
  • Drop (most) Groovy DSL tests - #4687
  • Check detekt-gradle-plugin functionalTest source when running detekt task - #4681
  • Fix typo in AvoidReferentialEquality rule description - #4644
  • Housekeep Gradle scripts - #4589
  • Refactor config printer to improve testability - #4580
  • avoid usage of java stream for parameterized tests - #4579
  • split rule documentation printer to improve testability - #4578
  • Make VERSION_CATALOGS stable - #4577
  • Enable Gradle's configuration cache by default - #4576
  • Migrate detekt-rules-performance tests to JUnit - #4569
  • Migrate detekt-rules-complexity tests to JUnit - #4566
  • Drop Groovy DSL testing in DetektTaskDslSpec - #4563
  • Reuse setReportOutputConventions - #4546
  • Code cleanups - #4542
  • Fix MaxLineLength violation on detekt main inside IgnoredReturnValue rule - #4539
  • Use Java 17 for all CI jobs - #4526
  • Migrate tests in detekt-rules-errorprone to junit - #4523
  • Drop unused dependencies - #4506
  • Update JUnit dependencies - #4505
  • Fixes test for LiteFindingsReport - #4479
  • Remove outdated detekt suppression - #4468
  • Add test cases to RedundantSuspendModifier rule - #4430
  • Refactor MultilineLambdaItParameter rule - #4428
  • Formulate rule/naming descriptions consistently - #4419
  • Formulate rule/bugs descriptions consistently - #4418
  • Formulate rule/complexity descriptions consistently - #4417
  • Formulate rule/documentation descriptions consistently - #4416
  • Formulate rule/coroutines descriptions consistently - #4415
  • Formulate rule/style descriptions consistently - #4414
  • Formulate rule/exceptions descriptions consistently - #4413
  • Formulate rule/performance descriptions consistently - #4411
  • Make MultiRuleCollector.kt consistent with the DoubleMutabilityForCollection rule - #4405
  • Add test for nested SwallowedException - #4404
  • Disable CI for Windows & JDK8 - #4403
  • Improve test description in ForEachOnRangeSpec.kt - #4402
  • Don't define classes on default package - #4401
  • Config file in directory test - #4398
  • Remove unnecessary map lambda in test code - #4397
  • Improve AnnotationExcluder tests - #4368
  • Enable UseAnyOrNoneInsteadOfFind - #4362
  • Enable ForbiddenMethodCall - #4334

See all issues at: 1.20.0