Michael Marshall
08/18/2021, 11:07 AM./gradlew detektMain
on my Android project. Including this… 😂
error: 'trySend(E): ChannelResult<Unit>' is only available since Kotlin 1.4.30 and cannot be used in Kotlin 1.5
These errors don’t come up when compiling normally, what’s happening here?Gopal S Akshintala
08/24/2021, 3:26 PMproperty("sonar.sources", "src/main")
property("sonar.tests", "src/test")
But when I run gradle sonarqube
task, I keep getting errors like:
No input file found for /Users/gopala.akshintala/code-clones/my-github/vader-root/vader/build/generated/sources/delombok/java/main/org/revcloud/vader/runner/Utils.kt. No detekt issues will be imported on this file.
And I don’t see any detekt related errors.
Note: I am using lombok for some modules, so I even tried this:
property(
"sonar.sources",
the<SourceSetContainer>()["main"].allJava.srcDirs.filter { it.exists() }.joinToString(",")
)
property(
"sonar.tests",
the<SourceSetContainer>()["test"].allJava.srcDirs.filter { it.exists() }.joinToString(",")
)
but I keep getting the same error with file path being different (pointing to generated, so I guess this is not lombok specific)
No input file found for /Users/gopala.akshintala/code-clones/my-github/vader-root/vader/build/generated/sources/delombok/java/main/org/revcloud/vader/runner/Utils.kt. No detekt issues will be imported on this file.
Please help!Lilly
08/25/2021, 1:09 PMBrais Gabin
08/30/2021, 3:15 PMKtNamedFunction
) and I want to know if the returning type is Unit or not with type solving. I'm using this: function.bodyExpression.getResolvedCall(bindingContext)?.resultingDescriptor?.returnType?.isUnit()
but I get null for functions like this: fun asdf() = 5
. And if I use this: function.getType(bindingContext)?.fqNameOrNull()?.shortName()?.let { it.toString() == "Unit" }
get null
for fun asdf() {}
.Brais Gabin
08/31/2021, 4:48 PM@Test
function doesn't return Unit
JUnit will not execute it? But, no one returns something in those functions, right? Well... if you uses coroutines and follow this pattern in your tests: @Test fun foo() = runBlocking { ... }
your tests are not executed at all. Give the custom rule a try if you want 🙂. All feedback is more than welcome.Marek Kubiczek
09/01/2021, 3:54 PMA problem occurred evaluating script.
> Failed to apply plugin 'io.gitlab.arturbosch.detekt'.
> Cannot run Project.afterEvaluate(Action) when the project is already evaluated.
The thing is I have multiple modules and I am applying detekt to all of them just by
allprojects {
apply from: "$rootDir/detekt.gradle"
}
in the root project.
This was working so far. Is there a remedy for that or it needs to be fixed in Detekt gradle plugin?Callum Seabrook
09/12/2021, 5:02 PMSuppress
) is present? And if so, how?Colton Idle
09/22/2021, 8:22 PM./gradlew detektMain
, but I get an error:
Task 'detektMain' not found in root project 'rollertoaster'.
2. If I run ./gradlew detekt, I get a success message in 1s, but I don't think detekt actually analyzed my code.
The following Kotlin source sets were configured but not added to any Kotlin compilation:
* androidAndroidTestRelease
* androidTestFixtures
* androidTestFixturesDebug
* androidTestFixturesRelease
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See <https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets>
BUILD SUCCESSFUL in 1s
3. I can't add detekt into spotless right? I use spotless in order to run ktfmt, so being able to add detekt into spotless would be cool.
Can I get help on those three?dimsuz
09/23/2021, 4:27 PMwithType
in subprojects
while I already have this:
subprojects {
apply plugin: "io.gitlab.arturbosch.detekt"
detekt { ... }
tasks.withType(io.gitlab.arturbosch.detekt.Detekt).configureEach {
exclude("**/entity/generated/**")
}
}
And yet the file with path like this:
module/src/main/kotlin/data/network/entity/generated/AmountModel.kt:34:3
ends up being checked by detekt.
Any hints on what I did wrong? Version is 1.18.1
Brais Gabin
09/25/2021, 12:07 PMBrais Gabin
09/27/2021, 12:12 PMEndre Deak
10/08/2021, 6:30 PMbuild:
maxIssues: 0
excludeCorrectable: false
config:
validation: true
warningsAsErrors: false
processors:
active: true
comments:
active: true
UndocumentedPublicClass:
active: true
excludes: [ '**/test/**', '**/integrationTest/**', '**/systemTest/**', '*Test' ]
searchInNestedClass: true
searchInInnerClass: true
searchInInnerObject: true
searchInInnerInterface: true
UndocumentedPublicFunction:
active: true
excludes: [ '**/test/**', '**/integrationTest/**', '**/systemTest/**', '*Test' ]
UndocumentedPublicProperty:
active: true
excludes: [ '**/test/**', '**/integrationTest/**', '**/systemTest/**', '*Test' ]
formatting:
active: true
autoCorrect: true
MaximumLineLength:
active: true
autoCorrect: true
maxLineLength: 120
ignoreBackTickedIdentifier: true
configuration:
detekt {
toolVersion = "1.18.1"
config = files("config/detekt/detekt.yml")
buildUponDefaultConfig = true
autoCorrect = true
debug = true
}
I have a line longer than 120 chars and doesn’t get formatted correctly when I run gradle detekt
. What do I miss here?eygraber
10/11/2021, 7:39 PMgradle check
used to run all the necessary detekt tasks for me detektMetadata
, detektJvmMain
etc...). It seems to no longer be doing that. How can I get the behavior back?Michael Marshall
10/14/2021, 12:13 AMdetekt
, detektMain
and then detektTest
so we get type resolution running across both main and test source sets. However when we do this the report files seem to overwrite each other, and only one is left at the end (seems to be a random one). Any idea how we can keep all the report files - or merge them as we go along?dimsuz
10/14/2021, 12:37 PMdetektPlugins("path:to:artifact")
.
Gradle sync is finished OK, jar is downloaded and used, but when I run the 'detekt' task it prints an error that detekt-config.yml
contains an unknown property myrulesetname
.
I have rechecked that this published jar has services/path.to.ruleset.Ruleset
file.
What can go wrong? Do I need to add something else to this jar?gammax
10/19/2021, 2:32 PMgavvvr
10/21/2021, 2:31 PMgradle build
task graph? I am not ready to fix all my existing code base right now to make this step pass. I would like to exclude it from gradle build and run on demand only, by calling it explicitly with gradle detekt
Mike Wolfson
10/25/2021, 5:55 PM1.18.1
but switched to 1.17..1
and saw the same thing.
I am seeing a weird thing, where when I get my Detekt issues down to 0, the configuration file seems to get ignored...
I mean if I have at least 1 error, I will see it, but and as soon as I fix it - so I am down to 0 issues, Detekt seems to ignore my config file (and I see ALL the issues I have carefully Suppressed)
My detekt config:
apply plugin: "io.gitlab.arturbosch.detekt"
detekt {
toolVersion = detekt_version
buildUponDefaultConfig = true
autoCorrect = true
source = files("$projectDir")
config = files("$projectDir/analysis/detekt/detekt.yml")
parallel = true
reports {
html.enabled = true
xml.enabled = false
txt.enabled = false
}
}
Is there some default value I need to set to change this functionality? I feel like this must be something I have configured wrong, since I can see this in 1.17.1
and 1.18.1
(so it is not likely a bug, or this would be a bigger deal.eygraber
10/27/2021, 6:38 PMdetektMain
on my project.
One of my library modules generates code in build/generated/myapp/kotlin
which is added as a source set to main like so:
extensions.getByType<LibraryExtension>().sourceSets {
named("main") {
java {
srcDir(layout.buildDirectory.file("generated/myapp/kotlin"))
}
}
}
However, I don't want detekt to look at generated files. How can I prevent that?Janusz Chorko
11/02/2021, 4:32 PMignoreAnnotated
working on FunctionNaming
rule with Composable
annotation.
I've tried config:
FunctionNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)'
excludeClassPattern: '$^'
ignoreOverridden: true
ignoreAnnotated:
- 'Composable'
Also tried setting it to full androidx.compose.runtime.Composable
, but I'm still getting reports on all Composable functions
Am I configuring it wrong?dimsuz
11/03/2021, 4:01 PM// before
val itemId = 3
onClick = { someListener(itemId) }
// after
onClick = { someListener() }
// OR
onClick = { itemId -> someListener(itemId) }
in the latter cases this can be simplified to (no extra wrapping lambda):
onClick = someListener
I'm about to try to write a custom check for this, but I thought maybe there already is one?Javier
11/19/2021, 11:59 AMdetekt {
rules {
detektRule("com.example.rules:custom-rule-one:1.0.0")
// alternatives: `implementation`, `add`, etc.
// automatically applied without indicating it in the yaml
}
}
Another solution can be merging yaml files via adding them to resource folders or something so, but I prefer the previous API.Big Chungus
11/19/2021, 12:18 PMdimsuz
11/19/2021, 2:13 PMNamedArguments
with threshold=1
only for Composable
functions, is there some analog of ignoreAnnotated
which is in reverse: something like onlyAnnotated
?BorzdeG
11/21/2021, 1:33 PMmkrussel
11/22/2021, 7:49 PM1.19.0-RC1
on my Android project.
The type resolution tasks cannot find Android classes so they report many false positives.
For example
val sensorManager: SensorManager = context.getSystemService() ?: return null
val sensor = sensorManager.getDefaultSensor(sensorType) ?: return null
Reports unreachable code for everything after the first ?: return null
because it cannot find the type of context
and seems to assume that it always returns null.
See UnsafeCast
warnings also when checking and then casting for classes that extend View
.
Is there any configuration that I can do to make detekt find the Android classes during type resolution?AG
11/25/2021, 1:59 PMtask detektProjectBaseline(type: DetektCreateBaselineTask, group: "detekt") {
description = "Overrides current baseline."
buildUponDefaultConfig = false
ignoreFailures.set(true)
parallel.set(true)
setSource(files(rootDir))
config.setFrom(files("$rootDir/quality/detekt/detekt-config.yml"))
baseline.set(file("$rootDir/quality/detekt/baseline.xml"))
include("**/*.kt")
exclude("**/res/**", "**/build/**", "**/*.kts", "**/test/**", "**/androidTest/**")
classpath.setFrom(project.configurations.getByName("detekt"))
}
and I have another task which runs on files that I'm passing through -PinputFiles
gradle param
task detektChangedFiles(type: Detekt, group: "detekt") {
description = "Runs over changed files."
buildUponDefaultConfig = false
ignoreFailures = false
parallel = true
if (project.hasProperty("inputFiles")) {
setSource(files(inputFiles.split('\n')))
}
config.setFrom(file("$rootDir/quality/detekt/detekt-config.yml"))
baseline.set(file("$rootDir/quality/detekt/baseline.xml"))
include("**/*.kt")
exclude("**/res/**", "**/build/**", "**/*.kts", "**/test/**", "**/androidTest/**")
classpath.setFrom(project.configurations.getByName("detekt"))
reports {
xml {
enabled = true
destination = file("build/reports/detekt.xml")
}
html {
enabled = true
destination = file("build/reports/detekt.html")
}
}
}
The problem is that after running detektChangedFiles I'm getting issues like UnnecessaryLet that my baseline doesn't contain for that file. Seems baseline generation task ignores some rulesrudolf.hladik
11/29/2021, 10:34 AMDetekt
rule
LongMethod:
active: true
threshold: 60
but we find it too small for @Composable
functions. Is there a way to exclude composables from this limit, something like ignoreAnnotated
in LongParameterList
?Luka Štorek
11/29/2021, 12:40 PMMichael Marshall
11/29/2021, 10:16 PM