Skip to content

Commit e08e99a

Browse files
refactor: minor rule changes
1 parent 8938457 commit e08e99a

File tree

14 files changed

+74
-58
lines changed

14 files changed

+74
-58
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+
)

core/src/main/java/org/openedx/core/domain/model/CourseDateBlock.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ data class CourseDateBlock(
1818
val assignmentType: String? = "",
1919
) : Parcelable {
2020
fun isCompleted(): Boolean {
21-
return complete || (
22-
dateType in setOf(
23-
DateType.COURSE_START_DATE,
24-
DateType.COURSE_END_DATE,
25-
DateType.CERTIFICATE_AVAILABLE_DATE,
26-
DateType.VERIFIED_UPGRADE_DEADLINE,
27-
DateType.VERIFICATION_DEADLINE_DATE,
28-
) && date.before(
29-
Date()
30-
)
31-
)
21+
val dateTypeInSet = dateType in setOf(
22+
DateType.COURSE_START_DATE,
23+
DateType.COURSE_END_DATE,
24+
DateType.CERTIFICATE_AVAILABLE_DATE,
25+
DateType.VERIFIED_UPGRADE_DEADLINE,
26+
DateType.VERIFICATION_DEADLINE_DATE
27+
)
28+
return complete || (dateTypeInSet && date.before(Date()))
3229
}
3330

3431
override fun equals(other: Any?): Boolean {

core/src/main/java/org/openedx/core/presentation/dialog/appreview/AppReviewManager.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ class AppReviewManager(
1717
isDialogShowed = true
1818
val currentVersionName = reviewPreferences.formatVersionName(appData.versionName)
1919
// Check is app wasn't positive rated AND 2 minor OR 1 major app versions passed since the last review
20-
if (
21-
!reviewPreferences.wasPositiveRated &&
22-
(
23-
currentVersionName.minorVersion - 2 >= reviewPreferences.lastReviewVersion.minorVersion ||
24-
currentVersionName.majorVersion - 1 >= reviewPreferences.lastReviewVersion.majorVersion
25-
)
26-
) {
20+
val minorVersionPassed =
21+
currentVersionName.minorVersion - 2 >= reviewPreferences.lastReviewVersion.minorVersion
22+
val majorVersionPassed =
23+
currentVersionName.majorVersion - 1 >= reviewPreferences.lastReviewVersion.majorVersion
24+
if (!reviewPreferences.wasPositiveRated && (minorVersionPassed || majorVersionPassed)) {
2725
val dialog = RateDialogFragment.newInstance()
2826
dialog.show(
2927
supportFragmentManager,

core/src/main/java/org/openedx/core/ui/WebContentScreen.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,7 @@ private fun WebViewContent(
147147
request: WebResourceRequest?
148148
): Boolean {
149149
val clickUrl = request?.url?.toString() ?: ""
150-
return if (clickUrl.isNotEmpty() &&
151-
(
152-
clickUrl.startsWith("http://") ||
153-
clickUrl.startsWith("https://")
154-
)
155-
) {
150+
return if (clickUrl.isNotEmpty() && clickUrl.startsWith("http")) {
156151
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(clickUrl)))
157152
true
158153
} else if (clickUrl.startsWith("mailto:")) {

course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitFragment.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,7 @@ private fun HTMLContentView(
320320
request: WebResourceRequest?
321321
): Boolean {
322322
val clickUrl = request?.url?.toString() ?: ""
323-
return if (clickUrl.isNotEmpty() &&
324-
(
325-
clickUrl.startsWith("http://") ||
326-
clickUrl.startsWith("https://")
327-
)
328-
) {
323+
return if (clickUrl.isNotEmpty() && clickUrl.startsWith("http")) {
329324
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(clickUrl)))
330325
true
331326
} else if (clickUrl.startsWith("mailto:")) {

discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,12 +640,7 @@ private fun CourseDescription(
640640
request: WebResourceRequest?
641641
): Boolean {
642642
val clickUrl = request?.url?.toString() ?: ""
643-
return if (clickUrl.isNotEmpty() &&
644-
(
645-
clickUrl.startsWith("http://") ||
646-
clickUrl.startsWith("https://")
647-
)
648-
) {
643+
return if (clickUrl.isNotEmpty() && clickUrl.startsWith("http")) {
649644
context.startActivity(
650645
Intent(Intent.ACTION_VIEW, Uri.parse(clickUrl))
651646
)

0 commit comments

Comments
 (0)