lilypuchi
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 { .. }
}
Brais Gabin
08/29/2022, 3:05 PMBrais Gabin
08/29/2022, 3:07 PMlilypuchi
08/30/2022, 10:53 PMtwisterrob
09/19/2022, 2:53 PMignoreAnnotated
using FQCN, see https://github.com/TWiStErRob/net.twisterrob.sun/blob/master/config/detekt/detekt.yml