Skip to content

Commit

Permalink
Ktlint integration (#8)
Browse files Browse the repository at this point in the history
* ktlint codestyle applied

* reformat code

* KTLint codestyle and check
  • Loading branch information
faogustavo authored Oct 5, 2020
1 parent 234da18 commit 5a22b3a
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 52 deletions.
17 changes: 2 additions & 15 deletions .github/workflows/jvmTest.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
name: Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
test:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Gradle test flow for JVM
- name: Gradle test for JVM
run: ./gradlew jvmTest
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint
on:
pull_request:
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: ktlint
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
fail_on_error: true
32 changes: 19 additions & 13 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/ktlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ allprojects {

group = "dev.valvassori.fluks"
version = "1.0.0"
}
}
4 changes: 2 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ publishing {
setUrl("https://api.bintray.com/maven/$user/$repo/$name/;publish=0;override=1")

credentials {
username = if(project.hasProperty("bintrayUser")) {
username = if (project.hasProperty("bintrayUser")) {
project.property("bintrayUser").toString()
} else {
System.getenv("BINTRAY_USER")
}

password = if(project.hasProperty("bintrayApiKey")) {
password = if (project.hasProperty("bintrayApiKey")) {
project.property("bintrayApiKey").toString()
} else {
System.getenv("BINTRAY_KEY")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ fun <S0 : Fluks.State, S1 : Fluks.State, SOUT : Fluks.State> combiner(
@ExperimentalCoroutinesApi
fun interface Combiner<S0 : Fluks.State, S1 : Fluks.State, SOUT : Fluks.State> {
fun combine(state0: S0, state1: S1): SOUT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
@ExperimentalCoroutinesApi
fun interface Dispatcher {
fun dispatch(action: Fluks.Action)
}
}
7 changes: 5 additions & 2 deletions core/src/commonMain/kotlin/dev.valvassori/fluks/Fluks.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dev.valvassori.fluks

import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.MutableStateFlow
import kotlin.coroutines.CoroutineContext

Expand All @@ -23,4 +26,4 @@ object Fluks {
open fun applyMiddleware(middleware: Middleware<S>) {}
open fun applyMiddleware(middlewares: List<Middleware<S>>) {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ internal object GlobalDispatcher {
internal fun register(store: Fluks.Store<*>) {
stores.add(store)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ internal class ChainNode<S : Fluks.State>(
internal fun <S : Fluks.State> Fluks.Store<S>.asChainNode() = ChainNode<S>(
middleware = { _, action, _ -> reduce(value, action) },
nextNode = null
)
)
2 changes: 1 addition & 1 deletion core/src/commonMain/kotlin/dev.valvassori/fluks/Reducer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ fun interface Reducer<S : Fluks.State> {
currentState: S,
action: Fluks.Action
): S
}
}
1 change: 0 additions & 1 deletion core/src/commonMain/kotlin/dev.valvassori/fluks/Store.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dev.valvassori.fluks
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext

@ExperimentalCoroutinesApi
fun <T: Fluks.State> Fluks.Store<T>.launch(
fun <T : Fluks.State> Fluks.Store<T>.launch(
context: CoroutineContext = EmptyCoroutineContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
block: suspend Fluks.Store<T>.() -> Unit
) = scope.launch(context, start) { block() }

@ExperimentalCoroutinesApi
fun <T: Fluks.State> Fluks.Store<T>.async(
fun <T : Fluks.State> Fluks.Store<T>.async(
context: CoroutineContext = EmptyCoroutineContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
block: suspend Fluks.Store<T>.() -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ fun <S0 : Fluks.State, S1 : Fluks.State, SOUT : Fluks.State> Fluks.Store<S0>.com
store1 = other,
baseContext = baseContext,
combiner = combiner
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ fun <S : Fluks.State> logMiddleware(
messages.forEach { logger.log(it) }

updatedValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ class AbstractCombinedStoreTest {
store0.dispatch(Inc)
assertEquals(9, combinedStores.value.multiplication)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ internal class AbstractStoreTest {
store.dispatch(Action.Dec)
store.dispatch(Action.Div(2))


assertEquals(4, store.value.count)
}

Expand All @@ -83,7 +82,6 @@ internal class AbstractStoreTest {
store.dispatch(Action.Dec)
store.dispatch(Action.Mult(2))


assertEquals(-4, store.value.count)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ class GlobalDispatcherTest {
assertFalse(store2.value.switch)
assertFalse(store3.value.switch)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package dev.valvassori.fluks.middlewares
import dev.valvassori.fluks.Fluks
import dev.valvassori.fluks.Next
import dev.valvassori.fluks.ext.value
import io.mockk.*
import io.mockk.Runs
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.verify
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -68,4 +73,4 @@ class LogMiddlewareTest {
every { next.invoke(any()) } returns State(true)
every { logger.log(any()) } just Runs
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class CoroutineTestRule : TestWatcher(), TestCoroutineScope by TestCoroutineScop
Dispatchers.resetMain()
testDispatcher.cleanupTestCoroutines()
}
}
}

0 comments on commit 5a22b3a

Please sign in to comment.