Zac Sweers
12/01/2022, 9:26 PMdimsuz
12/06/2022, 5:55 PM@RequiresTypeResolution
to the rule class
• In my test (using KoTest
) I have called createEnvironment()
• Then I switched to MyRule().compileAndLintWithContext(env, code)
All existing tests keep passing (so no errors in test/env setup).
But the following code:
fun visitNamedFunction(function: KtNamedFunction) {
println(bindingContext.getType(function))
}
prints "*null*".
I have also checked that bindingContext == BindingContext.EMPTY
returns false.
Did I miss someting?fred
12/07/2022, 9:17 AMdetektMain
to sweep non-multiplatform stuff with type resolution
◦ detektMetadataMain
to sweep commonMain
on all modules (found this one here)
◦ detektAndroidDebug
and detektAndroidRelease
to sweep Android code in multiplatform modules
◦ …and how do I sweep iOS code in multiplatform modules? I’ve tried detektMetadataIosMain
, detektIosX64Main
, detektIosArm64Main
and detektIosSimulatorArm64Main
but they all seem to fail to find issues on code inside iosMain
— should I file an issue or am I missing something? I have a minimum reproducible example here: https://github.com/tfcporciuncula/detekt-kmm-issue (this commit summarizes everything)
• any other option?Marek Czerwinski
12/08/2022, 10:49 AMexcludes
for every rule in a config?
Sample below:
LargeClass:
active: true
threshold: 150
excludes: ['**/test/**', '**/*Test.kt', '**/*Spec.kt']
eygraber
12/09/2022, 8:12 PMdetekt
task, or is that covered by the others?
./gradlew detektJvmMain detektDebug detektJsMain detektMetadataMain
rocketraman
12/13/2022, 2:02 PMeygraber
12/15/2022, 4:55 AMdimsuz
12/19/2022, 11:48 AMcompileAndLintWithContext
2. Using "native" android artifacts is not possible, because it required Android Gradle Plugin which I don't want to add (or should I try?)
3. Instead I started to use artifacts by Jetbrains's Compose Desktop, they do not require AGP
4. Now imports can be used, but if I compile a test snippet (see in thread), it fails with the "cannot inline "Box" method error" (see in thread)
5. If I a) add JB plugin to "plugins" block and b) write the same compose-code in the "Test.kt" file (not as snippet!) it compiles (without a) it gives the same "cannot-inline" error)
So from 5 I can see that compiling compose code as part of the test project works, but compiling with compileAndLintWithContext
doesn't work, it seems that compiler plugin gets applied in the first case and doesn't in second.
Is there a way to make test rule aware of compiler plugins?Yusuf.I
12/19/2022, 8:14 PMLandry Norris
12/20/2022, 6:38 PMeygraber
12/25/2022, 2:13 PMBilgehan KALKAN
01/11/2023, 8:02 AMdetektDebug
But recently I’m trying to validate “.kts” files too. But when I configure DetektExtension
with that paths(for root settings.gradle.kts
files too), detektDebug
task does not validates that files. It only validates default paths. On CI environment application is validated only with detektDebug
task because of baseline files.
Is there any way to configure detektDebug
task inputs via Extensions? When I tried to reach the task via tasks.named<Detekt>("detektDebug")
call it was tricky, I had to do this call on doAfter
block. Also project uses published plugins to apply all required plugins, so ı didn’t want to add confusing tricks on there.
Also I tried to configure detektDebug
task to depend on detekt
task and configured DetektExtension
to only check “.kts” files but when I do that --continue
option become useless. (CI environment uses --continue
option and we would like to provide complete reports to developers so that they can fix all issues at once instead of waiting results for each validation errors commit by commit.)Sebastian Schuberth
01/17/2023, 10:31 AMUnable to load class 'org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension'.
This is an unexpected error. Please file a bug containing the idea.log file.
Sebastian Schuberth
01/25/2023, 9:27 AMfun addResult(projectAnalyzerResult: ProjectAnalyzerResult) = apply {
// ...
}
instead of
fun addResult(projectAnalyzerResult: ProjectAnalyzerResult) =
apply {
// ...
}
?eygraber
01/26/2023, 2:42 AMMatt Russell
01/30/2023, 7:17 PM$ nix-shell -p detekt -I nixpkgs=<https://github.com/NixOS/nixpkgs/archive/f80ac848e3d6f0c12c52758c0f25c10c97ca3b62.tar.gz> --command 'detekt --version'
1.22.0
Yoni Obia
02/05/2023, 1:24 PMformatting:
active: boolean
android: boolean
autoCorrect: boolean
what does the android argument mean ?gammax
02/05/2023, 2:00 PMYoni Obia
02/05/2023, 2:53 PMMichael Marshall
02/11/2023, 7:27 AMForbiddenMethodCall
on a function annotated with @JvmStatic
and it doesn’t appear in my Detekt warnings (I am running it with type resolution via detektMain
). Is that a limitation or am I doing something wrong?
detekt.yml
ForbiddenMethodCall:
active: true
methods: [
... // Other method definitions which are working properly
'com.bluelinelabs.conductor.RouterTransaction.with', // Not working
]
Function definition (from a 3rd party lib)
package com.bluelinelabs.conductor
RouterTransaction {
...
companion object {
@JvmStatic
fun with(controller: Controller): RouterTransaction = RouterTransaction(controller)
}
}
Callsite
RouterTransaction.with(MyController())
Thomas Hormes
02/13/2023, 7:58 AMdetekt
Task nothing happens.
Do I need to apply the Detekt plugin to each module individually?
Edit: Adding the detektAll
task, which is sometimes recommended does not help eitherKevin
02/15/2023, 1:11 PMdetekt
task is using different rules than detektMain
. It's not skipping over any files, but it is applying different rules in the same file.
My detekt config in gradle looks like this:
detekt {
config = files("../detekt.yml")
buildUponDefaultConfig = true
source = files("src")
}
And detekt.yml looks like this:
complexity:
active: true
CognitiveComplexMethod:
active: true
threshold: 5
naming:
InvalidPackageDeclaration:
active: false
I'm using gradle 7.5.1 and targeting jdk 11.
Namely, detektMain
includes UnnecessaryFilter
and VarCouldBeVal
while detekt
does not.
Is this expected? I didn't find anything on google or in the github issues.Peter Mandeljc
02/15/2023, 3:01 PMUnnecessaryLet
?
val x = getJavaDuration()
.toHours()
.let { ceil(it / 24.0) }
.roundToLong()
kenkyee
02/16/2023, 3:39 PMLuca Nicoletti
02/21/2023, 9:58 AMdetekt
and updating a rule (custom), but the rule code is not the latest I have in the file. Any why I can force re-loading the rule when I run ./gradlew detekt
?Colton Idle
02/23/2023, 7:39 PMLuca Nicoletti
02/24/2023, 2:32 PMwhen
statement orders? I’m looking to have all objects
of a sealed class/interface coming first, then the data classes, so my when(s) would look like:
when (a) {
object1 -> {}
object2 -> {}
object3 -> {}
is dc1 -> {}
is dc2 -> {}
}
And not with is
mixed between all the statementsFrancis Mariano
02/28/2023, 2:23 PMtasks.register("detektAll") {
allprojects {
this@register.dependsOn(tasks.withType<io.gitlab.arturbosch.detekt.Detekt>())
}
}
I would like to run the detektAll in each build, but I unable configure that.
Do you know a better approach to run detekt in entire project ???Nikolay Puliaev
03/01/2023, 3:17 PMdetekt.yml
new libraries
and formatting
sections, now build doesn’t work because apparently I need to connect plugins to CLI.
Part of the action to execute detekt:
jobs:
detekt:
runs-on: buildjet-4vcpu-ubuntu-2004
steps:
- uses: actions/checkout@v3
- name: Setup detekt
uses: peter-murray/setup-detekt@v2
with:
detekt_version: 1.22.0
- name: Run detekt
run: detekt-cli \
--config plugins/detekt/detekt.yml \
--build-upon-default-config \
--excludes '**/androidTest/**','**/build.gradle.kts'
How can I connect both formatting
and libraries
plugins? I’ve read the documentation, but there’s no actual example how to add the plugins.tokuhirom
03/03/2023, 6:53 AMtokuhirom
03/03/2023, 6:53 AMBrais Gabin
03/03/2023, 9:52 AMtokuhirom
03/03/2023, 10:39 AM