Fix codeAnalysis errors
This commit is contained in:
parent
516b097e9e
commit
1aa0b48b0a
8 changed files with 37 additions and 13 deletions
16
.github/workflows/pull-request-jobs.yml
vendored
16
.github/workflows/pull-request-jobs.yml
vendored
|
|
@ -27,15 +27,17 @@ jobs:
|
|||
- name: Run detekt
|
||||
run: ./gradlew detekt
|
||||
- name: Upload Detekt Results
|
||||
- uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: Detekt Results
|
||||
path: build/reports/detekt/detekt.html
|
||||
path: build/reports/detekt.html
|
||||
retention-days: 1
|
||||
- name: Run ktlint
|
||||
run: ./gradlew ktlintCheck
|
||||
- name: Upload ktLint Results
|
||||
- uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: ktLint Results
|
||||
path: ./**/build/reports/ktlint/**/*ktlint*Check.txt
|
||||
|
|
@ -43,7 +45,8 @@ jobs:
|
|||
- name: Run Lint
|
||||
run: ./gradlew lint
|
||||
- name: Upload Lint Results
|
||||
- uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: Lint Results
|
||||
path: ./**/build/reports/*lint-results*.html
|
||||
|
|
@ -62,9 +65,10 @@ jobs:
|
|||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
- name: Run Unit Tests
|
||||
run: ./gradlew testReleaseUnit
|
||||
run: ./gradlew unitTests
|
||||
- name: Upload Test Results
|
||||
- uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: Unit Test Results
|
||||
path: ./**/build/reports/tests/**/index.html
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ android {
|
|||
defaultConfig {
|
||||
applicationId "org.fnives.test.showcase"
|
||||
minSdkVersion 21
|
||||
//noinspection OldTargetApi // todo
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
val adapter = FavouriteContentAdapter(viewModel.mapToAdapterListener())
|
||||
binding.recycler.layoutManager = LinearLayoutManager(this)
|
||||
binding.recycler.addItemDecoration(VerticalSpaceItemDecoration(resources.getDimensionPixelOffset(R.dimen.padding)))
|
||||
binding.recycler.addItemDecoration(
|
||||
VerticalSpaceItemDecoration(resources.getDimensionPixelOffset(R.dimen.padding))
|
||||
)
|
||||
binding.recycler.adapter = adapter
|
||||
|
||||
viewModel.content.observe(this) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ class GetAllContentUseCase internal constructor(
|
|||
) {
|
||||
|
||||
fun get(): Flow<Resource<List<FavouriteContent>>> =
|
||||
contentRepository.contents.combine(favouriteContentLocalStorage.observeFavourites(), ::combineContentWithFavourites)
|
||||
contentRepository.contents.combine(
|
||||
favouriteContentLocalStorage.observeFavourites(),
|
||||
::combineContentWithFavourites
|
||||
)
|
||||
|
||||
companion object {
|
||||
private fun combineContentWithFavourites(
|
||||
|
|
@ -24,10 +27,18 @@ class GetAllContentUseCase internal constructor(
|
|||
when (contentResource) {
|
||||
is Resource.Error -> Resource.Error(contentResource.error)
|
||||
is Resource.Loading -> Resource.Loading()
|
||||
is Resource.Success -> Resource.Success(combineContentWithFavourites(contentResource.data, favouriteContents))
|
||||
is Resource.Success ->
|
||||
Resource.Success(
|
||||
combineContentWithFavourites(contentResource.data, favouriteContents)
|
||||
)
|
||||
}
|
||||
|
||||
private fun combineContentWithFavourites(content: List<Content>, favourite: List<ContentId>): List<FavouriteContent> =
|
||||
content.map { FavouriteContent(content = it, isFavourite = favourite.contains(it.id)) }
|
||||
private fun combineContentWithFavourites(
|
||||
content: List<Content>,
|
||||
favourite: List<ContentId>
|
||||
): List<FavouriteContent> =
|
||||
content.map {
|
||||
FavouriteContent(content = it, isFavourite = favourite.contains(it.id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import org.fnives.test.showcase.model.shared.Resource
|
|||
import org.fnives.test.showcase.network.shared.exceptions.NetworkException
|
||||
import org.fnives.test.showcase.network.shared.exceptions.ParsingException
|
||||
|
||||
@Suppress("RethrowCaughtException")
|
||||
internal suspend fun <T> wrapIntoAnswer(callback: suspend () -> T): Answer<T> =
|
||||
try {
|
||||
Answer.Success(callback())
|
||||
|
|
|
|||
|
|
@ -714,7 +714,7 @@ style:
|
|||
active: false
|
||||
ReturnCount:
|
||||
active: true
|
||||
max: 2
|
||||
max: 5
|
||||
excludedFunctions: 'equals'
|
||||
excludeLabeled: false
|
||||
excludeReturnFromLambda: true
|
||||
|
|
|
|||
|
|
@ -14,11 +14,15 @@ internal class SessionAuthenticator(
|
|||
private val networkSessionExpirationListener: NetworkSessionExpirationListener
|
||||
) : Authenticator {
|
||||
|
||||
@Suppress("SwallowedException")
|
||||
override fun authenticate(route: Route?, response: Response): Request? {
|
||||
if (authenticationHeaderUtils.hasToken(response.request)) {
|
||||
return runBlocking {
|
||||
try {
|
||||
val newSession = loginRemoteSource.refresh(networkSessionLocalStorage.session?.refreshToken.orEmpty())
|
||||
val refreshToken = networkSessionLocalStorage.session
|
||||
?.refreshToken
|
||||
.orEmpty()
|
||||
val newSession = loginRemoteSource.refresh(refreshToken)
|
||||
networkSessionLocalStorage.session = newSession
|
||||
return@runBlocking authenticationHeaderUtils.attachToken(response.request)
|
||||
} catch (throwable: Throwable) {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.io.EOFException
|
|||
|
||||
internal object ExceptionWrapper {
|
||||
|
||||
@Suppress("RethrowCaughtException")
|
||||
@Throws(NetworkException::class, ParsingException::class)
|
||||
suspend fun <T> wrap(request: suspend () -> T) = try {
|
||||
request()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue