Created
June 9, 2025 15:45
-
-
Save euri16/2f907f6b56d2bcd588765f6f9881e5cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LaunchedEffectWithEffectParamRule(config: Config) : Rule(config) { | |
| // ... | |
| override fun visitCallExpression(expression: KtCallExpression) { | |
| super.visitCallExpression(expression) | |
| val calleeName = expression.calleeExpression?.text ?: return | |
| if (calleeName != "LaunchedEffect") return | |
| val argumentList = expression.valueArguments | |
| if (argumentList.isEmpty()) return | |
| val firstArg = argumentList.first().text | |
| // Check if any of the common effect-like names is present in the argument | |
| if (effectNameCandidates.any { name -> firstArg.contains(name, ignoreCase = true) }) { | |
| report( | |
| CodeSmell( | |
| issue, | |
| Entity.from(expression), | |
| message = "Consider using LaunchedUiEffectHandler instead of manually " + | |
| "handling one-off events with LaunchedEffect and effect-related " + | |
| "parameters.", | |
| ), | |
| ) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment