Lucas Mo
07/21/2022, 8:44 PMLucas Mo
07/21/2022, 8:45 PMDavide Giuseppe Farella
07/22/2022, 12:17 PMdetekt.config
accepts multiple files, but I’m unsure how it works. Do they have a particular priority? How could we add more than 1 config file to the Detekt plugin?yousef shaaban
07/25/2022, 11:22 AMJavier
07/25/2022, 12:49 PMDavide Giuseppe Farella
07/27/2022, 4:28 PMprivate fun isLambda(parameter: KtParameter) = ") -> " in parameter.text
Note that isLambdaParameter
and isFunctionTypeParameter
evaluate the KtParameter
as a parameter of a lambda blockgammax
07/17/2022, 2:21 PMalp
08/01/2022, 11:02 PMBaseExtension
to access some information and it works fine on the my sample app project since I can find the extension via
extensions.findByType(BaseExtension::class.java) // returns null in functional test but works fine on the actual app project
but when I use GradleRunner
for my plugin’s functional test, the expression above returns null
even though I can find it via:
extensions.findByName("android") // not null in both cases
I was looking for a possible problem and found detekt project that has functional tests for android scenario and was wondering if you can suggest something. In my functional test I use this setup:
File(projectRoot, "settings.gradle")
.apply {
writeText(
"""
include ':app'
"""
)
}
File(projectRoot, "build.gradle")
.apply {
writeText(
"""
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.32"
}
}
"""
)
}
val appModule = File(projectRoot, "app").apply { mkdir() }
File(appModule, "build.gradle")
.apply {
writeText(
"""
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("my.custom.plugin") // plugin under test
}
android {
compileSdkVersion 30
defaultConfig {
applicationId "<http://my.custom.plugin.app|my.custom.plugin.app>"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
}
"""
)
}
samp
08/02/2022, 6:37 PMcesards
08/03/2022, 3:32 PMcesards
08/03/2022, 3:40 PMexcludes: &generatedCode
to exclude generated code from each of the rules that apply.
I thought there might be a way nowadays to exclude generated code from all rules so after looking into it, I found a closed issue about the topic:
https://github.com/detekt/detekt/issues/4743
so I went with:
detekt {
source = files("src/main/kotlin", "src/test/kotlin", "src/androidTest/kotlin")
}
but that didn’t make it.
I saw another dev asking about this about two months ago but I’m not sure it got resolved: https://kotlinlang.slack.com/archives/C88E12QH4/p1654877805110359
I also landed on another thread where Nicola brought up:
Yeah I believe thehas no effect because we changed how we collect the source sets.exclude
You’ll have to exclude using a like a package path or so. What happens is that excluded are computed for relative paths that are provided by the sourcesset from AGPI’m not sure I completely follow the implications of the changes. I could assume this is a generic issue for most of us. Any chance you could share how you deal with this, if that’s the case? Thanks in advance 🙏
ephemient
08/08/2022, 12:35 PMMarcelo Hernandez
08/10/2022, 11:25 PMandroidx.paging.compose.items
using ForbiddenMethodCall
instead of ForbiddenImport
, what pattern would I have to use given the following signature:
public fun <T : Any> LazyListScope.items(
items: LazyPagingItems<T>,
key: ((item: T) -> Any)? = null,
itemContent: @Composable LazyItemScope.(value: T?) -> Unit
)
Zac Sweers
08/13/2022, 4:43 PMJoe
08/15/2022, 7:12 PMInjectDispatcher
rule, should the following violate it:
class MyRepository(val dispatcher: CoroutineDispatcher) {
@Inject // mark this constructor as the one used by guice at runtime, tests can still inject a TestDispatcher using the primary constructor
constructor() : this(<http://Dispatchers.IO|Dispatchers.IO>)
}
This is basically equivalent to class MyRepository(dispatcher: CoroutineDispatcher = <http://Dispatchers.IO|Dispatchers.IO>)
but still triggers the detekt rule. Or am I missing a difference?Mahmoud Ahmed
08/20/2022, 11:21 AMdimsuz
08/26/2022, 2:26 PMbuild/generated/sqldelight/code.../SomeFile.kt
and Detekt analyzes it and prints errors. How should I instruct it to ignore build/generated
? I recall there was some config option in gradle plugin, but cannot find it in the manual, maybe it got deprecated/removed.dimsuz
08/26/2022, 2:45 PMNamedArguments
violation for stuff like this
combine(myFlow, otherFlow, anotherFlow, ::Triple)
I don't want to turn this into
combine(flow = myFlow, flow2 = otherFlow, flow3 = anotherFlow, transform = ::Triple)
Luckily I've found ignoreFunction
is a thing. But when I do
NamedArguments:
ignoreFunction:
- kotlinx.coroutines.flow.combine
errors don't go away. Tried wrapping it in single quotes, tried doing ignoreFunction: [ 'kotlinx...combine' ]
instead, still nothing. Is this a bug? this function is not part of some class, it's a top-level oneRichard Gomez
08/27/2022, 12:06 AMTooGenericExceptionCaught
? It's flagging this as being too generic, but IndexOutOfBoundsException
seems pretty appropriate.
https://github.com/rgmz/NewPipe/blob/75917c7f61cde0537075b3e1c5442cdf27755026/app/src/main/java/org/schabi/newpipe/info_list/StreamSegmentAdapter.kt#L54lilypuchi
08/29/2022, 10:00 AMclass LayoutModifierRequiredRule: Rule() {
..
override fun visitNamedFunction(function: KtFunction) {
super.visitNamedFunction(function)
// ignore non-@Composable functions
if (!function.hasAnnotation("Composable")) { return }
val doesModifierParameterExist = function.valueParameters.any { it.name == "Modifier" }
if (!doesModifierParameterExist) {
report(..)
}
}
}
and in detekt.yml I’ve added the rule as following
LayoutModifierRequiredRule:
active: true
ignoreAnnotated: ['Preview']
Even though I mention to ignore @Preview annotation, it still highlights the @Preview functions. Am I doing anything wrong here ?
@Preview
@Composable
fun PreviewScreen() {
MaterialTheme { .. }
}
PJ Walstrom
08/30/2022, 6:44 AMLandry Norris
08/31/2022, 7:30 PMColton Idle
09/13/2022, 12:04 AMSebastian Schuberth
09/15/2022, 12:37 PMigor.wojda
09/16/2022, 9:28 AMdetekt
task does not verify Android project modules (Gradle subprojects. including the app
default one)?dimsuz
09/21/2022, 12:46 AMeygraber
09/21/2022, 4:48 AMcontinuation_indent_size
https://kotlinlang.slack.com/archives/CKS3XG0LS/p1663735640538999mkrussel
09/22/2022, 8:04 PMKDocReferencesNonPublicProperty
is generating false positives when I use the ability to set the text for a code link to the name of a private property.
This is a bad example but it shows that the property workItem
is being accessed in KDoc.gammax
09/23/2022, 10:21 AMigor.wojda
09/23/2022, 10:43 AMigor.wojda
09/23/2022, 10:43 AMMarek Czerwinski
09/23/2022, 10:51 AMgammax
09/23/2022, 11:16 AMigor.wojda
09/23/2022, 11:37 AMdetekt-formating
rule set. I added this manually and it had worked.
@gammax is there a detekt check to make sure that custom config file contains all of the rules? (kid of detekt config meta check)
As you see it is easy to miss detekt-formating
rule set ot upgrade detekt without updating config files (thus config for some rules will stay kind of hidden)schalkms
09/24/2022, 9:30 AMigor.wojda
09/24/2022, 10:53 AM