eygraber
04/14/2023, 6:52 PMgammax
04/14/2023, 6:52 PMeygraber
04/14/2023, 7:02 PMeygraber
04/14/2023, 7:06 PMtrickybits
04/19/2023, 5:27 PMdetekt
gradle task on a mixed project with both kotlin-only and kotlin + android modules?
Execution failed for task ':rxreactor1:detekt'.
> Could not resolve all files for configuration ':rxreactor1:detekt'.
> Could not find io.gitlab.arturbosch.detekt:detekt-cli:provider(?).
Searched in the following locations:
- <https://dl.google.com/dl/android/maven2/io/gitlab/arturbosch/detekt/detekt-cli/provider(?)/detekt-cli-provider(?).pom>
- <https://repo.maven.apache.org/maven2/io/gitlab/arturbosch/detekt/detekt-cli/provider(?)/detekt-cli-provider(?).pom>
Required by:
project :rxreactor1
Atul Gupta
04/21/2023, 7:31 AMDontDowncastCollectionTypes
naming as per other rule naming convention? Like for when we want to warn against casting to nullable type we say that rule as CastToNullableType
. So shouldn't the name of DontDowncastCollectionTypes
be DowncastToCollectionTypes
?eygraber
04/24/2023, 4:21 AMBracesOnWhenStatements
with the following config:
BracesOnWhenStatements:
active: true
singleLine: 'necessary'
multiLine: 'necessary'
If I have a when
with a clause that does no handling, I typically use {}
because I like how it looks vs Unit
(depending on the use case), but BracesOnWhenStatements
reports that as a violation. Is that working as intended, or should the case of a clause with no handling be an exception?Travis Miehm
04/26/2023, 12:57 PMsanggggg
04/27/2023, 3:56 AMdetektMain
task should dependsOn some tasks like compileKotlin
to leverage already compiled results.
But in source code, detektMain
do not depends on any task regarding kotlin compiler.
Is this intented behavior? then how detekt gradle plugin can get compiled kotlin result?Brais Gabin
04/27/2023, 1:39 PMdetektMain
everything works as expected BUT when I run detektBaselineMain
a element is added to my baseline. I don't understand what could be happening here. Any ideas?Brais Gabin
04/27/2023, 1:40 PMAtul Gupta
04/28/2023, 8:38 AM1.23.0.RC2
and I really loved the BracesOnIfStatements
and BracesOnWhenStatements
. Thanks @Vitaly Pinchuk for the contribution 🤩Caio Costa
04/29/2023, 3:06 PM* What went wrong:
Execution failed for task ':app:detekt'.
> Run failed with 3 invalid config properties.
- Property 'formatting' is misspelled or does not exist.
- Property 'libraries' is misspelled or does not exist.
- Property 'ruleauthors' is misspelled or does not exist.
This is how detekt is setup here ATM (I created a separate gradle file for it):
apply plugin: 'io.gitlab.arturbosch.detekt'
detekt {
toolVersion = "$detektVersion"
allRules = true
autoCorrect = true
buildUponDefaultConfig = true
config = files("${rootProject.projectDir}/config/detekt/detekt.yml")
parallel = true
source = files(rootProject.projectDir)
reports {
xml.required.set(true)
html.required.set(true)
txt.required.set(true)
sarif.required.set(true)
md.required.set(true)
}
}
I'm using the latest detekt.yml: https://github.com/detekt/detekt/tree/main/config/detekt
I've searched online but couldn't find anything helpful. Any help would be appreciated. Thank you.Brais Gabin
04/30/2023, 12:19 PMeygraber
05/03/2023, 6:13 PMinline fun <T1, T2, T3, T4, T5, T6, R> combine(
flow: Flow<T1>,
flow2: Flow<T2>,
flow3: Flow<T3>,
flow4: Flow<T4>,
flow5: Flow<T5>,
flow6: Flow<T6>,
crossinline transform: suspend (T1, T2, T3, T4, T5, T6) -> R
): Flow<R> = kotlinx.coroutines.flow.combine(flow, flow2, flow3, flow4, flow5, flow6) { args: Array<*> ->
transform(
args[0] as T1,
args[1] as T2,
args[2] as T3,
args[3] as T4,
args[4] as T5,
args[5] as T6
)
}
It violates CastNullableToNonNullableType
, but the generic parameters here could be nullable (and in fact I think they are because they're not * & Any
). Am I missing something here?Eric
05/05/2023, 8:41 PMMultilineLambdaItParameter
and ExplicitItLambdaParameter
?
edit: ohh... took 3 extra seconds to read it again. EXPLICT itEric
05/05/2023, 9:24 PMignoreFunction
for SpreadOperator
here instead of using the annotation?
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.scheduling.annotation.EnableAsync
@EnableAsync
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) {
@Suppress("SpreadOperator")
runApplication<DemoApplication>(*args)
}
Colton Idle
05/09/2023, 2:02 PMColton Idle
05/09/2023, 2:25 PMEric
05/09/2023, 9:27 PMdetektMain
task, but not detekt
task? Several files are causing detekt to crash when I run detektMain
but not detekt
. Detekt 1.22.0, Kotlin 1.8.21, AWS Corretto 17Brian Hartvigsen
05/10/2023, 10:38 PM@RequiresTypeResolution
class PreferLetOverIfNotNullElseNull(
config: Config = Config.empty
) : Rule(config) {
override val issue = Issue(
"PreferLetOverIfNotNullElseNull",
Severity.Style,
"Using `if (X == null) { } else null` is just a longer form of `X?.let { }`",
Debt.FIVE_MINS
)
override val active: Boolean
get() = true
override fun visitIfExpression(expression: KtIfExpression) {
super.visitIfExpression(expression)
val elseBranch = expression.`else` ?: return
val condition = expression.condition as? KtBinaryExpression
if (condition?.isNonNullCheck() == true && isNullConstant(elseBranch)) {
report(CodeSmell(issue, Entity.from(expression), issue.description))
}
}
}
Colton Idle
05/11/2023, 1:07 PMColor.*
or MaterialTheme.colors.*
in my codebase and instead stick to my custom colors I have defined. What's the best way to enforce this with Detekt?Kirill Zhukov
05/16/2023, 12:14 AMbuild-logic
custom Gradle module with various build conventions. In there I have a gradle plugin extension that applies and configures Detekt Gradle plugin (that works with existing rules). Now, I added my own custom rule set, following official guide, but the rule does not seem to be picked up, what am I missing?
1. create custom Detekt rule, say, MyRule
2. create custom rule set, say, MyRuleSetProvider
that includes MyRule
package com.example
class MyRuleSetProvider : RuleSetProvider {
override val ruleSetId: String = "MyRuleSet"
override fun instance(config: Config): RuleSet {
return RuleSet(
id = ruleSetId,
rules = listOf(
MyRule(config)
)
)
}
}
3. define build-logic/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider
com.example.MyRuleSetProvider
4. define detekt yml config build-logic/resources/config.yml
MyRuleSet:
MyRule:
active: true
ken_kentan
05/17/2023, 7:14 AMInjectDispatcher
in my project, but it seems the rule is not detect well like in the document.
I created a sample project to reproduce the issue https://github.com/ken-kentan/DetektSample/blob/main/src/main/kotlin/Main.kt
Did I miss anything?
16:14:25: Executing 'detekt'...
> Task :detekt UP-TO-DATE
BUILD SUCCESSFUL in 127ms
1 actionable task: 1 up-to-date
16:14:25: Execution finished 'detekt'.
Atul Gupta
05/18/2023, 6:04 PMAbsentOrWrongFileLicense
in my project, my detekt
config.yml
file is inside a convention plugin. But AbsentOrWrongFileLicense
is not detecting anything while If I enable the same rule in detekt
repo AbsentOrWrongFileLicense
is correctly detecting all the violations.
Only difference is that in my setup detekt
integration is inside my custom plugin while in detekt
repo it is configure in top level build.gradle
Below is my setup
class CustomDetektPlugin : Plugin<Project>
{
override fun apply(target: Project)
{
with(target) {
apply<DetektPlugin>()
extensions.configure<DetektExtension> {
// If set to `true` the build does not fail when the
// maxIssues count was reached. Defaults to `false`.
ignoreFailures = false
// point to your custom config defining rules to run, overwriting default behavior
config.setFrom("$rootDir/Configs/config/detekt/detekt.yml")
// a way of suppressing issues before introducing detekt
baseline = file("$projectDir/config/detekt/baseline.xml")
// Specify the base path for file paths in the formatted reports.
// If not set, all file paths reported will be absolute file path.
basePath = projectDir.toString()
// Adds debug output during task execution. `false` by default.
debug = true
parallel = true
buildUponDefaultConfig = true
// Turn this on for auto correcting the code on Gradle build
// autoCorrect = true
}
dependencies.add(CONFIGURATION_DETEKT_PLUGINS, libs.findLibrary("detekt.ktlint").get())
}
}
}
Wilerson Oliveira
05/23/2023, 9:32 AMgammax
05/23/2023, 10:03 AMJavier
05/23/2023, 11:45 AMSerializationException
is marked as SwallowedException
? Even being open, public open class SerializationException : IllegalArgumentException
, the child exceptions are internal
. Should I file a feature request for this as it is the kotlinx serialization library?Sebastian Schuberth
05/24/2023, 7:57 AMjava.lang.NoClassDefFoundError: Could not initialize class io.github.detekt.test.utils.KtTestCompiler
in test for my own Detekt rules. Do I now need to add more than the detekt-test
artifact to testImplementation
?