Skip to content

Commit 375329c

Browse files
refactor: minor rule changes
1 parent 8938457 commit 375329c

File tree

8 files changed

+49
-15
lines changed

8 files changed

+49
-15
lines changed

.github/workflows/detekt.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Detekt
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request: { }
6+
7+
env:
8+
GRADLE_OPTS: -Dorg.gradle.daemon=false
9+
CI_GRADLE_ARG_PROPERTIES: --stacktrace
10+
11+
jobs:
12+
linting:
13+
name: Run Detekt
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Repo
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Java
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: 'temurin' # See 'Supported distributions' for available options
24+
java-version: '17'
25+
26+
- name: Run Detekt
27+
run: ./gradlew detektAll
28+
29+
- name: Upload report
30+
uses: github/codeql-action/upload-sarif@v3
31+
if: success() || failure()
32+
with:
33+
sarif_file: build/reports/detekt/detekt.sarif

app/src/main/java/org/openedx/app/di/ScreenModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ val screenModule = module {
184184
profileRouter = get(),
185185
)
186186
}
187-
viewModel { (account: Account) -> EditProfileViewModel(get(), get(), get(), get(), account) }
187+
viewModel { (account: Account) -> EditProfileViewModel(get(), get(), get(), get(), get(), account) }
188188
viewModel { VideoSettingsViewModel(get(), get(), get(), get()) }
189189
viewModel { (qualityType: String) -> VideoQualityViewModel(qualityType, get(), get(), get()) }
190190
viewModel { DeleteProfileViewModel(get(), get(), get(), get(), get()) }

config/detekt.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
maxIssues: 100
2+
maxIssues: 0
33
weights:
44
complexity: 2
55
LongParameterList: 1
@@ -43,19 +43,13 @@ style:
4343
active: true
4444
ignoreAnnotated:
4545
- 'Preview'
46-
ForbiddenComment:
47-
active: false
48-
SerialVersionUIDInSerializableClass:
49-
active: false
5046

5147
complexity:
5248
active: true
5349
LongMethod:
5450
active: true
5551
ignoreAnnotated: [ 'Composable' ]
5652
ignoreFunction: [ 'onCreateView' ]
57-
LargeClass:
58-
active: false
5953
LongParameterList:
6054
active: true
6155
functionThreshold: 15
@@ -64,8 +58,8 @@ complexity:
6458
ignoreAnnotated: [ 'Composable' ]
6559
TooManyFunctions:
6660
active: true
67-
thresholdInClasses: 30
68-
thresholdInInterfaces: 30
61+
thresholdInClasses: 21
62+
thresholdInInterfaces: 20
6963
ignoreAnnotatedFunctions: [ 'Composable' ]
7064
ignoreOverridden: true
7165
ignorePrivate: true

core/src/main/java/org/openedx/core/config/Config.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.google.gson.JsonParser
88
import org.openedx.core.domain.model.AgreementUrls
99
import java.io.InputStreamReader
1010

11+
@Suppress("TooManyFunctions")
1112
class Config(context: Context) {
1213

1314
private var configProperties: JsonObject = try {
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package org.openedx.core.domain.model
22

3-
import java.io.Serializable
3+
import com.google.gson.annotations.SerializedName
44

55
data class AppConfig(
66
val courseDatesCalendarSync: CourseDatesCalendarSync = CourseDatesCalendarSync(),
7-
) : Serializable
7+
)
88

99
data class CourseDatesCalendarSync(
10+
@SerializedName("is_enabled")
1011
val isEnabled: Boolean = false,
12+
@SerializedName("is_self_paced_enabled")
1113
val isSelfPacedEnabled: Boolean = false,
14+
@SerializedName("is_instructor_paced_enabled")
1215
val isInstructorPacedEnabled: Boolean = false,
16+
@SerializedName("is_deep_link_enabled")
1317
val isDeepLinkEnabled: Boolean = false,
14-
) : Serializable
18+
)

discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import org.openedx.foundation.presentation.UIMessage
4040
import org.openedx.foundation.system.ResourceManager
4141
import java.net.UnknownHostException
4242

43+
@Suppress("LargeClass")
4344
@OptIn(ExperimentalCoroutinesApi::class)
4445
class DiscussionCommentsViewModelTest {
4546

profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,9 @@ class EditProfileFragment : Fragment() {
278278
fos.write(bitmapData)
279279
fos.flush()
280280
fos.close()
281-
// TODO: get applicationId instead of packageName
282281
return FileProvider.getUriForFile(
283282
requireContext(),
284-
requireContext().packageName + ".fileprovider",
283+
viewModel.config.getAppId() + ".fileprovider",
285284
newFile
286285
)!!
287286
}

profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.lifecycle.MutableLiveData
66
import androidx.lifecycle.viewModelScope
77
import kotlinx.coroutines.launch
88
import org.openedx.core.R
9+
import org.openedx.core.config.Config
910
import org.openedx.foundation.extension.isInternetError
1011
import org.openedx.foundation.presentation.BaseViewModel
1112
import org.openedx.foundation.presentation.UIMessage
@@ -24,6 +25,7 @@ class EditProfileViewModel(
2425
private val resourceManager: ResourceManager,
2526
private val notifier: ProfileNotifier,
2627
private val analytics: ProfileAnalytics,
28+
val config: Config,
2729
account: Account,
2830
) : BaseViewModel() {
2931

0 commit comments

Comments
 (0)