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

SonarCloud integration and warnings #402

Closed
kirillt opened this issue Oct 18, 2023 · 3 comments
Closed

SonarCloud integration and warnings #402

kirillt opened this issue Oct 18, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@kirillt
Copy link
Member

kirillt commented Oct 18, 2023

Let's have similar SonarCloud integration:

We also need to check current warnings and fix those which are quick to fix:
Reference issue: #405

> Task :app:compileDebugKotlin
.../data/preferences/PreferencesImpl.kt: (75, 23): Unchecked cast: Preferences.Key<out {Comparable<*> & java.io.Serializable}> to Preferences.Key<T>
.../data/stats/category/StatsCategoryStorage.kt: (23, 14): This declaration is in a preview state and can be changed in a backwards-incompatible manner with a best-effort migration. Its usage should be marked with '@kotlinx.coroutines.FlowPreview' or '@OptIn(kotlinx.coroutines.FlowPreview::class)' if you accept the drawback of relying on preview API
.../data/stats/category/TagLabeledNStorage.kt: (30, 29): This declaration needs opt-in. Its usage should be marked with '@kotlinx.serialization.ExperimentalSerializationApi' or '@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)'
.../data/stats/category/TagLabeledTSStorage.kt: (26, 29): This declaration needs opt-in. Its usage should be marked with '@kotlinx.serialization.ExperimentalSerializationApi' or '@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)'
.../data/stats/category/TagQueriedTSStorage.kt: (26, 25): This declaration needs opt-in. Its usage should be marked with '@kotlinx.serialization.ExperimentalSerializationApi' or '@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)'
.../presentation/dialog/InfoDialogFragment.kt: (31, 21): 'get(String!): Any?' is deprecated. Deprecated in Java
.../presentation/dialog/InfoDialogFragment.kt: (32, 27): 'get(String!): Any?' is deprecated. Deprecated in Java
.../presentation/dialog/edittags/EditTagsDialogFragment.kt: (44, 13): 'get(String!): Any?' is deprecated. Deprecated in Java
.../presentation/dialog/edittags/EditTagsDialogFragment.kt: (45, 32): 'getParcelableArray(String?): Array<(out) Parcelable!>?' is deprecated. Deprecated in Java
.../presentation/dialog/edittags/EditTagsDialogFragment.kt: (46, 17): Unchecked cast: List<Parcelable!> to List<ResourceId>
.../presentation/dialog/edittags/EditTagsDialogFragment.kt: (81, 50): Parameter 'event' is never used, could be renamed to _
.../presentation/dialog/edittags/EditTagsDialogPresenter.kt: (275, 11): Unchecked cast: Map<Tag /* = String */, {Comparable<*> & Number}> to Map<Tag /* = String */, Comparable<Any>>
.../presentation/dialog/tagssort/TagsSortViewModel.kt: (92, 64): Unchecked cast: TagsSortViewModel to T
.../presentation/navigation/AppNavigator.kt: (220, 9): Parameter 'command' is never used
.../presentation/navigation/AppNavigator.kt: (221, 9): Parameter 'currentFragment' is never used
.../presentation/navigation/AppNavigator.kt: (222, 9): Parameter 'nextFragment' is never used
.../presentation/navigation/AppNavigator.kt: (223, 9): Parameter 'fragmentTransaction' is never used
.../presentation/navigation/AppNavigator.kt: (235, 9): Parameter 'command' is never used
.../presentation/navigation/AppNavigator.kt: (236, 9): Parameter 'activityIntent' is never used
.../presentation/navigation/AppNavigator.kt: (261, 9): Parameter 'screen' is never used
.../presentation/navigation/AppNavigator.kt: (262, 9): Parameter 'activityIntent' is never used
.../presentation/navigation/AppNavigator.kt: (287, 36): Parameter 'screen' is never used
.../presentation/screen/folders/FoldersViewModel.kt: (290, 11): Unchecked cast: FoldersViewModel to T
.../presentation/screen/gallery/GalleryFragment.kt: (66, 13): 'get(String!): Any?' is deprecated. Deprecated in Java
.../presentation/screen/gallery/GalleryFragment.kt: (67, 32): 'getParcelableArray(String?): Array<(out) Parcelable!>?' is deprecated. Deprecated in Java
.../presentation/screen/gallery/GalleryFragment.kt: (68, 17): Unchecked cast: List<Parcelable!> to List<ResourceId>
.../presentation/screen/gallery/GalleryFragment.kt: (72, 36): 'getParcelableArray(String?): Array<(out) Parcelable!>?' is deprecated. Deprecated in Java
.../presentation/screen/gallery/GalleryFragment.kt: (73, 31): Unchecked cast: List<Parcelable!> to List<ResourceId>
.../presentation/screen/gallery/GalleryFragment.kt: (337, 13): 'get(String!): Any?' is deprecated. Deprecated in Java
.../presentation/screen/gallery/GalleryFragment.kt: (524, 13): Variable 'extension' is never used
.../presentation/screen/gallery/previewpager/PreviewImageViewHolder.kt: (37, 52): Parameter 'view' is never used, could be renamed to _
.../presentation/screen/gallery/previewpager/PreviewImageViewHolder.kt: (40, 45): Parameter 'view' is never used, could be renamed to _
.../presentation/screen/gallery/previewpager/PreviewImageViewHolder.kt: (87, 9): Parameter 'meta' is never used
.../presentation/screen/gallery/previewpager/PreviewPlainTextViewHolder.kt: (16, 48): Parameter 'view' is never used, could be renamed to _
.../presentation/screen/main/MainActivity.kt: (86, 25): The expression is unused
.../presentation/screen/resources/ResourcesFragment.kt: (70, 13): 'get(String!): Any?' is deprecated. Deprecated in Java
.../presentation/screen/resources/ResourcesFragment.kt: (434, 28): 'getParcelableArray(String?): Array<(out) Parcelable!>?' is deprecated. Deprecated in Java
.../presentation/screen/resources/ResourcesFragment.kt: (436, 34): Unchecked cast: List<Parcelable!> to List<ResourceId>
.../presentation/screen/resources/ResourcesPresenter.kt: (122, 19): Unchecked cast: Map<Tag /* = String */, {Comparable<*> & Number}> to Map<Tag /* = String */, Comparable<Any>>
.../presentation/screen/resources/ResourcesPresenter.kt: (375, 66): Parameter 'to' is never used
.../presentation/utils/FullscreenHelper.kt: (18, 28): 'getWindowInsetsController(View): WindowInsetsControllerCompat?' is deprecated. Deprecated in Java
.../presentation/utils/FullscreenHelper.kt: (22, 59): 'FLAG_FULLSCREEN: Int' is deprecated. Deprecated in Java
.../presentation/utils/FullscreenHelper.kt: (29, 61): 'FLAG_FULLSCREEN: Int' is deprecated. Deprecated in Java
.../presentation/view/StackedToasts.kt: (104, 13): Parameter 'value' is never used
@kirillt kirillt added the enhancement New feature or request label Oct 18, 2023
@kirillt kirillt moved this to In Progress in Development Oct 18, 2023
@kirillt
Copy link
Member Author

kirillt commented Oct 18, 2023

Repository secret SONAR_TOKEN is created.

That's what official docs say, but we did it a bit different way in arklib-android:

Update your build.gradle.kts file with the org.sonarqube plugin and its configuration:

plugins {
  id("org.sonarqube") version "4.4.1.3373"
}

sonar {
  properties {
    property("sonar.projectKey", "ARK-Builders_ARK-Navigator")
    property("sonar.organization", "ark-builders")
    property("sonar.host.url", "https://sonarcloud.io")
  }
}

Create or update your .github/workflows/build.yml. Here is a base configuration to run a SonarCloud analysis on your master branch and Pull Requests. If you already have some GitHub Actions, you might want to just add some of these new steps to an existing one.

name: SonarCloud
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build and analyze
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: 17
          distribution: 'zulu' # Alternative distribution options are available
      - name: Cache SonarCloud packages
        uses: actions/cache@v3
        with:
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache Gradle packages
        uses: actions/cache@v3
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
          restore-keys: ${{ runner.os }}-gradle
      - name: Build and analyze
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: ./gradlew build sonar --info

@tuancoltech
Copy link
Collaborator

tuancoltech commented Oct 24, 2023

First resolve warnings using local analysis tool: #405

@kirillt
Copy link
Member Author

kirillt commented Nov 5, 2023

Assigned this to Hieu since we've just done same job in arklib-android.

@kirillt kirillt moved this from In Progress to Review in Development Nov 24, 2023
@kirillt kirillt closed this as completed Dec 19, 2023
@github-project-automation github-project-automation bot moved this from Review to Done in Development Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants