Closed joshafeinberg closed 1 month ago
Not sure if this is just bad code design or if the rule should handle this. This was passing fine on 0.4.5 but failed when I upgraded to 0.4.8
Example Composable:
@Composable fun EarlyReturnComposable(isVisible: Boolean, modifier: Modifier = Modifier) { if (!isVisible) { Text("Shouldn't be visible") return } Text("Should be visible") }
Result:
Composable functions should only be emitting content into the composition from one source at their top level. See https://mrmans0n.github.io/compose-rules/rules/#do-not-emit-multiple-pieces-of-content for more information. (cannot be auto-corrected)
Composable functions should only be emitting content into the composition from one source at their top level.
See https://mrmans0n.github.io/compose-rules/rules/#do-not-emit-multiple-pieces-of-content for more information. (cannot be auto-corrected)
FWIW I'm not a big fan of early returns in composables, but it has some legit use cases so I've added support to detect these kinds of things. The fix should be present in 0.4.9, which I've just released.
Not sure if this is just bad code design or if the rule should handle this. This was passing fine on 0.4.5 but failed when I upgraded to 0.4.8
Example Composable:
Result: