Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD - Qodana #584

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/qodana_code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
qodana:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.niyaj.data.repository.validation.ChargesValidationRepository
import com.niyaj.database.model.asExternalModel
import com.niyaj.model.Charges
import com.niyaj.model.searchCharges
import com.niyaj.poposroom.features.charges.data.dao.ChargesDao
import com.niyaj.database.dao.ChargesDao
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
Expand Down
2 changes: 1 addition & 1 deletion core/data/src/main/java/com/niyaj/data/di/ChargesModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.niyaj.common.network.PoposDispatchers
import com.niyaj.data.data.repository.ChargesRepositoryImpl
import com.niyaj.data.repository.ChargesRepository
import com.niyaj.data.repository.validation.ChargesValidationRepository
import com.niyaj.poposroom.features.charges.data.dao.ChargesDao
import com.niyaj.database.dao.ChargesDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.niyaj.database.dao.ProductDao
import com.niyaj.database.dao.ProfileDao
import com.niyaj.database.dao.ReportsDao
import com.niyaj.database.dao.SelectedDao
import com.niyaj.poposroom.features.charges.data.dao.ChargesDao
import com.niyaj.database.dao.ChargesDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import com.niyaj.database.model.ReportsEntity
import com.niyaj.database.model.SelectedEntity
import com.niyaj.database.util.ListConverter
import com.niyaj.database.util.TimestampConverters
import com.niyaj.poposroom.features.charges.data.dao.ChargesDao
import com.niyaj.database.dao.ChargesDao


@Database(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package com.niyaj.poposroom.features.charges.data.dao
package com.niyaj.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import androidx.room.Upsert
import androidx.room.*
import com.niyaj.database.model.ChargesEntity
import kotlinx.coroutines.flow.Flow

Expand Down
12 changes: 6 additions & 6 deletions core/ui/src/main/java/com/niyaj/ui/event/ItemEvents.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ sealed interface ItemEvents {

data class SelectItem(val itemId: Int): ItemEvents

object SelectAllItems: ItemEvents
data object SelectAllItems: ItemEvents

object DeselectAllItems: ItemEvents
data object DeselectAllItems: ItemEvents

object DeleteItems: ItemEvents
data object DeleteItems: ItemEvents

object OnSearchClick: ItemEvents
data object OnSearchClick: ItemEvents

data class OnSearchTextChanged(val text: String): ItemEvents

object OnSearchTextClearClick: ItemEvents
data object OnSearchTextClearClick: ItemEvents

object OnSearchBarCloseClick: ItemEvents
data object OnSearchBarCloseClick: ItemEvents

}
6 changes: 1 addition & 5 deletions feature/cart/src/main/java/com/niyaj/cart/CartScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ fun CartScreen(
onClickOrderDetails: (Int) -> Unit,
onNavigateToOrderScreen: () -> Unit,
) {
val pagerState = rememberPagerState(
initialPage = 0,
initialPageOffsetFraction = 0f,
pageCount = { 2 }
)
val pagerState = rememberPagerState{ 2 }

StandardScaffoldWithBottomNavigation(
navController = navController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ import com.niyaj.model.ProductIdWithPrice
import com.niyaj.ui.event.BaseViewModel
import com.niyaj.ui.utils.UiEvent
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand All @@ -43,9 +38,7 @@ class ProductSettingsViewModel @Inject constructor(
val products = snapshotFlow { mSearchText.value }.flatMapLatest { searchText ->
productRepository.getAllProduct(searchText)
}.mapLatest { list ->
totalItems = list.map { item ->
item.productId
}
totalItems = list.map { item -> item.productId }
list
}.stateIn(
viewModelScope,
Expand Down Expand Up @@ -79,11 +72,11 @@ class ProductSettingsViewModel @Inject constructor(
if (_selectedCategory.contains(event.categoryId)) {
mSelectedItems.removeAll(products)
_selectedCategory.remove(event.categoryId)
}else {
} else {
_selectedCategory.add(event.categoryId)

products.forEach {
if (!mSelectedItems.contains(it)){
if (!mSelectedItems.contains(it)) {
mSelectedItems.add(it)
}
}
Expand Down Expand Up @@ -176,10 +169,11 @@ class ProductSettingsViewModel @Inject constructor(
}
}

when(val result = productRepository.increaseProductsPrice(data)) {
when (val result = productRepository.increaseProductsPrice(data)) {
is Resource.Error -> {
mEventFlow.emit(UiEvent.OnError(result.message ?: "Unable"))
}

is Resource.Success -> {
mEventFlow.emit(UiEvent.OnSuccess("${data.size} products price has been increased"))
}
Expand Down Expand Up @@ -207,10 +201,11 @@ class ProductSettingsViewModel @Inject constructor(
}
}

when(val result = productRepository.decreaseProductsPrice(data)) {
when (val result = productRepository.decreaseProductsPrice(data)) {
is Resource.Error -> {
mEventFlow.emit(UiEvent.OnError(result.message ?: "Unable"))
}

is Resource.Success -> {
mEventFlow.emit(UiEvent.OnSuccess("${data.size} products price has been decreased"))
}
Expand Down
33 changes: 33 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

projectJDK: 19 #(Applied in CI/CD pipeline)

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm:latest
exclude:
- name: UnstableApiUsage