# kotlin:S5612 should adjust its behavior for function with @Composable annotations

**URL:** <https://community.sonarsource.com/t/kotlin-s5612-should-adjust-its-behavior-for-function-with-composable-annotations/148135>\
**Category:** Report False-positive / False-negative...\
**Tags:** android, rules, kotlin, sonarqube, rule-changes\
**Created:** [September 4, 2025, 11:20am UTC](https://community.sonarsource.com/t/kotlin-s5612-should-adjust-its-behavior-for-function-with-composable-annotations/148135 "2025-09-04T11:20:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qheb](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/qheb/32/72125_2.png) [@Qheb](https://community.sonarsource.com/u/Qheb)\
**Post date:** [September 4, 2025, 11:20am UTC](https://community.sonarsource.com/t/kotlin-s5612-should-adjust-its-behavior-for-function-with-composable-annotations/148135/1 "2025-09-04T11:20:34Z")

</div>

- What language is this for?

- Which rule?

- Are you using

- Why do you believe it’s a false-positive/false-negative?

With Jetpack Compose, UI is built by nesting composable functions within trailing lambdas. These lambdas are not for complex logic; they are for declaring a UI hierarchy. It is standard practice for a screen’s content lambda to exceed the default 20-line limit, even for moderately complex views.

- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

```kotlin

@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun SettingsScreen() {
    var notificationsEnabled by remember { mutableStateOf(true) }
    var darkModeEnabled by remember { mutableStateOf(false) }
    var dataSaverEnabled by remember { mutableStateOf(false) }
    var autoPlayVideos by remember { mutableStateOf(true) }
    var showProfilePublicly by remember { mutableStateOf(false) }

    Scaffold(
        topBar = {
            TopAppBar(title = { Text("App Settings") })
        }
    ) { paddingValues ->
        // This Column's content lambda will trigger the violation.
        // It contains more than 20 lines of declarative UI code.
        Column(
            modifier = Modifier
                .padding(paddingValues)
                .padding(16.dp),
            verticalArrangement = Arrangement.spacedBy(16.dp)
        ) {
            SettingItem(
                title = "Enable Notifications",
                checked = notificationsEnabled,
                onCheckedChange = { notificationsEnabled = it }
            )
            SettingItem(
                title = "Dark Mode",
                checked = darkModeEnabled,
                onCheckedChange = { darkModeEnabled = it }
            )
            SettingItem(
                title = "Data Saver",
                checked = dataSaverEnabled,
                onCheckedChange = { dataSaverEnabled = it }
            )
            SettingItem(
                title = "Auto-play Videos",
                checked = autoPlayVideos,
                onCheckedChange = { autoPlayVideos = it }
            )
            SettingItem(
                title = "Show Profile Publicly",
                checked = showProfilePublicly,
                onCheckedChange = { showProfilePublicly = it }
            )
        }
    }
}

@Composable
private fun SettingItem(
    title: String,
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit
) {
    Row(
        modifier = Modifier.fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.SpaceBetween
    ) {
        Text(text = title)
        Switch(checked = checked, onCheckedChange = onCheckedChange)
    }
}

```

I believe the behavior of this rule should be quite like for [kotlin:s107](https://community.sonarsource.com/t/kotlin-s107-should-ignore-methods-with-composable-annotation/117826) where it is considered to add a separate threshold for compose functions.

---

<div class="post-metadata">

**Author:** ![maksim.grebeniuk](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@maksim.grebeniuk](https://community.sonarsource.com/u/maksim.grebeniuk)\
**Post date:** [September 5, 2025, 7:36am UTC](https://community.sonarsource.com/t/kotlin-s5612-should-adjust-its-behavior-for-function-with-composable-annotations/148135/4 "2025-09-05T07:36:36Z")

</div>

Hello @Qheb ,

First of all - welcome to the community and big thanks for the reporting.  
We created a ticket to fix the problem and will work on it in one of the future releases.

---

<div class="post-metadata">

**Author:** ![Qheb](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/qheb/32/72125_2.png) [@Qheb](https://community.sonarsource.com/u/Qheb)\
**Post date:** [September 5, 2025, 8:18am UTC](https://community.sonarsource.com/t/kotlin-s5612-should-adjust-its-behavior-for-function-with-composable-annotations/148135/6 "2025-09-05T08:18:30Z")

</div>

Hi Maksim,  
That’s great, thank you for the quick response! 🙂
