github detekt/detekt v1.18.0

latest releases: v1.23.6, v1.23.5, v1.23.4...
2 years ago

1.18.0 - 2021-08-12

We're more than excited to introduce you a next stable release of Detekt: 1.18.0 🎉
This release is coming with a lot of changes, new rules, evolution in the API and stability improvements.

We want to take the opportunity to thank our contributors for testing, bug reporting and helping
us release this new version of Detekt.

Notable Changes

  • We've added two new rules: AvoidReferentialEquality and BooleanPropertyNaming (see #3924 and #3795)
  • This version of Detekt ships with Kotlin 1.5.21, and we're compiling with apiVersion set to 1.4 - #3956 and #3852
  • The minimum version of Gradle to use Detekt Gradle Plugin is now 6.1 - #3830
  • This version of Detekt has been tested against Java 16 - #3698
  • We fixed a long-standing bug related to parallel execution (#3248) - #3799 and #3822
  • We now use multi-line format for list options in the default detekt config file - #3827
  • The rule VarCouldBeVal has been updated and now works only with type resolution to provide more precise findings - #3880
  • We removed all the references to Extensions.getRootArea that is now deprecated from our codebase. This was affecting users with sporadic crashes. - #3848
  • For detekt rule authors: We created a Github Template that you can use to bootstrap your custom rule project: detekt-custom-rule-template. You can use JitPack to host it and share your rule easily with other members of the community.
  • For detekt rule authors: We finished the rework to use the annotations instead of kdoc tags in rules. Specifically configurations must be configured using @Configuration while auto-correction capability should be specified with the @AutoCorrectable annotation #3820.

Migration

  • We renamed the input property inside the detekt{} extension of the Gradle plugin to source. The input property has been deprecated, and we invite you to migrate to the new property (see #3951)
// BEFORE
detekt {
    input = files(...)
}

// AFTER
detekt {
    source = files(...)
}
  • For all rule authors: When accessing a config value within a rule, using valueOrDefault and valueOrDefaultCommaSeparated is no longer recommended. While both will remain part of the public api, they should be replaced by one of the config delegates (see #3891). The key that is used to lookup the configured value is derived from the property name.
/* simple property */
// BEFORE
val ignoreDataClasses = valueOrDefault("ignoreDataClasses", true)
// AFTER
val ignoreDataClasses: Boolean by config(true)

/* transformed simple property */
// BEFORE
val ignoredName = valueOrDefault("ignoredName", "").trim()
// AFTER
val ignoredName: String by config("", String::trim)

/* transformed list property */
// BEFORE
val ignoreAnnotated = valueOrDefaultCommaSeparated("ignoreAnnotated", listOf("Inject", "Value"))
        .map(String::trim)
// AFTER
val ignoreAnnotated: List<String> by config(listOf("Inject", "Value")) { list -> 
    list.map(String::trim) 
}
  • For all rule authors: The types ThresholdRule and LazyRegex have been marked as deprecated and will be removed in a future release. Please migrate to config delegates.
/* ThresholdRule */
// BEFORE
class MyRule(config: Config, threshold: Int = 10) : ThresholdRule(config, threshold) {
    // ...
}
// AFTER
class MyRule(config: Config) : Rule(config) {
    private val threshold: Int by config(10)
    // ...
}

/* LazyRegex */
// BEFORE
private val allowedPattern: Regex by LazyRegex("allowedPatterns", "")
// AFTER
private val allowedPattern: Regex by config("", String::toRegex)
  • For custom rule authors: This will be the last version of detekt where we publish the detekt-bom artifact. This change should not affect anyone. If it affects you, please let us know.

Changelog

  • [KMP] Fix resolution of Android test classpaths - #4026
  • Sort config lists - #4014
  • Multiplatform tasks should not depend on check - #4025
  • mark configWithFallback as unstable - #4028
  • UseDataClass: fix false positive on value classes - #4016
  • ImplicitUnitReturnType: don't report when expression body is 'Unit' - #4011
  • Fix false positive with UnusedPrivateMember on parameter of a protected function - #4007
  • ClassNaming: Don't treat Kotlin syntax ` as part of class name - #3977
  • IgnoredReturnValue: fix false negative when annotation is on the class - #3979
  • NoNameShadowing: fix false positive with nested lambda has implicit parameter - #3991
  • UnusedPrivateMember - added handling of overloaded array get operator - #3666
  • Publish bundled/Shadow JAR artifact to Maven repos - #3986
  • EmptyDefaultConstructor false positive with expect and actual classes - #3970
  • FunctionNaming - Allow factory function names - fix #1639 - #3973
  • EndOfSentenceFormat - Fix #3893 by only calling super.visit once - #3904
  • UndocumentedPublicFunction: don't report when nested class is inside not public class #3962
  • Fail with a meaningful error message for invalid boolean - #3931
  • UndocumentedPublicProperty and UndocumentedPublicFunction should include objects - #3940
  • Fix exclusion pattern for InvalidPackageDeclaration - #3907
  • Allow else when {...} in MandatoryBracesIfStatements rule - #3905
  • Remove unnecessary constant declaration - #3903
  • Check bindingContext only once in MemberNameEqualsClassName - #3899
  • LongMethod: add 'ignoreAnnotated' configuration option - #3892
  • Fix Deprecation rule message - #3885
  • Improve LongParameterList rule by supporting ignoring annotated parameters - #3879
  • OptionalUnit: fix false positive when function initializer is Nothing type - #3876
  • UnnecessaryParentheses: fix false positive for delegated expressions - #3858
  • Fix UnnecessaryLet false positive in inner lambdas - #3841
  • Fix false positive for UnusedPrivateMember - Backtick identifiers - #3828
  • Properly apply test excludes for comments - #3815
  • Fix generation issues around (deprecated) list properties - #3813
  • Update the implementation of ClassOrdering to handle false negatives - #3810
  • [comments] Do not exclude tests globally - #3801
  • UnnecessaryLet: report when implicit parameter isn't used - #3794
  • NoNameShadowing: don't report when implicit 'it' parameter isn't used - #3793
  • Fix ModifierOrder to support value class - #3719
  • Remove inline value class to stay compatible with Kotlin 1.4 API - #3871
  • [FunctionNaming] Revert annotations that are ignored by default - #3948
  • Android: add javac intermediates to classpath - [#3867]((#3867)
  • Revert "Android: add javac intermediates to classpath (#3867)" - [#3958]((#3958)
  • Use annotations to configure rules in detekt-rules-exceptions - #3798
  • Use @configuration in detekt-rules-style - #3774
  • Use annotations to configure rules in custom-checks - #3773
  • Use @configuration for rules-errorprone - #3772
  • Use annotation to configure rules in rules-empty - #3771
  • Use annotation to configure rules in rules-documentation - #3770
  • Use annotations to configure rules in rules-naming - #3769
  • Use annotations to configure rules in rules-complexity - #3768
  • Move formatting rules to @configuration - #3847

Dependency Updates

  • Bump Kotlin to 1.5.21 - #3956
  • Revert "Bump Kotlin to v1.5.20" - #3941
  • Bump Kotlin to v1.5.20 - #3921
  • Kotlin 1.5.10 - #3826
  • Update assertj to v3.20.2 - #3912
  • Update snakeyaml to v1.29 - #3911
  • Bump byte-buddy from 1.11.2 to 1.11.5 - #3886
  • Bump byte-buddy from 1.11.1 to 1.11.2 - #3872
  • Bump byte-buddy from 1.11.0 to 1.11.1 - #3861
  • Update mockk to 1.12.0 - #3937

Housekeeping & Refactorings

  • Enable UnnecessaryLet rule for detekt code base - #4024
  • enable PreferToOverPairSyntax rule for detekt code base - #4023
  • Add IllegalArgumentException and IllegalStateException to ThrowingExceptionsWithoutMessageOrCause - #4013
  • enable more potential-bugs rules for detekt code base - #3997
  • enable more exception rules for detekt code base - #3995
  • Enable UseOrEmpty for detekt code base - #3999
  • enable those rules from the style rule set that have not violation or obvious fixes - #3998
  • Enable more rules from naming rule set for detekt code base - #3996
  • Enable UseEmptyCounterpart for detekt code base - #4000
  • enable coroutine rules for detekt code base - #3994
  • Remove "plugin" suffix from version catalog aliases - #3987
  • Fix ClassCastException in test on java 11 openjdk9 - #3984
  • Activate IgnoredReturnValue on detekt code base - #3974
  • Add missing test in FunctionNaming - #3976
  • Fix trunk compilation - #3968
  • Reformat internal detekt.yml using multi line lists - #3936
  • Increase memory available to gradle integration test daemon - #3938
  • Avoid empty lines when running detekt with type resolution - #3909
  • Fix java.lang.ClassCastException is reading default yaml config - #3920
  • Refactor + rename util function inside MandatoryBracesIfStatement rule - #3908
  • Rename Tests to Spec - #3906
  • verify that no rule is configured with kdoc tags - #3870
  • Setup FOSSA - #3836
  • jvmTarget can't be null - #3818
  • Add test for ruleset provider configuration - #3814
  • Merge JaCoCo coverage reports the "right" way - #3650
  • Update outdated Gradle plugin documentation regarding source files - #3883
  • Make documentation more precise about how rules are enabled - #3889
  • Rename MapGetWithNotNullAsserSpec to follow test convention - #3878
  • Remove custom assertions that check kdoc of rules - #3859
  • Avoid overlapping outputs - #3790
  • Revert "Avoid overlapping outputs" - #3943

See all issues at: 1.18.0

Don't miss a new detekt release

NewReleases is sending notifications on new releases.