Skip to content

Commit

Permalink
Merge pull request #54 from krzdabrowski/renovate/major-ktlint
Browse files Browse the repository at this point in the history
Update dependency org.jmailen.kotlinter to v4
  • Loading branch information
krzdabrowski authored Jun 15, 2024
2 parents 4adab3f + 1dc8101 commit dbf81d2
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 184 deletions.
65 changes: 65 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# https://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
max_line_length = 130

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true


[*.{java,kt,kts,scala,rs,xml,kt.spec,kts.spec}]
indent_size = 4


[*.{kt,kts}]
# Don't allow any wildcard imports
ij_kotlin_packages_to_use_import_on_demand = unset

# Prevent wildcard imports
ij_kotlin_name_count_to_use_star_import = 99
ij_kotlin_name_count_to_use_star_import_for_members = 99

ktlint_code_style = ktlint_official
ktlint_standard = enabled


# Ignore identifiers enclosed in backticks
ktlint_ignore_back_ticked_identifier = true

# Ignore "Expected newline after last annotation" error
# example: @Inject constructor()
ktlint_standard_annotation = disabled

# Ignore "Function name should start with a lowercase letter (except factory methods) and use camel case" error
# that usually occurs when working with Compose UI
ktlint_standard_function-naming = disabled

# Ignore "A multiline expression should start on a new line" error
# example: when declaring `runTest` in the same line as test name
ktlint_standard_multiline-expression-wrapping = disabled

# Ignore "No empty first line in class body" error
ktlint_standard_no-empty-first-line-in-class-body = disabled

# Ignore "No blank line before" error
ktlint_standard_no-blank-line-in-list = disabled

# Set signature body expression wrapping to default (even if default, it is required for multiline-expression-wrapping)
ktlint_function_signature_body_expression_wrapping = default


[*.md]
trim_trailing_whitespace = false
max_line_length = unset

[gradle/verification-metadata.xml]
indent_size = 3


[*.yml]
ij_yaml_spaces_within_brackets = false
2 changes: 0 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ dependencies {

ksp(libs.hilt.compiler)
ksp(libs.room.compiler)

detektPlugins(libs.detekt.compose.rules)
}

ksp {
Expand Down
2 changes: 0 additions & 2 deletions baseline-profiles/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ baselineProfile {
dependencies {
implementation(libs.test.android.benchmark.macro)
implementation(libs.test.android.junit)

detektPlugins(libs.detekt.compose.rules)
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class BaselineProfileGenerator {
rule.collect(
packageName = InstrumentationRegistry.getArguments().getString("targetAppId")
?: throw IllegalArgumentException("targetAppId not passed as instrumentation runner arg"),

// See: https://d.android.com/topic/performance/baselineprofiles/dex-layout-optimizations
includeInStartupProfile = true,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ class StartupBenchmarks {
val rule = MacrobenchmarkRule()

@Test
fun startupCompilationNone() =
benchmark(CompilationMode.None())
fun startupCompilationNone() = benchmark(CompilationMode.None())

@Test
fun startupCompilationBaselineProfiles() =
benchmark(CompilationMode.Partial(BaselineProfileMode.Require))
fun startupCompilationBaselineProfiles() = benchmark(CompilationMode.Partial(BaselineProfileMode.Require))

private fun benchmark(compilationMode: CompilationMode) {
// The application id for the running build variant is read from the instrumentation arguments.
Expand Down
2 changes: 0 additions & 2 deletions basic-feature/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,4 @@ dependencies {

ksp(libs.hilt.compiler)
kspAndroidTest(libs.hilt.compiler)

detektPlugins(libs.detekt.compose.rules)
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ class RocketsScreenTest {
.assertExists()
}

private fun setUpComposable(
rocketsUiState: RocketsUiState,
) {
private fun setUpComposable(rocketsUiState: RocketsUiState) {
composeTestRule.setContent {
RocketsScreen(
uiState = rocketsUiState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,19 @@ internal object RocketModule {

@Provides
@Singleton
fun provideRocketApi(
retrofit: Retrofit,
): RocketApi {
fun provideRocketApi(retrofit: Retrofit): RocketApi {
return retrofit.create(RocketApi::class.java)
}

@Provides
fun provideGetRocketsUseCase(
rocketRepository: RocketRepository,
): GetRocketsUseCase {
fun provideGetRocketsUseCase(rocketRepository: RocketRepository): GetRocketsUseCase {
return GetRocketsUseCase {
getRockets(rocketRepository)
}
}

@Provides
fun provideRefreshRocketsUseCase(
rocketRepository: RocketRepository,
): RefreshRocketsUseCase {
fun provideRefreshRocketsUseCase(rocketRepository: RocketRepository): RefreshRocketsUseCase {
return RefreshRocketsUseCase {
refreshRockets(rocketRepository)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import kotlinx.coroutines.flow.Flow

interface RocketRepository {
fun getRockets(): Flow<List<Rocket>>

suspend fun refreshRockets()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ private const val RETRY_TIME_IN_MILLIS = 15_000L

fun interface GetRocketsUseCase : () -> Flow<Result<List<Rocket>>>

fun getRockets(
rocketRepository: RocketRepository,
): Flow<Result<List<Rocket>>> = rocketRepository
fun getRockets(rocketRepository: RocketRepository): Flow<Result<List<Rocket>>> = rocketRepository
.getRockets()
.map {
Result.success(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import eu.krzdabrowski.starter.core.utils.resultOf

fun interface RefreshRocketsUseCase : suspend () -> Result<Unit>

suspend fun refreshRockets(
rocketRepository: RocketRepository,
): Result<Unit> = resultOf {
suspend fun refreshRockets(rocketRepository: RocketRepository): Result<Unit> = resultOf {
rocketRepository.refreshRockets()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package eu.krzdabrowski.starter.basicfeature.presentation

sealed class RocketsIntent {
data object RefreshRockets : RocketsIntent()

data class RocketClicked(val uri: String) : RocketsIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ class RocketsViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
rocketsInitialState: RocketsUiState,
) : BaseViewModel<RocketsUiState, PartialState, RocketsEvent, RocketsIntent>(
savedStateHandle,
rocketsInitialState,
) {
savedStateHandle = savedStateHandle,
initialState = rocketsInitialState,
) {

init {
observeRockets()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import androidx.compose.ui.text.style.TextAlign
import eu.krzdabrowski.starter.basicfeature.R

@Composable
fun RocketsErrorContent(
modifier: Modifier = Modifier,
) {
fun RocketsErrorContent(modifier: Modifier = Modifier) {
Box(
modifier = modifier
.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
fun RocketsLoadingPlaceholder(
modifier: Modifier = Modifier,
) {
fun RocketsLoadingPlaceholder(modifier: Modifier = Modifier) {
Spacer(
modifier = modifier
.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import eu.krzdabrowski.starter.core.utils.collectWithLifecycle
import kotlinx.coroutines.flow.Flow

@Composable
fun RocketsRoute(
viewModel: RocketsViewModel = hiltViewModel(),
) {
fun RocketsRoute(viewModel: RocketsViewModel = hiltViewModel()) {
HandleEvents(viewModel.getEvents())
val uiState by viewModel.uiState.collectAsStateWithLifecycle()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ class RocketsViewModelTest {
}
}

private fun setUpRocketsViewModel(
initialUiState: RocketsUiState = RocketsUiState(),
) {
private fun setUpRocketsViewModel(initialUiState: RocketsUiState = RocketsUiState()) {
objectUnderTest = RocketsViewModel(
getRocketsUseCase,
refreshRocketsUseCase,
Expand Down
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ allprojects {
config.setFrom(files("$rootDir/gradle/detekt.yml"))
}
}

buildscript {
dependencies {
classpath(libs.compose.rules)
}
}
2 changes: 0 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,4 @@ dependencies {

ksp(libs.hilt.compiler)
kspAndroidTest(libs.hilt.compiler)

detektPlugins(libs.detekt.compose.rules)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import dagger.hilt.android.testing.HiltTestApplication

class HiltTestRunner : AndroidJUnitRunner() {

override fun newApplication(cl: ClassLoader?, name: String?, context: Context?): Application {
override fun newApplication(
cl: ClassLoader?,
name: String?,
context: Context?,
): Application {
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.activity.viewModels
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.lifecycle.ViewModel

inline fun <reified T : ViewModel> AndroidComposeTestRule<*, *>.getHiltTestViewModel() =
activity
.viewModels<T>()
.value
inline fun <reified T : ViewModel> AndroidComposeTestRule<*, *>.getHiltTestViewModel() = activity
.viewModels<T>()
.value
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ internal object CoroutinesScopeModule {

@Singleton
@Provides
fun provideCoroutineExceptionHandler(): CoroutineExceptionHandler =
CoroutineExceptionHandler { _, throwable ->
Timber.e(throwable)
}
fun provideCoroutineExceptionHandler(): CoroutineExceptionHandler = CoroutineExceptionHandler { _, throwable ->
Timber.e(throwable)
}

@MainImmediateScope
@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ fun AndroidStarterTheme(
}

@Composable
fun pickColorScheme(
darkTheme: Boolean,
): ColorScheme = when {
fun pickColorScheme(darkTheme: Boolean): ColorScheme = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ sealed class NavigationDestination(
val route: String,
) {
data object Rockets : NavigationDestination("rocketsDestination")

data object Back : NavigationDestination("navigationBack")
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ internal object NetworkModule {

@Provides
@Singleton
fun provideRetrofit(
okHttpClient: OkHttpClient,
): Retrofit {
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
val json = Json {
ignoreUnknownKeys = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import kotlinx.coroutines.flow.Flow

interface EventDelegate<EVENT> {
fun getEvents(): Flow<EVENT>

suspend fun setEvent(event: EVENT)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package eu.krzdabrowski.starter.core.presentation.mvi
import kotlinx.coroutines.flow.Flow

interface IntentDelegate<INTENT, PARTIAL_UI_STATE> {
fun getIntents(
mapOperation: (INTENT) -> Flow<PARTIAL_UI_STATE>,
): Flow<PARTIAL_UI_STATE>
fun getIntents(mapOperation: (INTENT) -> Flow<PARTIAL_UI_STATE>): Flow<PARTIAL_UI_STATE>

suspend fun setIntent(intent: INTENT)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class IntentDelegateImpl<INTENT, PARTIAL_UI_STATE> : IntentDelegate<INTENT, PART
private val intentsFlowListenerStarted = CompletableDeferred<Unit>()
private val intentsFlow = MutableSharedFlow<INTENT>()

override fun getIntents(
mapOperation: (INTENT) -> Flow<PARTIAL_UI_STATE>,
): Flow<PARTIAL_UI_STATE> = intentsFlow
override fun getIntents(mapOperation: (INTENT) -> Flow<PARTIAL_UI_STATE>): Flow<PARTIAL_UI_STATE> = intentsFlow
.onSubscription { intentsFlowListenerStarted.complete(Unit) }
.flatMapConcurrently(
transform = mapOperation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ class InternalChangesDelegateImpl<PARTIAL_UI_STATE> : InternalChangesDelegate<PA
private val internalChangesPartialStateFlowListenerStarted = CompletableDeferred<Unit>()
private val internalChangesPartialStateFlow = MutableSharedFlow<PARTIAL_UI_STATE>()

override fun getInternalChanges(): Flow<PARTIAL_UI_STATE> =
internalChangesPartialStateFlow
.onSubscription { internalChangesPartialStateFlowListenerStarted.complete(Unit) }
override fun getInternalChanges(): Flow<PARTIAL_UI_STATE> = internalChangesPartialStateFlow
.onSubscription { internalChangesPartialStateFlowListenerStarted.complete(Unit) }

override suspend fun setInternalChanges(vararg internalChangesFlows: Flow<PARTIAL_UI_STATE>) {
internalChangesPartialStateFlowListenerStarted.await()
Expand Down
Loading

0 comments on commit dbf81d2

Please sign in to comment.