danger-checkstyle_format 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/checkstyle_format/gem_version.rb +1 -1
- data/lib/checkstyle_format/plugin.rb +28 -9
- data/spec/checkstyle_format_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 979204d1d5978fbd6d160175238a593c408585d7
|
4
|
+
data.tar.gz: 1c46f43bc1452d88c76775152b07fcca9345cfa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d679c9d8a9f5c4d52c473705d1203bb21980185340b146e244eb3e0be82041cdc0c1f52a34c5fe3dedbeed6d55279135599aef9af4b85e1e8d550f69a3331669
|
7
|
+
data.tar.gz: 2d3da84229b1764ea7637144d41f3dc36fd0eaa379ba45ae4799c17fb76746e09ecb360e39027fa2e6975c1c5b53b2145c73e83f4204bd1b21623d474573d0c1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,12 @@ checkstyle_format.base_path = Dir.pwd
|
|
16
16
|
checkstyle_format.report 'app/build/reports/checkstyle/checkstyle.xml'</pre>
|
17
17
|
</blockquote>
|
18
18
|
|
19
|
+
<blockquote>Parse the XML text, and let the plugin do your reporting
|
20
|
+
<pre>
|
21
|
+
checkstyle_format.base_path = Dir.pwd
|
22
|
+
checkstyle_format.report_by_text '<?xml ...'</pre>
|
23
|
+
</blockquote>
|
24
|
+
|
19
25
|
## Development
|
20
26
|
|
21
27
|
1. Clone this repo
|
@@ -8,6 +8,11 @@ module Danger
|
|
8
8
|
# checkstyle_format.base_path = Dir.pwd
|
9
9
|
# checkstyle_format.report 'app/build/reports/checkstyle/checkstyle.xml'
|
10
10
|
#
|
11
|
+
# @example Parse the XML text, and let the plugin do your reporting
|
12
|
+
#
|
13
|
+
# checkstyle_format.base_path = Dir.pwd
|
14
|
+
# checkstyle_format.report_by_text '<?xml ...'
|
15
|
+
#
|
11
16
|
# @see noboru-i/danger-checkstyle_format
|
12
17
|
# @tags lint, reporting
|
13
18
|
#
|
@@ -18,26 +23,32 @@ module Danger
|
|
18
23
|
attr_accessor :base_path
|
19
24
|
|
20
25
|
# Report checkstyle warnings
|
21
|
-
# @return [void]
|
22
26
|
#
|
27
|
+
# @return [void]
|
23
28
|
def report(file, inline_mode = true)
|
24
29
|
raise "Please specify file name." if file.empty?
|
25
30
|
raise "No checkstyle file was found at #{file}" unless File.exist? file
|
26
|
-
errors = parse(file)
|
31
|
+
errors = parse(File.read(file))
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
send_comment(errors, inline_mode)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Report checkstyle warnings by XML text
|
37
|
+
#
|
38
|
+
# @return [void]
|
39
|
+
def report_by_text(text, inline_mode = true)
|
40
|
+
raise "Please specify xml text." if text.empty?
|
41
|
+
errors = parse(text)
|
42
|
+
|
43
|
+
send_comment(errors, inline_mode)
|
33
44
|
end
|
34
45
|
|
35
46
|
private
|
36
47
|
|
37
|
-
def parse(
|
48
|
+
def parse(text)
|
38
49
|
require "ox"
|
39
50
|
|
40
|
-
doc = Ox.parse(
|
51
|
+
doc = Ox.parse(text)
|
41
52
|
present_elements = doc.nodes.first.nodes.reject do |test|
|
42
53
|
test.nodes.empty?
|
43
54
|
end
|
@@ -52,6 +63,14 @@ module Danger
|
|
52
63
|
elements
|
53
64
|
end
|
54
65
|
|
66
|
+
def send_comment(errors, inline_mode)
|
67
|
+
if inline_mode
|
68
|
+
send_inline_comment(errors)
|
69
|
+
else
|
70
|
+
raise "not implemented." # TODO: not implemented.
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
55
74
|
def send_inline_comment(errors)
|
56
75
|
errors.each do |error|
|
57
76
|
warn(error.message, file: error.file_name, line: error.line)
|
@@ -28,7 +28,7 @@ module Danger
|
|
28
28
|
describe ".parse" do
|
29
29
|
subject(:errors) do
|
30
30
|
@checkstyle_format.base_path = "/path/to"
|
31
|
-
@checkstyle_format.send(:parse, "spec/fixtures/checkstyle.xml")
|
31
|
+
@checkstyle_format.send(:parse, File.read("spec/fixtures/checkstyle.xml"))
|
32
32
|
end
|
33
33
|
it "have 4 items" do
|
34
34
|
expect(errors.size).to be 4
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-checkstyle_format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- noboru-i
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|