Skip to content

Commit

Permalink
4 remove legacy code (#6)
Browse files Browse the repository at this point in the history
- Remove "legacy" code from SRGDataProvider
- Add code quality with Detekt
  • Loading branch information
StaehliJ authored Jun 12, 2023
1 parent 6b7f4c7 commit cc51886
Show file tree
Hide file tree
Showing 87 changed files with 1,856 additions and 3,732 deletions.
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .editorconfig

# see http://EditorConfig.org

# This is the file in the root of the project.
# For sub folders you can have other files that override only some settings.
# For these, this settings should be false.
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 150

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
indent_size = 4

[*.{rb,yml}]
indent_size = 2

[*.properties]
# Exception for Java properties files should be encoded latin1 (aka iso8859-1)
charset = latin1
75 changes: 75 additions & 0 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Code quality
on:
merge_group:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]

jobs:
android-lint:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: reviewdog/action-setup@v1
- name: Run android linter
uses: gradle/gradle-build-action@v2
with:
arguments: lint
- name: review linter
uses: dvdandroid/action-android-lint@master
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
lint_xml_file: ./build/reports/android-lint.xml
reporter: github-pr-review
- name: check linter
uses: dvdandroid/action-android-lint@master
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
lint_xml_file: ./build/reports/android-lint.xml
reporter: github-pr-check

detekt:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: reviewdog/action-setup@v1
- name: review detekt
uses: alaegin/[email protected]
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
detekt_config: config/detekt.yml
reviewdog_reporter: github-pr-review
detekt_excludes: "**/build/**,**/.idea/**,**/buildSrc/**,**/androidTest/**,**/test/**,**/resources/**"
- name: check detekt
uses: alaegin/[email protected]
with:
github_token: ${{ secrets.RTS_DEVOPS_GITHUB_TOKEN }}
detekt_config: config/detekt.yml
reviewdog_reporter: github-pr-check
detekt_excludes: "**/build/**,**/.idea/**,**/buildSrc/**,**/androidTest/**,**/test/**,**/resources/**"

android-unit-test:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run android local unit test
uses: gradle/gradle-build-action@v2
with:
arguments: testDebug
33 changes: 33 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,41 @@ plugins {
id("com.android.application") version "8.0.1" apply false
id("com.android.library") version "8.0.1" apply false
id("org.jetbrains.kotlin.android") version "1.6.21" apply false
// https://github.com/detekt/detekt
id("io.gitlab.arturbosch.detekt").version(Versions.detekt)
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}

allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")
detekt {
buildUponDefaultConfig = true // preconfigure defaults
allRules = false // activate all available (even unstable) rules.
source.setFrom("src/main/java", "src/main/kotlin")
config.setFrom("../config/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
baseline = file("$projectDir/detekt-baseline.xml") // a way of suppressing issues before introducing detekt
ignoredBuildTypes = listOf("release")
autoCorrect = true
}

dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.detekt}")
}
}

/*
* https://detekt.dev/docs/gettingstarted/git-pre-commit-hook
* https://medium.com/@alistair.cerio/android-ktlint-and-pre-commit-git-hook-5dd606e230a9
*/
tasks.register("installGitHook", Copy::class) {
description = "Adding git hook script to local working copy"
println("Installing git hook to ${rootProject.rootDir}/.git/hooks")
from(file("${rootProject.rootDir}/git_hooks/pre-commit"))
into { file("${rootProject.rootDir}/.git/hooks") }
fileMode = 0x777
}

tasks.getByPath(":data:preBuild").dependsOn(":installGitHook")
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ object Config {
const val minSdk = 21

const val major = 0
const val minor = 0
const val patch = 2
const val minor = 1
const val patch = 0
const val versionName = "$major.$minor.$patch"

const val maven_group = "ch.srg.data.provider"
}
}
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ object Versions {
const val retrofit_version = "2.9.0"
const val okHttp_version = "4.9.1"
const val gsonVersion = "2.10.1"
}
const val detekt = "1.22.0"
}
Loading

0 comments on commit cc51886

Please sign in to comment.