From 876cda2fa4e4fccad050f3d18d2e0ccb0717f5c1 Mon Sep 17 00:00:00 2001 From: PavloNetrebchuk Date: Thu, 14 Nov 2024 17:02:57 +0200 Subject: [PATCH] refactor: minor rule changes --- .github/workflows/detekt.yml | 33 +++++++++++++++++++ config/detekt.yml | 12 ++----- .../java/org/openedx/core/config/Config.kt | 1 + .../openedx/core/domain/model/AppConfig.kt | 10 ++++-- .../DiscussionCommentsViewModelTest.kt | 1 + 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/detekt.yml diff --git a/.github/workflows/detekt.yml b/.github/workflows/detekt.yml new file mode 100644 index 000000000..0cee02ffe --- /dev/null +++ b/.github/workflows/detekt.yml @@ -0,0 +1,33 @@ +name: Detekt + +on: + workflow_dispatch: + pull_request: { } + +env: + GRADLE_OPTS: -Dorg.gradle.daemon=false + CI_GRADLE_ARG_PROPERTIES: --stacktrace + +jobs: + linting: + name: Run Detekt + runs-on: ubuntu-latest + + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + + - name: Run Detekt + run: ./gradlew detektAll + + - name: Upload report + uses: github/codeql-action/upload-sarif@v3 + if: success() || failure() + with: + sarif_file: build/reports/detekt/detekt.sarif diff --git a/config/detekt.yml b/config/detekt.yml index 11c63e2fc..37d257629 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -1,5 +1,5 @@ build: - maxIssues: 100 + maxIssues: 0 weights: complexity: 2 LongParameterList: 1 @@ -43,10 +43,6 @@ style: active: true ignoreAnnotated: - 'Preview' - ForbiddenComment: - active: false - SerialVersionUIDInSerializableClass: - active: false complexity: active: true @@ -54,8 +50,6 @@ complexity: active: true ignoreAnnotated: [ 'Composable' ] ignoreFunction: [ 'onCreateView' ] - LargeClass: - active: false LongParameterList: active: true functionThreshold: 15 @@ -64,8 +58,8 @@ complexity: ignoreAnnotated: [ 'Composable' ] TooManyFunctions: active: true - thresholdInClasses: 30 - thresholdInInterfaces: 30 + thresholdInClasses: 21 + thresholdInInterfaces: 20 ignoreAnnotatedFunctions: [ 'Composable' ] ignoreOverridden: true ignorePrivate: true diff --git a/core/src/main/java/org/openedx/core/config/Config.kt b/core/src/main/java/org/openedx/core/config/Config.kt index 53b4c3c09..1b58c7e44 100644 --- a/core/src/main/java/org/openedx/core/config/Config.kt +++ b/core/src/main/java/org/openedx/core/config/Config.kt @@ -8,6 +8,7 @@ import com.google.gson.JsonParser import org.openedx.core.domain.model.AgreementUrls import java.io.InputStreamReader +@Suppress("TooManyFunctions") class Config(context: Context) { private var configProperties: JsonObject = try { diff --git a/core/src/main/java/org/openedx/core/domain/model/AppConfig.kt b/core/src/main/java/org/openedx/core/domain/model/AppConfig.kt index 97750957f..a64e09655 100644 --- a/core/src/main/java/org/openedx/core/domain/model/AppConfig.kt +++ b/core/src/main/java/org/openedx/core/domain/model/AppConfig.kt @@ -1,14 +1,18 @@ package org.openedx.core.domain.model -import java.io.Serializable +import com.google.gson.annotations.SerializedName data class AppConfig( val courseDatesCalendarSync: CourseDatesCalendarSync = CourseDatesCalendarSync(), -) : Serializable +) data class CourseDatesCalendarSync( + @SerializedName("is_enabled") val isEnabled: Boolean = false, + @SerializedName("is_self_paced_enabled") val isSelfPacedEnabled: Boolean = false, + @SerializedName("is_instructor_paced_enabled") val isInstructorPacedEnabled: Boolean = false, + @SerializedName("is_deep_link_enabled") val isDeepLinkEnabled: Boolean = false, -) : Serializable +) diff --git a/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt b/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt index 8c783a3fd..e9323270e 100644 --- a/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt +++ b/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt @@ -40,6 +40,7 @@ import org.openedx.foundation.presentation.UIMessage import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException +@Suppress("LargeClass") @OptIn(ExperimentalCoroutinesApi::class) class DiscussionCommentsViewModelTest {