ronantakizawa/codereview-bench huggingface dataset:
Repository: thunderbird/thunderbird-android
File: feature/onboarding/welcome/src/main/kotlin/app/k9mail/feature/onboarding/welcome/ui/WelcomeContent.kt (Kotlin)

Code before:
                    header = {
                        WelcomeHeaderSection()
                    },
                    footer = {
                        WelcomeFooterSection(
                            showImportButton = showImportButton,
                            onStartClick = onStartClick,
                            onImportClick = onImportClick,
                        )
                    },
                    content = {
                        item {WelcomeTitleItem(title = appName)}
                        item {WelcomeMessageItem()}
                    },
                )
            }



        }
    }
}

@Composable
private fun WelcomeHeaderSection(

){
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .defaultItemModifier()
            .padding(top = MainTheme.spacings.double),
            contentAlignment = Alignment.Center,
    ) {
        WelcomeLogo()
    }

}

@Composable
private fun WelcomeLogo(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))

Review comment (suggestion):
We always add the Modifier to composables. The title could be added here.

```suggestion
    title: String,
    modifier: Modifier = Modifier,
```

Code after:
                },
                footer = {
                    WelcomeFooterSection(
                        showImportButton = showImportButton,
                        onStartClick = onStartClick,
                        onImportClick = onImportClick,
                    )
                },
                content = {
                    item { WelcomeMessageItem() }
                },
            )
        }
    }
}

@Composable
private fun WelcomeHeaderSection(
    title: String,
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier
            .fillMaxWidth()
            .defaultItemModifier()
            .padding(top = MainTheme.spacings.quadruple),
        verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.double),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        WelcomeLogo()
        WelcomeTitleItem(title = title)
    }
}

@Composable
private fun WelcomeLogo(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))
                .size(CIRCLE_SIZE_DP.dp),
        ) {
            Image(
                painter = painterResource(id = MainTheme.images.logo),
                contentDescription = null,
Repository: thunderbird/thunderbird-android
File: feature/onboarding/welcome/src/main/kotlin/app/k9mail/feature/onboarding/welcome/ui/WelcomeContent.kt (Kotlin)

Code before:
                        WelcomeFooterSection(
                            showImportButton = showImportButton,
                            onStartClick = onStartClick,
                            onImportClick = onImportClick,
                        )
                    },
                    content = {
                        item {WelcomeTitleItem(title = appName)}
                        item {WelcomeMessageItem()}
                    },
                )
            }



        }
    }
}

@Composable
private fun WelcomeHeaderSection(

){
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .defaultItemModifier()
            .padding(top = MainTheme.spacings.double),
            contentAlignment = Alignment.Center,
    ) {
        WelcomeLogo()
    }

}

@Composable
private fun WelcomeLogo(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))
                .size(CIRCLE_SIZE_DP.dp),
        ) {
            Image(
                painter = painterResource(id = MainTheme.images.logo),

Review comment (suggestion):
Add the title here.

```suggestion
        WelcomeLogo()
        WelcomeTitleItem(title = title)
```

Code after:
                        onStartClick = onStartClick,
                        onImportClick = onImportClick,
                    )
                },
                content = {
                    item { WelcomeMessageItem() }
                },
            )
        }
    }
}

@Composable
private fun WelcomeHeaderSection(
    title: String,
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier
            .fillMaxWidth()
            .defaultItemModifier()
            .padding(top = MainTheme.spacings.quadruple),
        verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.double),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        WelcomeLogo()
        WelcomeTitleItem(title = title)
    }
}

@Composable
private fun WelcomeLogo(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))
                .size(CIRCLE_SIZE_DP.dp),
        ) {
            Image(
                painter = painterResource(id = MainTheme.images.logo),
                contentDescription = null,
                modifier = Modifier
                    .size(LOGO_SIZE_DP.dp)
                    .align(Alignment.Center),
            )
Repository: thunderbird/thunderbird-android
File: feature/onboarding/welcome/src/main/kotlin/app/k9mail/feature/onboarding/welcome/ui/WelcomeContent.kt (Kotlin)

Code before:
                            onImportClick = onImportClick,
                        )
                    },
                    content = {
                        item {WelcomeTitleItem(title = appName)}
                        item {WelcomeMessageItem()}
                    },
                )
            }



        }
    }
}

@Composable
private fun WelcomeHeaderSection(

){
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .defaultItemModifier()
            .padding(top = MainTheme.spacings.double),
            contentAlignment = Alignment.Center,
    ) {
        WelcomeLogo()
    }

}

@Composable
private fun WelcomeLogo(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))
                .size(CIRCLE_SIZE_DP.dp),
        ) {
            Image(
                painter = painterResource(id = MainTheme.images.logo),
                contentDescription = null,
                modifier = Modifier
                    .size(LOGO_SIZE_DP.dp)

Review comment (suggestion):
Replace the box by a column.
```suggestion
    Column(
        modifier = modifier
            .fillMaxWidth()
            .defaultItemModifier()
            .padding(top = MainTheme.spacings.double),
            contentAlignment = Alignment.Center,
            .padding(top = MainTheme.spacings.quadruple),
        verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.double),
        horizontalAlignment = Alignment.CenterHorizontally,
```

Code after:
                },
                content = {
                    item { WelcomeMessageItem() }
                },
            )
        }
    }
}

@Composable
private fun WelcomeHeaderSection(
    title: String,
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier
            .fillMaxWidth()
            .defaultItemModifier()
            .padding(top = MainTheme.spacings.quadruple),
        verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.double),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        WelcomeLogo()
        WelcomeTitleItem(title = title)
    }
}

@Composable
private fun WelcomeLogo(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))
                .size(CIRCLE_SIZE_DP.dp),
        ) {
            Image(
                painter = painterResource(id = MainTheme.images.logo),
                contentDescription = null,
                modifier = Modifier
                    .size(LOGO_SIZE_DP.dp)
                    .align(Alignment.Center),
            )
        }
    }
}
Repository: thunderbird/thunderbird-android
File: feature/onboarding/welcome/src/main/kotlin/app/k9mail/feature/onboarding/welcome/ui/WelcomeContent.kt (Kotlin)

Code before:

}

@Composable
private fun WelcomeLogo(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))
                .size(CIRCLE_SIZE_DP.dp),
        ) {
            Image(
                painter = painterResource(id = MainTheme.images.logo),
                contentDescription = null,
                modifier = Modifier
                    .size(LOGO_SIZE_DP.dp)
                    .align(Alignment.Center),
            )
        }
    }
}


@Composable
private fun WelcomeTitleItem(
    title: String,
) {
    Box(
        modifier = Modifier
            .defaultItemModifier()
    ) {
        WelcomeTitle(
            title = title,
            modifier = Modifier.defaultItemModifier(),
        )
    }

}

@Composable
private fun WelcomeTitle(
    title: String,
    modifier: Modifier = Modifier,
) {
    Column(

Review comment (suggestion):
Please add the modifier here:

```suggestion
    title: String,
    modifier: Modifier = Modifier,
```

Code after:
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        Box(
            modifier = Modifier
                .clip(CircleShape)
                .background(Color(CIRCLE_COLOR))
                .size(CIRCLE_SIZE_DP.dp),
        ) {
            Image(
                painter = painterResource(id = MainTheme.images.logo),
                contentDescription = null,
                modifier = Modifier
                    .size(LOGO_SIZE_DP.dp)
                    .align(Alignment.Center),
            )
        }
    }
}

@Composable
private fun WelcomeTitleItem(
    title: String,
    modifier: Modifier = Modifier,
) {
    Box(
        modifier = modifier,
    ) {
        WelcomeTitle(
            title = title,
            modifier = Modifier.defaultItemModifier(),
        )
    }
}

@Composable
private fun WelcomeTitle(
    title: String,
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier.padding(horizontal = MainTheme.spacings.quadruple),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        TextDisplayMedium(
            text = title,
            textAlign = TextAlign.Center,
        )
Repository: thunderbird/thunderbird-android
File: feature/onboarding/welcome/src/main/kotlin/app/k9mail/feature/onboarding/welcome/ui/WelcomeContent.kt (Kotlin)

Code before:
            title = title,
            modifier = Modifier.defaultItemModifier(),
        )
    }

}

@Composable
private fun WelcomeTitle(
    title: String,
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier.padding(horizontal = MainTheme.spacings.quadruple),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        TextDisplayMedium(
            text = title,
            textAlign = TextAlign.Center,
        )
    }
}

@Composable
private fun WelcomeMessageItem(
){
    Box(
        modifier = Modifier
            .defaultItemModifier()
    ) {
        WelcomeMessage(
            modifier = Modifier.defaultItemModifier(),
        )
    }

}

@Composable
private fun WelcomeMessage(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = Modifier
            .padding(horizontal = MainTheme.spacings.quadruple)
            .then(modifier),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        TextBodyLarge(
            text = stringResource(id = R.string.onboarding_welcome_text),
            textAlign = TextAlign.Center,
        )

Review comment (suggestion):
Please add the modifier here:

```suggestion
    modifier: Modifier = Modifier,
) {
```

Code after:
@Composable
private fun WelcomeTitle(
    title: String,
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier.padding(horizontal = MainTheme.spacings.quadruple),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        TextDisplayMedium(
            text = title,
            textAlign = TextAlign.Center,
        )
    }
}

@Composable
private fun WelcomeMessageItem(
    modifier: Modifier = Modifier,
) {
    Box(
        modifier = modifier,
    ) {
        WelcomeMessage(
            modifier = Modifier.defaultItemModifier(),
        )
    }
}

@Composable
private fun WelcomeMessage(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = Modifier
            .padding(horizontal = MainTheme.spacings.quadruple)
            .then(modifier),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        TextBodyLarge(
            text = stringResource(id = R.string.onboarding_welcome_text),
            textAlign = TextAlign.Center,
        )
    }
}

@Composable
private fun WelcomeFooterSection(
    showImportButton: Boolean,
    onStartClick: () -> Unit,
    onImportClick: () -> Unit,
Repository: thunderbird/thunderbird-android
File: feature/onboarding/welcome/src/main/kotlin/app/k9mail/feature/onboarding/welcome/ui/WelcomeContent.kt (Kotlin)

Code before:
    }

}

@Composable
private fun WelcomeMessage(
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = Modifier
            .padding(horizontal = MainTheme.spacings.quadruple)
            .then(modifier),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        TextBodyLarge(
            text = stringResource(id = R.string.onboarding_welcome_text),
            textAlign = TextAlign.Center,
        )
    }
}

@Composable
private fun WelcomeFooterSection(
    showImportButton: Boolean,
    onStartClick: () -> Unit,
    onImportClick: () -> Unit
) {
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .padding(top = MainTheme.spacings.quadruple)
    ) {
        WelcomeFooter(
            showImportButton = showImportButton,
            onStartClick = onStartClick,
            onImportClick = onImportClick,
            modifier = Modifier
                .fillMaxWidth()
                .padding(top = MainTheme.spacings.quadruple)
        )
    }
}

@Composable
private fun WelcomeFooter(
    showImportButton: Boolean,
    onStartClick: () -> Unit,
    onImportClick: () -> Unit,
    modifier: Modifier = Modifier,
) {
    Column(

Review comment (suggestion):
Please add the modifier here: 

```suggestion
    onImportClick: () -> Unit,
    modifier: Modifier = Modifier,
```

Code after:
    Column(
        modifier = Modifier
            .padding(horizontal = MainTheme.spacings.quadruple)
            .then(modifier),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        TextBodyLarge(
            text = stringResource(id = R.string.onboarding_welcome_text),
            textAlign = TextAlign.Center,
        )
    }
}

@Composable
private fun WelcomeFooterSection(
    showImportButton: Boolean,
    onStartClick: () -> Unit,
    onImportClick: () -> Unit,
    modifier: Modifier = Modifier,
) {
    Box(
        modifier = modifier
            .fillMaxWidth()
            .padding(top = MainTheme.spacings.quadruple),
    ) {
        WelcomeFooter(
            showImportButton = showImportButton,
            onStartClick = onStartClick,
            onImportClick = onImportClick,
            modifier = Modifier
                .fillMaxWidth()
                .padding(top = MainTheme.spacings.quadruple),
        )
    }
}

@Composable
private fun WelcomeFooter(
    showImportButton: Boolean,
    onStartClick: () -> Unit,
    onImportClick: () -> Unit,
    modifier: Modifier = Modifier,
) {
    Column(
        modifier = modifier.padding(bottom = MainTheme.spacings.double),
        verticalArrangement = Arrangement.spacedBy(MainTheme.spacings.quarter),
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        ButtonFilled(
            text = stringResource(id = R.string.onboarding_welcome_start_button),
            onClick = onStartClick,
Repository: thunderbird/thunderbird-android
File: feature/navigation/drawer/build.gradle.kts (Kotlin)

Code before:
plugins {
    id(ThunderbirdPlugins.Library.androidCompose)
}

android {
    namespace = "app.k9mail.feature.navigation.drawer"
    resourcePrefix = "navigation_drawer_"
}

dependencies {
    implementation(projects.core.mail.folder.api)

    implementation(projects.core.ui.theme.api)
    implementation(projects.core.ui.compose.designsystem)

    implementation(projects.feature.account.avatar)

    implementation(projects.legacy.account)
    implementation(projects.legacy.mailstore)
    implementation(projects.legacy.message)
    implementation(projects.legacy.search)
    implementation(projects.legacy.ui.folder)
    implementation(projects.legacy.core)

    testImplementation(projects.core.ui.compose.testing)
}


Review comment (suggestion):
Our goal is to reduce dependence on legacy code and these dependencies should be avoided where possible.

Code after:
plugins {
    id(ThunderbirdPlugins.Library.androidCompose)
}

android {
    namespace = "app.k9mail.feature.navigation.drawer"
    resourcePrefix = "navigation_drawer_"
}

dependencies {
    implementation(projects.core.mail.folder.api)

    implementation(projects.core.ui.theme.api)
    implementation(projects.core.ui.compose.designsystem)

    implementation(projects.feature.account.avatar)

    implementation(projects.legacy.account)
    implementation(projects.legacy.mailstore)
    implementation(projects.legacy.message)
    implementation(projects.legacy.search)
    implementation(projects.legacy.ui.folder)

    testImplementation(projects.core.ui.compose.testing)
}
Repository: thunderbird/thunderbird-android
File: feature/widget/unread/src/main/kotlin/app/k9mail/feature/widget/unread/UnreadWidgetChooseAccountResultContract.kt (Kotlin)

Code before:
package app.k9mail.feature.widget.unread

import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContract

class UnreadWidgetChooseAccountResultContract : ActivityResultContract<Unit, String?>() {
    override fun createIntent(context: Context, input: Unit): Intent {
        return Intent(context, UnreadWidgetChooseAccountActivity::class.java)
    }

    override fun parseResult(resultCode: Int, intent: Intent?): String? {
        return intent?.getStringExtra(UnreadWidgetChooseAccountActivity.EXTRA_ACCOUNT_UUID)
            .takeIf { resultCode == Activity.RESULT_OK }
    }
}


Review comment (suggestion):
Note for future changes: This doesn't have to be part of the feature module's API surface and as far as I can tell there's no framework reason for this class to be public. So it could be an `internal` class.

Code after:
package app.k9mail.feature.widget.unread

import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContract

internal class UnreadWidgetChooseAccountResultContract : ActivityResultContract<Unit, String?>() {
    override fun createIntent(context: Context, input: Unit): Intent {
        return Intent(context, UnreadWidgetChooseAccountActivity::class.java)
    }

    override fun parseResult(resultCode: Int, intent: Intent?): String? {
        return intent?.getStringExtra(UnreadWidgetChooseAccountActivity.EXTRA_ACCOUNT_UUID)
            .takeIf { resultCode == Activity.RESULT_OK }
    }
}
Repository: thunderbird/thunderbird-android
File: legacy/preferences/src/main/java/app/k9mail/legacy/preferences/DefaultSettingsChangeBroker.kt (Kotlin)

Code before:
package app.k9mail.legacy.preferences

class DefaultSettingsChangeBroker(
    private val subscribers: MutableSet<SettingsChangeSubscriber> = mutableSetOf(),
) : SettingsChangeBroker, SettingsChangePublisher {

    private val lock = Any()

    override fun subscribe(subscriber: SettingsChangeSubscriber) {
        synchronized(lock) {
            subscribers.add(subscriber)
        }
    }

    override fun unsubscribe(subscriber: SettingsChangeSubscriber) {
        synchronized(lock) {
            subscribers.remove(subscriber)
        }
    }

    override fun publish() {
        for (subscriber in subscribers) {
            subscriber.receive()
        }
    }
}


Review comment (suggestion):
This accesses `subscribers` without synchronizing on `lock`. If a subscriber is removed in one thread while this is iterating over subscribers in another thread, a `ConcurrentModificationException` could be thrown.

The problem can be avoided by also wrapping this method body in `synchronized(lock) { … }` or by using `CopyOnWriteArraySet` which can be used without any manual locking/synchronization.

Code after:
package app.k9mail.legacy.preferences

class DefaultSettingsChangeBroker(
    private val subscribers: MutableSet<SettingsChangeSubscriber> = mutableSetOf(),
) : SettingsChangeBroker, SettingsChangePublisher {

    private val lock = Any()

    override fun subscribe(subscriber: SettingsChangeSubscriber) {
        synchronized(lock) {
            subscribers.add(subscriber)
        }
    }

    override fun unsubscribe(subscriber: SettingsChangeSubscriber) {
        synchronized(lock) {
            subscribers.remove(subscriber)
        }
    }

    override fun publish() {
        val currentSubscribers = synchronized(lock) { HashSet(subscribers) }

        for (subscriber in currentSubscribers) {
            subscriber.receive()
        }
    }
}