ForbiddenMethodCall rule doesn't raise lint errors for files under src/test/kotlin
directory
#6485
-
Hi, I'm trying to use When I run > Task :detektMain FAILED
Property 'naming>BooleanPropertyNaming>ignoreOverridden' is deprecated. This configuration is ignored and will be removed in the future.
Property 'naming>FunctionNaming>ignoreOverridden' is deprecated. This configuration is ignored and will be removed in the future.
Property 'naming>FunctionParameterNaming>ignoreOverridden' is deprecated. This configuration is ignored and will be removed in the future.
Property 'naming>ConstructorParameterNaming>ignoreOverridden' is deprecated. This configuration is ignored and will be removed in the future.
Property 'naming>VariableNaming>ignoreOverridden' is deprecated. This configuration is ignored and will be removed in the future.
/<project_path>/src/main/kotlin/Main.kt:2:5: The method `kotlin.io.println` has been forbidden: println does not allow you to configure the output stream. Use a logger instead. [ForbiddenMethodCall]
/<project_path>/src/main/kotlin/Main.kt:7:5: The method `kotlin.error` has been forbidden: error() method hides Too generic exception [ForbiddenMethodCall] The rule correctly raises the violation inside ForbiddenMethodCall:
active: true
methods:
- reason: 'print does not allow you to configure the output stream. Use a logger instead.'
value: 'kotlin.io.print'
- reason: 'println does not allow you to configure the output stream. Use a logger instead.'
value: 'kotlin.io.println'
- reason: 'error() method hides Too generic exception'
value: 'kotlin.error' I do not have any global exclusion for the detekt {
// debug = true
toolVersion = detektVersion
buildUponDefaultConfig = true // preconfigure defaults
allRules = false // activate all available (even unstable) rules.
baseline = file("$projectDir/config/detekt/baseline.xml") // a way of suppressing issues before introducing detekt
autoCorrect = true
} I'm using version Not sure what am I missing. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
detektMain
only check the code onmain
. You also need to rundetektTest
. I usually create a meta-task on gradledetektAll
that depend on both tasks because they usually are executed together.