danger-static_analyzer_comments 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +80 -0
- data/.idea/inspectionProfiles/Project_Default.xml +6 -0
- data/lib/danger_plugin.rb +42 -16
- data/lib/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ca60892fd8da20ab1a3ffa4488c95f7b85b4e51
|
4
|
+
data.tar.gz: ff433712c0ec41d165baae60bebc07c37f05e465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 603d9b7a049624d9dfce083875ce5ca62173253546e924dc47dc6eb1a9fce761a93dc179039b10b1574a3abeca6d6f70b6d70681870618169e317b535d1575dc
|
7
|
+
data.tar.gz: 964aee52512b13fb046d191f49db060db9588a11f102de742db8cd691004b35ac46fdb5cf6d6a41c9ef04e94472cd74c0f03bfbfe2ea72d0a25c255d548de18e
|
data/.gitignore
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# read http://stackoverflow.com/a/8527650/1852422
|
2
|
+
# https://stackoverflow.com/questions/11968531/what-to-gitignore-from-the-idea-folder
|
3
|
+
|
4
|
+
# generated files
|
5
|
+
bin/
|
6
|
+
build/
|
7
|
+
*.ap_
|
8
|
+
|
9
|
+
# Local configuration file (sdk path, etc.)
|
10
|
+
local.properties
|
11
|
+
|
12
|
+
# Java class files
|
13
|
+
*.class
|
14
|
+
|
15
|
+
# User-specific (aka high-churn) files
|
16
|
+
**/.idea/workspace.xml
|
17
|
+
**/.idea/tasks.xml
|
18
|
+
**/.idea/dictionaries
|
19
|
+
**/.idea/vcs.xml
|
20
|
+
**/.idea/shelf
|
21
|
+
**/.idea/runConfigurations/
|
22
|
+
**/.idea/runConfigurations.xml
|
23
|
+
**/.idea/jsLibraryMappings.xml
|
24
|
+
**/.idea/caches/
|
25
|
+
*.iml
|
26
|
+
.navigation
|
27
|
+
**/.idea/assetWizardSettings.xml
|
28
|
+
**/.idea/misc.xml
|
29
|
+
|
30
|
+
# Statistic plugin
|
31
|
+
**/.idea/statistic.xml
|
32
|
+
|
33
|
+
# Gradle:
|
34
|
+
**/.idea/gradle.xml
|
35
|
+
**/.idea/libraries
|
36
|
+
.gradle
|
37
|
+
|
38
|
+
# Sensitive or high-churn files
|
39
|
+
**/.idea/dataSources.ids
|
40
|
+
**/.idea/dataSources.xml
|
41
|
+
**/.idea/dataSources.local.xml
|
42
|
+
**/.idea/sqlDataSources.xml
|
43
|
+
**/.idea/dynamic.xml
|
44
|
+
**/.idea/uiDesigner.xml
|
45
|
+
|
46
|
+
# File-based project format
|
47
|
+
*.iws
|
48
|
+
|
49
|
+
# IntelliJ
|
50
|
+
/out/
|
51
|
+
|
52
|
+
.externalNativeBuild
|
53
|
+
|
54
|
+
# AS' Layout Inspector files
|
55
|
+
*/captures
|
56
|
+
|
57
|
+
# OS X junk
|
58
|
+
.DS_Store
|
59
|
+
|
60
|
+
# files for the dex VM
|
61
|
+
*.dex
|
62
|
+
|
63
|
+
# woof woof!
|
64
|
+
doge.jp[e]g
|
65
|
+
|
66
|
+
## Ruby environment normalization
|
67
|
+
/.bundle/
|
68
|
+
/vendor/bundle
|
69
|
+
/lib/bundler/man/
|
70
|
+
|
71
|
+
## Documentation cache and generated files:
|
72
|
+
/.yardoc/
|
73
|
+
/_yardoc/
|
74
|
+
/doc/
|
75
|
+
/rdoc/
|
76
|
+
|
77
|
+
## Environment normalization:
|
78
|
+
/.bundle/
|
79
|
+
/vendor/bundle
|
80
|
+
/lib/bundler/man/
|
data/lib/danger_plugin.rb
CHANGED
@@ -2,46 +2,72 @@ require 'oga'
|
|
2
2
|
|
3
3
|
module Danger
|
4
4
|
|
5
|
-
# A Danger plugin which turns static analyzers' output into inline Github comments
|
6
5
|
class DangerStaticAnalyzerComments < Plugin
|
7
6
|
LINT_SEVERITY_LEVELS = ["Warning", "Error", "Fatal"]
|
7
|
+
CHECKSTYLE_SEVERITY_LEVELS = ["ignore", "info", "warning", "error"]
|
8
8
|
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :android_lint_report_file
|
10
|
+
attr_accessor :checkstyle_report_file
|
10
11
|
|
11
12
|
def run
|
12
|
-
|
13
|
+
android_lint
|
14
|
+
checkstyle
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
16
|
-
unless File.exists?(@
|
17
|
-
fail("Lint report not found at `#{@
|
17
|
+
def android_lint
|
18
|
+
unless File.exists?(@android_lint_report_file)
|
19
|
+
fail("Lint report not found at `#{@android_lint_report_file}`.")
|
18
20
|
end
|
19
21
|
|
20
|
-
file = File.open(@
|
22
|
+
file = File.open(@android_lint_report_file)
|
21
23
|
report = Oga.parse_xml(file)
|
22
24
|
issues = report.xpath('//issue')
|
23
|
-
|
25
|
+
send_android_lint_inline_comment(issues)
|
24
26
|
end
|
25
27
|
|
28
|
+
def checkstyle
|
29
|
+
unless File.exists?(checkstyle_report_file)
|
30
|
+
fail("Checkstyle report not found at `#{checkstyle_report_file}`.")
|
31
|
+
end
|
32
|
+
|
33
|
+
file = File.open(checkstyle_report_file)
|
34
|
+
report = Oga.parse_xml(file)
|
35
|
+
files = report.xpath('/checkstyle/file')
|
36
|
+
send_checkstyle_inline_comment(files)
|
37
|
+
end
|
26
38
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
39
|
+
def send_checkstyle_inline_comment(files)
|
40
|
+
files.each do |file|
|
41
|
+
filename = file.get('name').gsub(current_dir, "")
|
42
|
+
errors = file.xpath('error')
|
43
|
+
errors.each do |error|
|
44
|
+
next unless (target_files.include? filename)
|
45
|
+
line = (error.get('line') || "0").to_i
|
46
|
+
warn(error.get('message'), file: filename, line: line)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def send_android_lint_inline_comment(issues)
|
32
52
|
LINT_SEVERITY_LEVELS.reverse.each do |level|
|
33
53
|
filtered = issues.select {|issue| issue.get("severity") == level}
|
34
54
|
next if filtered.empty?
|
35
55
|
filtered.each do |r|
|
36
56
|
location = r.xpath('location').first
|
37
|
-
filename = location.get('file').gsub(
|
38
|
-
print "location: #{location}, file: #{location.get('file')}, filename: #{filename}"
|
57
|
+
filename = location.get('file').gsub(current_dir, "")
|
39
58
|
next unless (target_files.include? filename)
|
40
|
-
print "target_files includes #{filename}"
|
41
59
|
line = (location.get('line') || "0").to_i
|
42
60
|
send(level === "Warning" ? "warn" : "fail", r.get('message'), file: filename, line: line)
|
43
61
|
end
|
44
62
|
end
|
45
63
|
end
|
64
|
+
|
65
|
+
def target_files
|
66
|
+
(git.modified_files - git.deleted_files) + git.added_files
|
67
|
+
end
|
68
|
+
|
69
|
+
def current_dir
|
70
|
+
"#{Dir.pwd}/"
|
71
|
+
end
|
46
72
|
end
|
47
73
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-static_analyzer_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vibin Reddy
|
@@ -172,6 +172,8 @@ executables: []
|
|
172
172
|
extensions: []
|
173
173
|
extra_rdoc_files: []
|
174
174
|
files:
|
175
|
+
- ".gitignore"
|
176
|
+
- ".idea/inspectionProfiles/Project_Default.xml"
|
175
177
|
- ".idea/misc.xml"
|
176
178
|
- ".idea/modules.xml"
|
177
179
|
- Gemfile
|