Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
54bb40b
Updating
sp4wna1 Apr 13, 2020
44ddc1b
Adding parameters
sp4wna1 Apr 13, 2020
385162c
Adding dangerfile
sp4wna1 Apr 13, 2020
a3206be
Fixing ktlint.gradle
sp4wna1 Apr 30, 2020
200f00a
Fixing detekt.gradle
sp4wna1 Apr 30, 2020
c5aca0d
Adding tests examples
sp4wna1 Apr 30, 2020
ac9a1e0
Adding report path
sp4wna1 Apr 30, 2020
2e52eb1
Using Detekt with Danger
sp4wna1 Apr 30, 2020
e5bdc68
Adding warning to severity
sp4wna1 Apr 30, 2020
02d7784
Removing duplicated call
sp4wna1 Apr 30, 2020
7b9aaeb
Adding danger-kotlint_detekt to Gemfile.lock
sp4wna1 Apr 30, 2020
8aa2f2b
Adding frozen literal
sp4wna1 Apr 30, 2020
4d292e5
Adding # to frozen literal
sp4wna1 Apr 30, 2020
bcd0300
Updating danger
sp4wna1 Apr 30, 2020
3c983d9
Updating danger
sp4wna1 Apr 30, 2020
aa7c098
Adding root path
sp4wna1 Apr 30, 2020
bd793aa
Updating default path
sp4wna1 Apr 30, 2020
09ec592
Updating report path
sp4wna1 Apr 30, 2020
a5d3d24
Removing unused file
sp4wna1 May 3, 2020
2224023
Removing inlinemode
sp4wna1 May 3, 2020
4a05583
Adding threshold to test
sp4wna1 May 3, 2020
b21357d
Adding default threshold
sp4wna1 May 3, 2020
e79f518
Adding detekt from NFesquest
sp4wna1 May 3, 2020
ae67e11
Removing frozen literal
sp4wna1 May 3, 2020
a0220f1
Inline true
sp4wna1 May 3, 2020
229285c
Adding ktlint
sp4wna1 May 3, 2020
9b4296b
Updating repos
sp4wna1 May 3, 2020
0823745
Removing old configuration
sp4wna1 May 10, 2020
ff59e81
Bundler init
sp4wna1 May 10, 2020
e4e9243
Adding danger
sp4wna1 May 10, 2020
1fa01ea
Adding detekt Danger
sp4wna1 May 10, 2020
325689e
Adding ktlint Danger
sp4wna1 May 10, 2020
8941fda
Adding danger to Gemfile
sp4wna1 May 10, 2020
74e8056
Creating gemfile lock with danger
sp4wna1 May 10, 2020
132df3f
Creating empty dangerfile
sp4wna1 May 10, 2020
0648b26
Adding detekt to dangerfile
sp4wna1 May 10, 2020
a697fbe
Adding detekt danger
sp4wna1 May 10, 2020
bbdb234
Adding danger ktlint
sp4wna1 May 10, 2020
3562db2
Adding ktlint to dangerfile
sp4wna1 May 10, 2020
b6b545c
Changing to Checkstyle format
sp4wna1 May 10, 2020
d0c6d13
Bundler install
sp4wna1 May 10, 2020
843341e
Adding reporter and output
sp4wna1 May 10, 2020
8895c82
Adding checkstyle usage
sp4wna1 May 10, 2020
118bafb
Adding gradle task
sp4wna1 May 10, 2020
aa47c3c
Updating revision
sp4wna1 May 10, 2020
d081950
Updating file report
sp4wna1 May 10, 2020
ca802f3
Testing inlinemode true
sp4wna1 May 11, 2020
a26f5f8
Ignoring exit value
sp4wna1 May 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kotlin_detekt.severity = "warning"
kotlin_detekt.gradle_task = "detektVerification"
kotlin_detekt.report_file = "app/build/reports/detekt/detekt-checkstyle.xml"
kotlin_detekt.detekt(inline_mode: true)

checkstyle_format.base_path = Dir.pwd
checkstyle_format.gradle_task = "ktlintVerification"
checkstyle_format.report 'app/build/reports/ktlint/ktlint-checkstyle.xml'
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'danger'
gem "danger", "~> 7.0.0"
gem "danger-kotlin_detekt", :github => "sp4wna1/danger-kotlin_detekt"
gem "danger-checkstyle_format", :github => "sp4wna1/danger-checkstyle_format"
51 changes: 41 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
GIT
remote: https://github.com/sp4wna1/danger-checkstyle_format
revision: 3df9a0ab7ee1cdc6ec0901f3cb2a67f60a758dc4
specs:
danger-checkstyle_format (0.1.0)
danger-plugin-api (~> 1.0)
ox (~> 2.0)

GIT
remote: https://github.com/sp4wna1/danger-kotlin_detekt
revision: b45824e4bc8e02feb4f3fc78cb7e2741cb7fcdb5
specs:
danger-kotlin_detekt (0.0.3)
danger-plugin-api (~> 1.0)
oga

GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ansi (1.5.0)
ast (2.4.0)
claide (1.0.3)
claide-plugins (0.9.2)
cork
Expand All @@ -11,26 +29,29 @@ GEM
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (6.3.2)
danger (7.0.1)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (~> 0.9)
faraday (>= 0.9.0, < 2.0)
faraday-http-cache (~> 2.0)
git (~> 1.6)
git (~> 1.7)
kramdown (~> 2.0)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
faraday (0.17.3)
danger-plugin-api (1.0.0)
danger (> 2.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
faraday-http-cache (2.1.0)
faraday (~> 0.8)
git (1.6.0)
faraday-http-cache (2.2.0)
faraday (>= 0.8)
git (1.7.0)
rchardet (~> 1.8)
kramdown (2.1.0)
kramdown (2.2.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
multipart-post (2.1.1)
Expand All @@ -39,9 +60,17 @@ GEM
octokit (4.18.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
oga (3.2)
ast
ruby-ll (~> 2.1)
open4 (1.3.4)
public_suffix (4.0.4)
ox (2.13.2)
public_suffix (4.0.5)
rchardet (1.8.0)
rexml (3.2.4)
ruby-ll (2.1.2)
ansi
ast
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
Expand All @@ -53,7 +82,9 @@ PLATFORMS
ruby

DEPENDENCIES
danger
danger (~> 7.0.0)
danger-checkstyle_format!
danger-kotlin_detekt!

BUNDLED WITH
2.1.4
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package br.com.prado.staticanalysis

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
Copy link
Collaborator

@Sp4wNa1-Bot Sp4wNa1-Bot May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Wildcard import (cannot be auto-corrected)

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/br/com/prado/staticanalysis/TestDetekt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ package br.com.prado.staticanalysis

import java.util.*
Copy link
Collaborator

@Sp4wNa1-Bot Sp4wNa1-Bot May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Wildcard import (cannot be auto-corrected)


class TestDetektErro {

}
class TestDetektErro
13 changes: 6 additions & 7 deletions app/src/main/java/br/com/prado/staticanalysis/TestKtlint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ package br.com.prado.staticanalysis

import java.util.*
Copy link
Collaborator

@Sp4wNa1-Bot Sp4wNa1-Bot May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Wildcard import (cannot be auto-corrected)


class TestKtlint {
class TestKtlint

}
class A

class A {}
class B

fun G() {}
Copy link
Collaborator

@Sp4wNa1-Bot Sp4wNa1-Bot May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
Function names should match the pattern: ^([a-z$][a-zA-Z$0-9]*) (.*)$


class B {}

fun f(): Unit {}
fun f() {}

/* OUTPUT da Task Gradle

Expand All @@ -24,4 +23,4 @@ staticanalysis/TestKtlint.kt:11:1: Needless blank line(s)
staticanalysis/TestKtlint.kt:12:9: Unnecessary block ("{}")
staticanalysis/TestKtlint.kt:14:10: Unnecessary "Unit" return type

*/
*/
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package br.com.prado.staticanalysis

import org.junit.Test

import org.junit.Assert.*
Copy link
Collaborator

@Sp4wNa1-Bot Sp4wNa1-Bot May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 Wildcard import (cannot be auto-corrected)

import org.junit.Test

/**
* Example local unit test, which will execute on the development machine (host).
Expand Down
10 changes: 0 additions & 10 deletions arquivosModificados.sh

This file was deleted.

5 changes: 4 additions & 1 deletion config/detekt/detekt-config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
maxIssues: 0
maxIssues: 10
excludeCorrectable: false
weights:
# complexity: 2
Expand Down Expand Up @@ -132,6 +132,7 @@ empty-blocks:
active: true
EmptyFunctionBlock:
active: true
threshold: 4
ignoreOverridden: false
EmptyIfBlock:
active: true
Expand Down Expand Up @@ -343,6 +344,7 @@ naming:
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
ignoreOverridden: true
threshold: 4
FunctionParameterNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
Expand All @@ -355,6 +357,7 @@ naming:
MatchingDeclarationName:
active: true
mustBeFirst: true
threshold: 4
MemberNameEqualsClassName:
active: true
ignoreOverridden: true
Expand Down
32 changes: 10 additions & 22 deletions config/detekt/detekt.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,16 @@ dependencies {
detekt libraries.detekt
}

def static execute(cmd, output) {
cmd.execute().waitForProcessOutput(output, System.err)
}

task detektVerification(group: "verification") {
task detektVerification(type: JavaExec, group: "verification") {
description = "Check Kotlin code smells, code complexity based on detekt-config.yml."

doFirst {
new ByteArrayOutputStream().withStream { output ->
main = "io.gitlab.arturbosch.detekt.cli.Main"
classpath = configurations.detekt

execute("./arquivosModificados.sh origin/master detekt", output)

if (!"$output".isEmpty()) {
javaexec {
main = "io.gitlab.arturbosch.detekt.cli.Main"
classpath = configurations.detekt
def dir = "$rootDir/config/detekt"
def config = "$dir/detekt-config.yml"
def params = ["-i", "$output", "-c", config]
args(params)
}
}
}
}
}
def input = "$projectDir"
def dir = "$rootDir/config/detekt"
def config = "$dir/detekt-config.yml"
def report = "xml:$buildDir/reports/detekt/detekt-checkstyle.xml"
def params = ["-i", input, "-c", config, "-r", report]
args(params)
}
25 changes: 6 additions & 19 deletions config/ktlint/ktlint.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,13 @@ configurations {
dependencies {
ktlint libraries.ktlint
}
def static execute(cmd, output) {
cmd.execute().waitForProcessOutput(output, System.err)
}
task ktlintVerification(group: "verification") {
description = "Check Kotlin code style."

doFirst {
new ByteArrayOutputStream().withStream { output ->

execute("./arquivosModificados.sh origin/master ktlint", output)
task ktlintVerification(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt", "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/reports/ktlint/ktlint-checkstyle.xml"

if (!"$output".isEmpty()) {
javaexec {
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "$output".split("\n")
}
} else {
print("What")
}
}
}
ignoreExitValue true
}