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