stojan
01/06/2024, 12:12 PMcollectAsState()
that's useful on other platforms, but probably wrong most of the time on Android. On Android we should be using collectAsStateWithLifecycle()
. This is where a detekt rule might help.
The way I see it, it can be one rule that covers both. And it has a deny list of functions/imports that the user can configure to fail the build.
Are you aware if something like this exists? Would detekt be the right tool to implement this?
Thanksmarschwar
01/06/2024, 1:16 PMForbiddenMethodCall
rules.
# example from the <https://github.com/detekt/detekt/blob/main/config/detekt/detekt.yml>
ForbiddenImport:
active: true
imports:
- value: 'org.junit.jupiter.api.Assertions*'
reason: 'Use AssertJ assertions instead.'
- value: 'org.junit.jupiter.api.assertThrows'
reason: 'Use AssertJ assertThatCode { }.isInstanceOf() or assertThatExceptionOfType().isThrownBy { } instead.'
- value: 'java.util.stream.*'
reason: "Use Kotlin's sequences instead."
ForbiddenMethodCall:
active: true
methods:
- 'kotlin.io.print'
- 'kotlin.io.println'
- 'java.net.URL.openStream'
- 'java.lang.Class.getResourceAsStream'
- 'java.lang.ClassLoader.getResourceAsStream'
- 'org.jetbrains.kotlin.diagnostics.DiagnosticUtils.getLineAndColumnInPsiFile'
stojan
01/06/2024, 2:28 PMAtul Gupta
01/06/2024, 7:45 PMthat's useful on other platforms, but probably wrong most of the time on Android. On Android we should be
in detekt you have to set different config in each repo. I don’t know anyway where we can override one rule config differently in each repo