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

Setup detekt #45

Merged
merged 15 commits into from
Mar 6, 2024
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gradle" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
39 changes: 35 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,43 @@ on:
branches: [ "main" ]

jobs:
detekt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Detekt
run: ./gradlew detekt
- name: reviewdog report
if: failure()
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cat ./build/reports/detekt/detekt.xml |
reviewdog -f=checkstyle -name="detekt" -reporter="github-pr-review"
build:
needs: detekt
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -24,7 +55,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/dev/keiji/tlv/sample/ConstructedData.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package dev.keiji.tlv.sample

import dev.keiji.tlv.*
import dev.keiji.tlv.BerTlv
import dev.keiji.tlv.BerTlvItem
import dev.keiji.tlv.BooleanTypeConverter
import dev.keiji.tlv.ByteTypeConverter
import dev.keiji.tlv.StringTypeConverter

@BerTlv
data class ConstructedData(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/dev/keiji/tlv/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.keiji.tlv.sample

import org.junit.Assert.*
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.fail
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.StreamCorruptedException
Expand Down
4 changes: 3 additions & 1 deletion app/src/test/java/dev/keiji/tlv/sample/PrimitiveDataTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package dev.keiji.tlv.sample

import org.junit.Assert.*
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.fail
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.StreamCorruptedException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.keiji.tlv.sample

import org.junit.Assert.*
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.fail
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.StreamCorruptedException
Expand Down
27 changes: 26 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.report.ReportMergeTask

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.2.1' apply false
id 'com.android.library' version '8.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'org.jetbrains.kotlin.jvm' version '1.9.22' apply false
id("io.gitlab.arturbosch.detekt") version "1.23.5"
}

Properties sonaTypeProps = new Properties()
Expand All @@ -25,6 +29,27 @@ ext {
repoUrl = versionCode.endsWith('-SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}

task clean(type: Delete) {
tasks.register('reportMerge', ReportMergeTask) {
output = layout.buildDirectory.file("reports/detekt/detekt.xml")
}

subprojects {
apply plugin: 'io.gitlab.arturbosch.detekt'

detekt {
buildUponDefaultConfig = true
allRules = true
config.setFrom("$rootDir/config/detekt/detekt.yml")
parallel = true
}

afterEvaluate { project ->
project.tasks.withType(Detekt) {
finalizedBy reportMerge
}
}
}

tasks.register('clean', Delete) {
delete rootProject.buildDir
}
Loading
Loading