Skip to content

Commit

Permalink
Merge pull request #228 from DroidKaigi/add_compose_lint
Browse files Browse the repository at this point in the history
Add Compose Lint
  • Loading branch information
takahirom authored Jul 2, 2023
2 parents b12d307 + 272843a commit 6251dac
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 17 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ jobs:

- uses: ./.github/actions/setup-java

- name: Check lint
run: ./gradlew lintDebug --stacktrace

- name: Upload lint reports
if: always()
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: lint-reports
path: build/lint-reports

- name: Build all build type and flavor permutations
run: ./gradlew assemble --stacktrace

Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/Format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ jobs:
- uses: ./.github/actions/setup-java
- name: Check spotless
run: ./gradlew spotlessCheck --stacktrace

- name: Check lint
run: ./gradlew lintDebug --stacktrace

- name: Upload lint reports
if: always()
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: lint-reports
path: build/lint-reports
2 changes: 1 addition & 1 deletion .github/workflows/WorkflowHook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
recreate: true
message: >
Hi @${{ github.event.workflow_run.actor.login }}!
Codes seem to be unformatted. Please run `./gradlew spotlessKotlinApply` to fix this issue.
Codes seem to be unformatted. To resolve this issue, please run `./gradlew spotlessKotlinApply` and fix the results of ./gradlew lintDebug..
Thank you for your contribution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import io.github.droidkaigi.confsched2023.main.MainScreen
import io.github.droidkaigi.confsched2023.sessions.TimetableScreen

@Composable
fun KaigiApp() {
fun KaigiApp(modifier: Modifier = Modifier) {
KaigiTheme {
val systemUiController = rememberSystemUiController()
val useDarkIcons = !isSystemInDarkTheme()
Expand All @@ -31,7 +31,7 @@ fun KaigiApp() {
}

Surface(
modifier = Modifier.fillMaxSize(),
modifier = modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
val navController = rememberNavController()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AndroidComposePlugin : Plugin<Project> {
testImplementation(libs.findLibrary("composeUiTestJunit4"))
debugImplementation(libs.findLibrary("composeUiTooling"))
debugImplementation(libs.findLibrary("composeUiTestManifest"))
lintChecks(libs.findLibrary("composeLintCheck"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ fun DependencyHandlerScope.testImplementation(
add("testImplementation", artifact.get())
}

fun DependencyHandlerScope.lintChecks(
artifact: Optional<Provider<MinimalExternalModuleDependency>>
) {
add("lintChecks", artifact.get())
}

private fun DependencyHandlerScope.api(
artifact: Optional<Provider<MinimalExternalModuleDependency>>
) {
Expand Down
1 change: 1 addition & 0 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ kotlin {
}

dependencies {
lintChecks(libs.findLibrary("composeLintCheck").get())
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const val MainScreenTestTag = "MainScreen"
@Composable
fun MainScreen(
timetableScreen: @Composable () -> Unit,
viewModel: MainScreenViewModel = hiltViewModel<MainScreenViewModel>(),
) {
val viewModel: MainScreenViewModel = hiltViewModel<MainScreenViewModel>()
val uiState by viewModel.uiState.collectAsState()
val snackbarHostState = SnackbarHostState()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const val TimetableScreenTestTag = "TimetableScreen"
@Composable
fun TimetableScreen(
onContributorsClick: () -> Unit,
viewModel: TimetableScreenViewModel = hiltViewModel<TimetableScreenViewModel>(),
) {
val viewModel: TimetableScreenViewModel = hiltViewModel<TimetableScreenViewModel>()
val uiState by viewModel.uiState.collectAsState()
val snackbarHostState = SnackbarHostState()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ const val TimetableUiTypeChangeButtonTestTag = "TimetableUiTypeChangeButton"

@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun TimetableTopArea(state: TimetableScreenScrollState, onTimetableUiChangeClick: () -> Unit) {
Column {
fun TimetableTopArea(
state: TimetableScreenScrollState,
onTimetableUiChangeClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(modifier = modifier) {
// TODO: Implement TopAppBar design
TopAppBar(
title = {
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ composeUiTestJunit4 = { module = "androidx.compose.ui:ui-test-junit4", version.r
composeUiTooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
composeUiTestManifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }
composeHiltNavigtation = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "composeHiltNavigatiaon" }
composeLintCheck = { module = "com.slack.lint.compose:compose-lint-checks", version = "1.2.0" }

accompanistSystemUiController = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }

Expand Down

0 comments on commit 6251dac

Please sign in to comment.