Skip to content

Commit 3c4a09b

Browse files
committed
Bump Spotless
1 parent 08b95b6 commit 3c4a09b

File tree

118 files changed

+412
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+412
-752
lines changed

android/conventions/src/main/kotlin/ribs.spotless-convention.gradle.kts

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919

2020
val libs = the<org.gradle.accessors.dm.LibrariesForLibs>()
2121

22-
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
22+
spotless {
2323
format("misc") {
2424
target("**/*.md", "**/.gitignore")
2525
trimTrailingWhitespace()
@@ -31,6 +31,7 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> {
3131
mapOf(
3232
"indent_size" to "2",
3333
"continuation_indent_size" to "4",
34+
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
3435
)
3536
)
3637
ktfmt(libs.versions.ktfmt.get()).googleStyle()
@@ -40,7 +41,7 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> {
4041
}
4142
java {
4243
target("src/*/java/**/*.java")
43-
googleJavaFormat(libs.versions.gjf.get())
44+
googleJavaFormat(libs.versions.google.java.format.get())
4445
licenseHeaderFile(rootProject.file("config/spotless/copyright.java"))
4546
removeUnusedImports()
4647
trimTrailingWhitespace()

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootActivity.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ import motif.ScopeFactory
2525

2626
class RootActivity : RibActivity() {
2727

28-
override fun createRouter(parentViewGroup: ViewGroup): ViewRouter<*, *> {
29-
return ScopeFactory.create(Parent::class.java)
28+
override fun createRouter(parentViewGroup: ViewGroup): ViewRouter<*, *> =
29+
ScopeFactory.create(Parent::class.java)
3030
.rootScope(this, findViewById(android.R.id.content))
3131
.router()
32-
}
3332

3433
@motif.Scope
3534
interface Parent : Creatable<NoDependencies> {

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootRouter.kt

+2-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ package com.uber.rib.compose.root
1818
import com.uber.rib.compose.root.main.MainRouter
1919
import com.uber.rib.core.BasicViewRouter
2020

21-
class RootRouter(
22-
view: RootView,
23-
interactor: RootInteractor,
24-
private val scope: RootScope,
25-
) : BasicViewRouter<RootView, RootInteractor>(view, interactor) {
21+
class RootRouter(view: RootView, interactor: RootInteractor, private val scope: RootScope) :
22+
BasicViewRouter<RootView, RootInteractor>(view, interactor) {
2623

2724
private var mainRouter: MainRouter? = null
2825

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootScope.kt

+6-12
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,17 @@ interface RootScope {
4141

4242
abstract fun presenter(): EmptyPresenter
4343

44-
fun view(parentViewGroup: ViewGroup): RootView {
45-
return RootView(parentViewGroup.context)
46-
}
44+
fun view(parentViewGroup: ViewGroup): RootView = RootView(parentViewGroup.context)
4745

4846
@Expose
49-
fun analyticsClient(activity: RibActivity): AnalyticsClient {
50-
return AnalyticsClientImpl(activity.application)
51-
}
47+
fun analyticsClient(activity: RibActivity): AnalyticsClient =
48+
AnalyticsClientImpl(activity.application)
5249

5350
@Expose
54-
fun experimentClient(activity: RibActivity): ExperimentClient {
55-
return ExperimentClientImpl(activity.application)
56-
}
51+
fun experimentClient(activity: RibActivity): ExperimentClient =
52+
ExperimentClientImpl(activity.application)
5753

5854
@Expose
59-
fun loggerClient(activity: RibActivity): LoggerClient {
60-
return LoggerClientImpl(activity.application)
61-
}
55+
fun loggerClient(activity: RibActivity): LoggerClient = LoggerClientImpl(activity.application)
6256
}
6357
}

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/RootView.kt

+3-6
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@ import android.widget.TextView
2323

2424
class RootView
2525
@JvmOverloads
26-
constructor(
27-
context: Context,
28-
attrs: AttributeSet? = null,
29-
defStyle: Int = 0,
30-
) : FrameLayout(context, attrs, defStyle) {
26+
constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
27+
FrameLayout(context, attrs, defStyle) {
3128

3229
init {
3330
setBackgroundColor(Color.RED)
3431
addView(
3532
TextView(context).apply {
3633
text = "root (view)"
3734
setTextColor(Color.WHITE)
38-
},
35+
}
3936
)
4037
}
4138
}

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/AuthStream.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import kotlinx.coroutines.flow.asStateFlow
2020
import kotlinx.coroutines.flow.update
2121

2222
class AuthStream {
23-
private val _authFlow = MutableStateFlow(AuthInfo(false, "", ""))
24-
private val authFlow = _authFlow.asStateFlow()
23+
private val mutableAuthFlow = MutableStateFlow(AuthInfo(false, "", ""))
24+
private val authFlow = mutableAuthFlow.asStateFlow()
2525

2626
fun observe() = authFlow
2727

2828
fun accept(value: AuthInfo) {
29-
_authFlow.update { value }
29+
mutableAuthFlow.update { value }
3030
}
3131
}
3232

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/MainScope.kt

+3-6
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@ interface MainScope {
4646
analyticsClient: AnalyticsClient,
4747
experimentClient: ExperimentClient,
4848
loggerClient: LoggerClient,
49-
): ComposePresenter {
50-
return object : ComposePresenter() {
49+
): ComposePresenter =
50+
object : ComposePresenter() {
5151
override val composable = @Composable { MainView(childContent) }
5252
}
53-
}
5453

55-
fun view(parentViewGroup: ViewGroup): ComposeView {
56-
return ComposeView(parentViewGroup.context)
57-
}
54+
fun view(parentViewGroup: ViewGroup): ComposeView = ComposeView(parentViewGroup.context)
5855

5956
abstract fun childContent(): MainRouter.ChildContent
6057

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/MainView.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ fun MainView(childContent: MainRouter.ChildContent) {
3939
Modifier.fillMaxSize().padding(all = 4.dp).padding(top = 14.dp).background(Color(0xFFFFA500)),
4040
) {
4141
Text("Main RIB (Compose w/ CompView)")
42-
Box(
43-
modifier = Modifier.fillMaxWidth().weight(1.0f).padding(4.dp).background(Color.Yellow),
44-
) {
42+
Box(modifier = Modifier.fillMaxWidth().weight(1.0f).padding(4.dp).background(Color.Yellow)) {
4543
childContent.fullScreenSlot.value.invoke()
4644
}
4745
}

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/LoggedInScope.kt

+4-6
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,16 @@ interface LoggedInScope {
4848
fun presenter(
4949
eventStream: EventStream<LoggedInEvent>,
5050
childContent: LoggedInRouter.ChildContent,
51-
): ComposePresenter {
52-
return object : ComposePresenter() {
51+
): ComposePresenter =
52+
object : ComposePresenter() {
5353
override val composable = @Composable { LoggedInView(eventStream, childContent) }
5454
}
55-
}
5655

5756
fun eventStream() = EventStream<LoggedInEvent>()
5857

5958
@Expose
60-
fun scoreSteam(authInfo: AuthInfo): ScoreStream {
61-
return ScoreStream(authInfo.playerOne, authInfo.playerTwo)
62-
}
59+
fun scoreSteam(authInfo: AuthInfo): ScoreStream =
60+
ScoreStream(authInfo.playerOne, authInfo.playerTwo)
6361

6462
@Expose
6563
abstract fun startGameListener(interactor: LoggedInInteractor): OffGameInteractor.Listener

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/LoggedInView.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ fun LoggedInView(
4646
) {
4747
Text("Logged In! (Compose RIB)")
4848
Spacer(Modifier.height(16.dp))
49-
Box(
50-
modifier = Modifier.fillMaxWidth().weight(1.0f).padding(4.dp).background(Color.LightGray),
51-
) {
49+
Box(modifier = Modifier.fillMaxWidth().weight(1.0f).padding(4.dp).background(Color.LightGray)) {
5250
childContent.fullScreenSlot.value.invoke()
5351
}
5452
CustomButton(

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/ScoreStream.kt

+3-9
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,12 @@ import kotlinx.coroutines.withContext
2323

2424
class ScoreStream(playerOne: String, playerTwo: String) {
2525

26-
private val _scoresFlow =
27-
MutableStateFlow(
28-
mapOf(
29-
playerOne to 0,
30-
playerTwo to 0,
31-
),
32-
)
33-
private val scoresFlow = _scoresFlow.asStateFlow()
26+
private val mutableScoresFlow = MutableStateFlow(mapOf(playerOne to 0, playerTwo to 0))
27+
private val scoresFlow = mutableScoresFlow.asStateFlow()
3428

3529
suspend fun addVictory(userName: String) =
3630
withContext(RibDispatchers.Default) {
37-
_scoresFlow.update { scores ->
31+
mutableScoresFlow.update { scores ->
3832
scores
3933
.toMutableMap()
4034
.apply {

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/offgame/OffGameInteractor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class OffGameInteractor(
5555
currentState.copy(
5656
playerOneWins = it[currentState.playerOne] ?: 0,
5757
playerTwoWins = it[currentState.playerTwo] ?: 0,
58-
),
58+
)
5959
)
6060
}
6161
.launchIn(coroutineScope)

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/offgame/OffGameScope.kt

+3-9
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ interface OffGameScope {
3535
fun presenter(
3636
stateStream: StateStream<OffGameViewModel>,
3737
eventStream: EventStream<OffGameEvent>,
38-
): ComposePresenter {
39-
return object : ComposePresenter() {
38+
): ComposePresenter =
39+
object : ComposePresenter() {
4040
override val composable =
4141
@Composable {
4242
OffGameView(
@@ -45,16 +45,10 @@ interface OffGameScope {
4545
)
4646
}
4747
}
48-
}
4948

5049
fun eventStream() = EventStream<OffGameEvent>()
5150

5251
fun stateStream(authInfo: AuthInfo) =
53-
StateStream(
54-
OffGameViewModel(
55-
playerOne = authInfo.playerOne,
56-
playerTwo = authInfo.playerTwo,
57-
),
58-
)
52+
StateStream(OffGameViewModel(playerOne = authInfo.playerOne, playerTwo = authInfo.playerTwo))
5953
}
6054
}

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/tictactoe/Board.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class Board @Inject constructor() {
3535
}
3636

3737
/** Return true if the player with "theSeed" has won after placing at (currentRow, currentCol) */
38-
fun hasWon(theSeed: MarkerType): Boolean {
39-
return (cells[currentRow][0] == theSeed &&
38+
fun hasWon(theSeed: MarkerType): Boolean =
39+
(cells[currentRow][0] == theSeed &&
4040
cells[currentRow][1] == theSeed &&
4141
cells[currentRow][2] == theSeed ||
4242
cells[0][currentCol] == theSeed &&
@@ -50,7 +50,6 @@ class Board @Inject constructor() {
5050
cells[0][2] == theSeed &&
5151
cells[1][1] == theSeed &&
5252
cells[2][0] == theSeed)
53-
}
5453

5554
enum class MarkerType {
5655
CROSS,

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/tictactoe/TicTacToeEvent.kt

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ package com.uber.rib.compose.root.main.loggedin.tictactoe
1717

1818
sealed class TicTacToeEvent {
1919
object XpButtonClick : TicTacToeEvent()
20+
2021
class BoardClick(val coordinate: BoardCoordinate) : TicTacToeEvent()
2122
}

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/tictactoe/TicTacToeInteractor.kt

+1-6
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ class TicTacToeInteractor(
7676
}
7777

7878
stateStream.dispatch(
79-
stateStream
80-
.current()
81-
.copy(
82-
board = board,
83-
currentPlayer = newPlayerName,
84-
),
79+
stateStream.current().copy(board = board, currentPlayer = newPlayerName)
8580
)
8681
}
8782
TicTacToeEvent.XpButtonClick -> TODO("Go somewhere")

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/tictactoe/TicTacToeScope.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ interface TicTacToeScope {
3535
fun presenter(
3636
stateStream: StateStream<TicTacToeViewModel>,
3737
eventStream: EventStream<TicTacToeEvent>,
38-
): ComposePresenter {
39-
return object : ComposePresenter() {
38+
): ComposePresenter =
39+
object : ComposePresenter() {
4040
override val composable =
4141
@Composable {
4242
TicTacToeView(
@@ -45,7 +45,6 @@ interface TicTacToeScope {
4545
)
4646
}
4747
}
48-
}
4948

5049
fun eventStream() = EventStream<TicTacToeEvent>()
5150

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/tictactoe/TicTacToeView.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ fun TicTacToeView(viewModel: State<TicTacToeViewModel>, eventStream: EventStream
4949
modifier = Modifier.fillMaxSize().background(Color.Blue),
5050
) {
5151
Text("Current Player: ${viewModel.value.currentPlayer}", color = Color.White)
52-
Box(
53-
modifier = Modifier.aspectRatio(1f).fillMaxSize(),
54-
) {
52+
Box(modifier = Modifier.aspectRatio(1f).fillMaxSize()) {
5553
LazyVerticalGrid(columns = GridCells.Fixed(3), modifier = Modifier.fillMaxSize()) {
5654
val board = viewModel.value.board
5755
items(9) { i ->

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedin/tictactoe/TicTacToeViewModel.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
*/
1616
package com.uber.rib.compose.root.main.loggedin.tictactoe
1717

18-
data class TicTacToeViewModel(
19-
val currentPlayer: String,
20-
val board: Board,
21-
)
18+
data class TicTacToeViewModel(val currentPlayer: String, val board: Board)

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedout/LoggedOutEvent.kt

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ package com.uber.rib.compose.root.main.loggedout
1717

1818
sealed class LoggedOutEvent {
1919
class PlayerNameChanged(val name: String, val num: Int) : LoggedOutEvent()
20+
2021
object LogInClick : LoggedOutEvent()
2122
}

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedout/LoggedOutInteractor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LoggedOutInteractor(
4545
.copy(
4646
playerOne = if (it.num == 1) it.name else current().playerOne,
4747
playerTwo = if (it.num == 2) it.name else current().playerTwo,
48-
),
48+
)
4949
)
5050
}
5151
}

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedout/LoggedOutScope.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ interface LoggedOutScope {
3434
fun presenter(
3535
stateStream: StateStream<LoggedOutViewModel>,
3636
eventStream: EventStream<LoggedOutEvent>,
37-
): ComposePresenter {
38-
return object : ComposePresenter() {
37+
): ComposePresenter =
38+
object : ComposePresenter() {
3939
override val composable =
4040
@Composable {
4141
LoggedOutView(
@@ -44,7 +44,6 @@ interface LoggedOutScope {
4444
)
4545
}
4646
}
47-
}
4847

4948
fun eventStream() = EventStream<LoggedOutEvent>()
5049

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedout/LoggedOutView.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ fun LoggedOutView(viewModel: State<LoggedOutViewModel>, eventStream: EventStream
5555
)
5656
Button(
5757
colors =
58-
ButtonDefaults.buttonColors(
59-
backgroundColor = Color.Black,
60-
contentColor = Color.White,
61-
),
58+
ButtonDefaults.buttonColors(backgroundColor = Color.Black, contentColor = Color.White),
6259
onClick = { eventStream.notify(LoggedOutEvent.LogInClick) },
6360
modifier = Modifier.fillMaxWidth(),
6461
) {

android/demos/compose/src/main/kotlin/com/uber/rib/compose/root/main/loggedout/LoggedOutViewModel.kt

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
*/
1616
package com.uber.rib.compose.root.main.loggedout
1717

18-
data class LoggedOutViewModel(
19-
val playerOne: String = "",
20-
val playerTwo: String = "",
21-
)
18+
data class LoggedOutViewModel(val playerOne: String = "", val playerTwo: String = "")

android/demos/compose/src/main/kotlin/com/uber/rib/compose/util/AnalyticsClient.kt

+2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ class AnalyticsClientImpl(private val application: Application) : AnalyticsClien
4242

4343
object NoOpAnalyticsClient : AnalyticsClient {
4444
override fun trackClick(id: String) = Unit
45+
4546
override fun trackImpression(id: String) = Unit
4647
}
4748

4849
interface AnalyticsClient {
4950
fun trackClick(id: String)
51+
5052
fun trackImpression(id: String)
5153
}

0 commit comments

Comments
 (0)