Skip to content

Commit

Permalink
chore: 静的解析ツールのdetektを導入し、指摘を修正 #109 (#112)
Browse files Browse the repository at this point in the history
* chore: 静的解析ツールのdetektを追加

* fix: (detekt) WildCardImport

* fix: (detekt) WildCardImport

* fix: (detekt) WildCardImport

* fix: (detekt) WildCardImport

* fix: (detekt) WildCardImport

* fix: (detekt) WildCardImport

* fix: (detekt) WildCardImport

* fix: (detekt) MayBeConst

* fix: (detekt) Add SuppressRule

* fix: (detekt) ReturnCount

* fix: (detekt) MagicNumber

* fix: (detekt) MagicNumber

* chore: detektのジョブを分けた

* fix: (detekt) TopLevelPropertyNaming

* fix: (detekt) TopLevelPropertyNaming

* fix: (detekt) MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) ReturnCount

* fix: (detekt) ReturnCount

* fix: (detekt) Suppress UnusedPrivateMember

* fix: (detekt) MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) Suppress MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) Suppress MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) MagicNumber

* fix: (detekt) Suppress ReturnCount

* fix: (detekt) ForbiddenComment

* fix: (detekt) Suppress SpreadOperator

* fix: (detekt) PrintStackTrace

* fix: (detekt) RethrowCaughtException

* fix: (detekt) TooGenericExceptionCaught

* fix: remove lateinit

* chore: detektの公式設定ファイルをコピーだけした

* fix: なぜかプロパティが存在しないエラーになった箇所をコメントアウト

This reverts commit 07007ea65d56802d4f5fca25e36e95ea01dbf66a.

* fix: 設定ファイルを読み込むように変更

* fix: 除外設定を追加

* fix: しきい値を変更

* fix: (detekt) LongMethod

* fix: しきい値を変更

* fix: artifactを起動してみたらClassNotFoundExceptionが発生したので一旦WIPで回避

* fix: リリースジョブからもdetektを除外
  • Loading branch information
jiro4989 authored Jan 4, 2022
1 parent 0d1d81c commit 6517740
Show file tree
Hide file tree
Showing 20 changed files with 1,329 additions and 272 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
echo ORG_GRADLE_PROJECT_CI_COMMIT_HASH="$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Build
run: ./gradlew build -x test
run: ./gradlew build -x test -x detekt

- name: Create artifact
run: >
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
# codecovからrevを参照されるのでv2にはしない
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/[email protected]
with:
distribution: temurin
Expand All @@ -42,10 +43,23 @@ jobs:
- name: Check code style
run: ./gradlew spotlessCheck
- name: Test
run: xvfb-run ./gradlew test jacocoTestReport
run: xvfb-run ./gradlew test jacocoTestReport -x detekt
- name: Send coverage report
run: bash <(curl -s https://codecov.io/bash)

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
java-package: jdk
architecture: x64
- name: Lint
run: ./gradlew detekt

build-artifact:
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -85,7 +99,7 @@ jobs:
echo ORG_GRADLE_PROJECT_CI_COMMIT_HASH="$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Build
run: ./gradlew build -x test
run: ./gradlew build -x test -x detekt

- name: Create artifact
run: >
Expand Down
57 changes: 56 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ plugins {
id 'jacoco'

id "org.jetbrains.kotlin.jvm" version "1.6.10"

// Linter
id 'io.gitlab.arturbosch.detekt' version '1.19.0'
}

// 変数定義
Expand Down Expand Up @@ -165,7 +168,6 @@ spotless {

kotlin {
ktfmt('0.15')
//diktat('0.4.0')
}

groovyGradle {
Expand All @@ -174,6 +176,58 @@ spotless {
}
}

detekt {
// Version of Detekt that will be used. When unspecified the latest detekt
// version found will be used. Override to stay on the same version.
toolVersion = "1.19.0"

// Define the detekt configuration(s) you want to use.
// Defaults to the default detekt configuration.
config = files("detekt.yml")

//
// // Specifying a baseline file. All findings stored in this file in subsequent runs of detekt.
// baseline = file("path/to/baseline.xml")

// Disables all default detekt rulesets and will only run detekt with custom rules
// defined in plugins passed in with `detektPlugins` configuration. `false` by default.
disableDefaultRuleSets = false

// Adds debug output during task execution. `false` by default.
debug = false

// If set to `true` the build does not fail when the
// maxIssues count was reached. Defaults to `false`.
ignoreFailures = false

// Android: Don't create tasks for the specified build types (e.g. "release")
ignoredBuildTypes = ["release"]

// Android: Don't create tasks for the specified build flavor (e.g. "production")
ignoredFlavors = ["production"]

// Android: Don't create tasks for the specified build variants (e.g. "productionRelease")
ignoredVariants = ["productionRelease"]

// Specify the base path for file paths in the formatted reports.
// If not set, all file paths reported will be absolute file path.
basePath = projectDir
}

tasks.named("detekt").configure {
dependsOn 'spotlessApply'
reports {
xml.required.set(false)
sarif.required.set(false)

html.required.set(true)
html.outputLocation.set(file("build/reports/detekt.html"))

txt.required.set(true)
txt.outputLocation.set(file("build/reports/detekt.txt"))
}
}

version = '0.0.0-SNAPSHOT'
if (project.hasProperty('CI_VERSION')) {
version = CI_VERSION
Expand Down Expand Up @@ -266,6 +320,7 @@ tasks.register('jlink', Exec) {
spotlessApply.dependsOn(['clean'])
versionSet.dependsOn(['spotlessApply'])
test.dependsOn('spotlessApply')
// detekt.dependsOn('spotlessApply')
processResources.dependsOn(['versionSet'])
compileJava.dependsOn(['processResources'])
compileKotlin.dependsOn(['processResources'])
Expand Down
Loading

0 comments on commit 6517740

Please sign in to comment.