Static code analysis for Kotlin
We're extremely excited to announce the next upcoming stable release of Detekt: 1.22.0 🚀 This release is coming with 16 new rules, 2 new rulesets and several new functionalities & APIs.
We've also introduced the Detekt Marketplace, a place for users to share their 3rd party rules and extensions.
We want to take the opportunity to thank our Sponsors and 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).
AlsoCouldBeApply
- #5333
MultilineRawStringIndentation
- #5058
TrimMultilineRawString
- #5051
UnnecessaryNotNullCheck
- #5218
UnnecessaryPartOfBinaryExpression
- #5203
UseSumOfInsteadOfFlatMapSize
- #5405
FunctionReturnTypeSpacing
from KtLint - #5256
FunctionSignature
from KtLint - #5256
FunctionStartOfBodySpacing
from KtLint - #5256
NullableTypeSpacing
from KtLint - #5256
ParameterListSpacing
from KtLint - #5256
SpacingBetweenFunctionNameAndOpeningParenthesis
from KtLint - #5256
TrailingCommaOnCallSite
from KtLint - #5312
TrailingCommaOnDeclarationSite
from KtLint - #5312
TypeParameterListSpacing
from KtLint - #5256
detekt-rules-ruleauthors
containing rules for Rule Authors to enforce best practices on Detekt rules such as the new ViolatesTypeResolutionRequirements
- #5129 #5182
detekt-rules-libraries
containing rules mostly useful for Library Authors - We moved the following rules inside ForbiddenPublicDataClass
, LibraryCodeMustSpecifyReturnType
, LibraryEntitiesShouldNotBePublic
this new ruleset - See Migration below on how to migrate #5360
--jdk-home
CLI parameter - #5269
--fail-fast
CLI flag (and failFast
Gradle property) has been removed. It was deprecated since 1.16.x - #5290
DuplicateCaseInWhenExpression
, MissingWhenCase
, RedundantElseInWhen
as the Kotlin Compiler is already reporting errors for those scenarios - #5309
--print-ast
CLI flag as PsiViewer provides the same features - #5418
ArrayPrimitive
is now working only with Type Resolution - #5175
WildcardImport
is now running also on tests by default - #5121
ForbiddenImport
allows now to specify a reason for every forbidden import - #4909
IgnoredReturnValue
: option restrictToAnnotatedMethods
is now deprecated in favor of restrictToConfig
- #4922
v7.5.1
, AGP 7.3.1
, Kotlin 1.7.21
and KtLint 0.47.1
(see #5363 #5189 #5411 #5312 #5519)v6.7.1
- #4964
We deprecated a number of rules in this release.
You should update your config file as follows:
potential-bugs:
active: true
...
- DuplicateCaseInWhenExpression:
- active: true
...
- MissingWhenCase:
- active: true
- allowElseExpression: true
...
- RedundantElseInWhen:
- active: true
style:
active: true
...
- ForbiddenPublicDataClass:
- active: true
- excludes: ['**']
- ignorePackages:
- - '*.internal'
- - '*.internal.*'
...
- LibraryCodeMustSpecifyReturnType:
- active: true
- excludes: ['**']
...
- LibraryEntitiesShouldNotBePublic:
- active: true
- excludes: ['**']
If you wish to use the libraries
ruleset we introduced you should add the following to your config file:
+ libraries:
+ active: true
+ ForbiddenPublicDataClass:
+ active: false
+ LibraryEntitiesShouldNotBePublic:
+ active: false
+ LibraryCodeMustSpecifyReturnType:
+ active: true
and add the following to you build.gradle
file:
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:$version")
If you're using our KtLint wrapper (i.e. detekt-formatting
) you should also update your config file as follows:
formatting:
active: true
...
- TrailingComma:
- active: false
- autoCorrect: true
- allowTrailingComma: false
- allowTrailingCommaOnCallSite: false
...
+ TrailingCommaOnCallSite:
+ active: false
+ autoCorrect: true
+ useTrailingCommaOnCallSite: false
+ TrailingCommaOnDeclarationSite:
+ active: false
+ autoCorrect: true
+ useTrailingCommaOnDeclarationSite: false
UnnecessaryPartOfBinaryExpression
- #5514
TrimMultilineRawString
false-positive on annotation parameters - #5476
SafeCast
with no braces - #5479
TrailingComma
as it's now split in two rules - #5423
it
-started expressions - #5376
FunctionOnlyReturningConstant>excludedFunctions
- #5120
KotlinEnvironmentResolver
- #5275
NestedScopeFunctions
- #5274
UnnecessaryAbstractClass
issue description to be less verbose - #5224
detektGenerateConfig
- #5199
ForbiddenMethodCall
- #5195
RedundantExplicitType
add annotation @RequiresTypeResolution
- #5128
ExitOutsideMain
if contextBinding
is empty - #5127
DataClassContainsFunctions>conversionFunctionPrefix
- #5119
ReturnCount
- #5118
ForbiddenMethodCall
- #4910
See all issues at: 1.22.0
Note: This Github Release was accidentally deleted as part of the RC3 release process. We've manually re-created it
AlsoCouldBeApply
- #5333
MultilineRawStringIndentation
- #5058
TrimMultilineRawString
- #5051
UnnecessaryNotNullCheck
- #5218
UnnecessaryPartOfBinaryExpression
- #5203
UseSumOfInsteadOfFlatMapSize
- #5405
FunctionReturnTypeSpacing
from KtLint - #5256
FunctionSignature
from KtLint - #5256
FunctionStartOfBodySpacing
from KtLint - #5256
NullableTypeSpacing
from KtLint - #5256
ParameterListSpacing
from KtLint - #5256
SpacingBetweenFunctionNameAndOpeningParenthesis
from KtLint - #5256
TrailingCommaOnCallSite
from KtLint - #5312
TrailingCommaOnDeclarationSite
from KtLint - #5312
TypeParameterListSpacing
from KtLint - #5256
detekt-rules-ruleauthors
containing rules for Rule Authors to enforce best practices on Detekt rules such as the new ViolatesTypeResolutionRequirements
- #5129 #5182
detekt-rules-libraries
containing rules mostly useful for Library Authors - We moved the following rules inside ForbiddenPublicDataClass
, LibraryCodeMustSpecifyReturnType
, LibraryEntitiesShouldNotBePublic
this new ruleset - See Migration below on how to migrate #5360
--jdk-home
CLI parameter - #5269
--fail-fast
CLI flag (and failFast
Gradle property) has been removed. It was deprecated since 1.16.x - #5290
DuplicateCaseInWhenExpression
, MissingWhenCase
, RedundantElseInWhen
as the Kotlin Compiler is already reporting errors for those scenarios - #5309
ArrayPrimitive
is now working only with Type Resolution - #5175
WildcardImport
is now running also on tests by default - #5121
ForbiddenImport
allows now to specify a reason for every forbidden import - #4909
IgnoredReturnValue
: option restrictToAnnotatedMethods
is now deprecated in favor of restrictToConfig
- #4922
v7.5.1
, AGP 7.3.1
, Kotlin 1.7.20
and KtLint 0.47.1
(see #5363 #5189 #5411 #5312
v6.7.1
- #4964
We deprecated a number of rules in this release.
You should update your config file as follows:
potential-bugs:
active: true
...
- DuplicateCaseInWhenExpression:
- active: true
...
- MissingWhenCase:
- active: true
- allowElseExpression: true
...
- RedundantElseInWhen:
- active: true
style:
active: true
...
- ForbiddenPublicDataClass:
- active: true
- excludes: ['**']
- ignorePackages:
- - '*.internal'
- - '*.internal.*'
...
- LibraryCodeMustSpecifyReturnType:
- active: true
- excludes: ['**']
...
- LibraryEntitiesShouldNotBePublic:
- active: true
- excludes: ['**']
If you wish to use the libraries
ruleset we introduced you should add the following to your config file:
+ libraries:
+ active: true
+ ForbiddenPublicDataClass:
+ active: false
+ LibraryEntitiesShouldNotBePublic:
+ active: false
+ LibraryCodeMustSpecifyReturnType:
+ active: true
and add the following to you build.gradle
file:
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-authors:$version")
If you're using our KtLint wrapper (i.e. detekt-formatting
) you should also update your config file as follows:
formatting:
active: true
...
- TrailingComma:
- active: false
- autoCorrect: true
- allowTrailingComma: false
- allowTrailingCommaOnCallSite: false
...
+ TrailingCommaOnCallSite:
+ active: false
+ autoCorrect: true
+ useTrailingCommaOnCallSite: false
+ TrailingCommaOnDeclarationSite:
+ active: false
+ autoCorrect: true
+ useTrailingCommaOnDeclarationSite: false
it
-started expressions - #5376
FunctionOnlyReturningConstant>excludedFunctions
- #5120
KotlinEnvironmentResolver
- #5275
NestedScopeFunctions
- #5274
UnnecessaryAbstractClass
issue description to be less verbose - #5224
detektGenerateConfig
- #5199
ForbiddenMethodCall
- #5195
RedundantExplicitType
add annotation @RequiresTypeResolution
- #5128
ExitOutsideMain
if contextBinding
is empty - #5127
DataClassContainsFunctions>conversionFunctionPrefix
- #5119
ReturnCount
- #5118
ForbiddenMethodCall
- #4910
See all issues at: 1.22.0
AlsoCouldBeApply
- #5333
MultilineRawStringIndentation
- #5058
TrimMultilineRawString
- #5051
UnnecessaryNotNullCheck
- #5218
UnnecessaryPartOfBinaryExpression
- #5203
UseSumOfInsteadOfFlatMapSize
- #5405
FunctionReturnTypeSpacing
from KtLint - #5256
FunctionSignature
from KtLint - #5256
FunctionStartOfBodySpacing
from KtLint - #5256
NullableTypeSpacing
from KtLint - #5256
ParameterListSpacing
from KtLint - #5256
SpacingBetweenFunctionNameAndOpeningParenthesis
from KtLint - #5256
TrailingCommaOnCallSite
from KtLint - #5312
TrailingCommaOnDeclarationSite
from KtLint - #5312
TypeParameterListSpacing
from KtLint - #5256
detekt-rules-ruleauthors
containing rules for Rule Authors to enforce best practices on Detekt rules such as the new ViolatesTypeResolutionRequirements
- #5129 #5182
detekt-rules-libraries
containing rules mostly useful for Library Authors - We moved the following rules inside ForbiddenPublicDataClass
, LibraryCodeMustSpecifyReturnType
, LibraryEntitiesShouldNotBePublic
this new ruleset - See Migration below on how to migrate #5360
--jdk-home
CLI parameter - #5269
--fail-fast
CLI flag (and failFast
Gradle property) has been removed. It was deprecated since 1.16.x - #5290
DuplicateCaseInWhenExpression
, MissingWhenCase
, RedundantElseInWhen
as the Kotlin Compiler is already reporting errors for those scenarios - #5309
--print-ast
CLI flag as PsiViewer provides the same features - #5418
ArrayPrimitive
is now working only with Type Resolution - #5175
WildcardImport
is now running also on tests by default - #5121
ForbiddenImport
allows now to specify a reason for every forbidden import - #4909
IgnoredReturnValue
: option restrictToAnnotatedMethods
is now deprecated in favor of restrictToConfig
- #4922
v7.5.1
, AGP 7.3.1
, Kotlin 1.7.20
and KtLint 0.47.1
(see #5363 #5189 #5411 #5312
v6.7.1
- #4964
We deprecated a number of rules in this release.
You should update your config file as follows:
potential-bugs:
active: true
...
- DuplicateCaseInWhenExpression:
- active: true
...
- MissingWhenCase:
- active: true
- allowElseExpression: true
...
- RedundantElseInWhen:
- active: true
style:
active: true
...
- ForbiddenPublicDataClass:
- active: true
- excludes: ['**']
- ignorePackages:
- - '*.internal'
- - '*.internal.*'
...
- LibraryCodeMustSpecifyReturnType:
- active: true
- excludes: ['**']
...
- LibraryEntitiesShouldNotBePublic:
- active: true
- excludes: ['**']
If you wish to use the libraries
ruleset we introduced you should add the following to your config file:
+ libraries:
+ active: true
+ ForbiddenPublicDataClass:
+ active: false
+ LibraryEntitiesShouldNotBePublic:
+ active: false
+ LibraryCodeMustSpecifyReturnType:
+ active: true
and add the following to you build.gradle
file:
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-authors:$version")
If you're using our KtLint wrapper (i.e. detekt-formatting
) you should also update your config file as follows:
formatting:
active: true
...
- TrailingComma:
- active: false
- autoCorrect: true
- allowTrailingComma: false
- allowTrailingCommaOnCallSite: false
...
+ TrailingCommaOnCallSite:
+ active: false
+ autoCorrect: true
+ useTrailingCommaOnCallSite: false
+ TrailingCommaOnDeclarationSite:
+ active: false
+ autoCorrect: true
+ useTrailingCommaOnDeclarationSite: false
SafeCast
with no braces - #5479
TrailingComma
as it's now split in two rules - #5423
it
-started expressions - #5376
FunctionOnlyReturningConstant>excludedFunctions
- #5120
KotlinEnvironmentResolver
- #5275
NestedScopeFunctions
- #5274
UnnecessaryAbstractClass
issue description to be less verbose - #5224
detektGenerateConfig
- #5199
ForbiddenMethodCall
- #5195
RedundantExplicitType
add annotation @RequiresTypeResolution
- #5128
ExitOutsideMain
if contextBinding
is empty - #5127
DataClassContainsFunctions>conversionFunctionPrefix
- #5119
ReturnCount
- #5118
ForbiddenMethodCall
- #4910
See all issues at: 1.22.0
MultilineRawStringIndentation
- #5058
TrimMultilineRawString
- #5051
UnnecessaryPartOfBinaryExpression
- #5203
FunctionReturnTypeSpacing
from KtLint - #5256
FunctionSignature
from KtLint - #5256
FunctionStartOfBodySpacing
from KtLint - #5256
NullableTypeSpacing
from KtLint - #5256
ParameterListSpacing
from KtLint - #5256
SpacingBetweenFunctionNameAndOpeningParenthesis
from KtLint - #5256
TypeParameterListSpacing
from KtLint - #5256
detekt-rules-ruleauthors
containing rules for Rule Authors to enforce best practices on Detetk rules - #5129
--jdk-home
CLI parameter - #5269
v7.5.1
, AGP 7.3.0
and Kotlin 1.7.10
(see #4821 #5189 #5306)v6.7.1
- #4964
FunctionOnlyReturningConstant>excludedFunctions
- #5120
KotlinEnvironmentResolver
- #5275
NestedScopeFunctions
- #5274
UnnecessaryAbstractClass
issue description to be less verbose - #5224
detektGenerateConfig
- #5199
ForbiddenMethodCall
- #5195
RedundantExplicitType
add annotation @RequiresTypeResolution
- #5128
ExitOutsideMain
if contextBinding
is empty - #5127
DataClassContainsFunctions>conversionFunctionPrefix
- #5119
ReturnCount
- #5118
IgnoredReturnValue
: add option returnValueTypes
to enable rule for particular types - #4922
ForbiddenMethodCall
- #4910
See all issues at: 1.22.0
We're delighted to announce the next upcoming stable release of Detekt: 1.21.0
🎉
This release is coming with 6 new rules, new API and functionalities and several stability improvements.
We want to thank you very much our Sponsors for the support in those last months. The work behind Detekt is all happening on a voluntary basis, and we're more than grateful for all the support we get from the Open Source Ecosystem.
We're also excited to announce that we're now having an Open Source Gradle Enterprise instance. When building the Detekt projects, you'll benefit from the Gradle Remote Cache that this instance is providing!
Finally, 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).
1.22.0
.We fixed a bug related to function with KDocs and how their location in the source code was calculated (see #4961 and #4887).
Because of this, some users might have to recreate their baseline as the location of such functions are not matched anymore against the baseline. You can do so by deleting your old baseline and invoking the detektBaseline
task (or the corresponding task, based on your configuration).
this
references - #4884
detekt-gradle-plugin
and detekt-utils
- #4748
VarCouldBeVal
: Add configuration flag ignoreLateinitVar
- #4745
1.21
- #4643
ComplexMethod
debt and refactor code - #5029
runWithArgsFile
failing locally - #4718
See all issues at: 1.21.0
this
references - #4884
detekt-gradle-plugin
and detekt-utils
- #4748
VarCouldBeVal
: Add configuration flag ignoreLateinitVar
- #4745
1.21
- #4643
runWithArgsFile
failing locally - #4718
See all issues at: 1.21.0
v1.21.0-RC1 - 2022-06-02
this
references - #4884
detekt-gradle-plugin
and detekt-utils
- #4748
VarCouldBeVal
: Add configuration flag ignoreLateinitVar
- #4745
1.21
- #4643
runWithArgsFile
failing locally - #4718
See all issues at: 1.21.0
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).
formatting
ruleset provided by Detekt is updated to use this new mechanism - #4352
LiteFindingsReport
(which is more compact reporting and similar to other tools in the ecosystem. You can see an example here) - #4449.FindingsReport
and FileBasedFindingsReporter
- #4464
1.19.0
for users using ignoreAnnotated
running without type resolution - #4570
ForbiddenMethod
where you can specify a method name in the config file, now we added support for:
v7.4.2
, AGP 7.1.3
and Kotlin 1.6.20
(see #4530 #4573 #4133 #4277 #4665)0.45.2
(see #4227 #4630 #4645 #4690)AnnotationExcluder
- #4518
formatting
- #4473
Suppressor
s - #4440
UnnecessaryAbstractClass
- #4399
inner
classes - #4344
setReportOutputConventions
- #4546
AnnotationExcluder
tests - #4368
See all issues at: 1.20.0
v1.20.0-RC2 - 2022-03-31
formatting
ruleset provided by Detekt is updated to use this new mechanism - #4352
LiteFindingsReport
(which is more compact reporting and similar to other tools in the ecosystem. You can see an example here) - #4449.FindingsReport
and FileBasedFindingsReporter
- #4464
1.19.0
for users using ignoreAnnotated
running without type resolution - #4570
ForbiddenMethod
where you can specify a method name in the config file, now we added support for:
v7.4.1
, AGP 7.1.1
and Kotlin 1.6.10
(see #4530 #4573 #4133 #4277)0.45.1
(see #4227 - #4630 - #4645)AnnotationExcluder
- #4518
formatting
- #4473
Suppressor
s - #4440
UnnecessaryAbstractClass
- #4399
inner
classes - #4344
setReportOutputConventions
- #4546
AnnotationExcluder
tests - #4368
See all issues at: 1.20.0
v1.20.0-RC1 - 2022-02-26
formatting
ruleset provided by Detekt is updated to use this new mechanism - #4352
LiteFindingsReport
(which is more compact reporting and similar to other tools in the ecosystem. You can see an example here) - #4449.FindingsReport
and FileBasedFindingsReporter
- #4464
1.19.0
for users using ignoreAnnotated
running without type resolution - #4570
v7.4
, AGP 7.1.1
and Kotlin 1.6.10
(see #4530 #4573 #4133 #4277)0.43.2
(see #4227)AnnotationExcluder
- #4518
formatting
- #4473
Suppressor
s - #4440
UnnecessaryAbstractClass
- #4399
inner
classes - #4344
setReportOutputConventions
- #4546
AnnotationExcluder
tests - #4368
See all issues at: 1.20.0