danger-checkstyle_xml 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/Gemfile.lock +1 -1
- data/lib/checkstyle_format/checkstyle_error.rb +1 -1
- data/lib/checkstyle_format/gem_version.rb +1 -1
- data/lib/checkstyle_format/plugin.rb +8 -10
- data/spec/checkstyle_format_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd740ce3fb5ca517dc3568735af078687506142537344f1ce5ae60f74f130a10
|
4
|
+
data.tar.gz: 5470bd1a659ec87a018802f9b86dd79e1ba7a819ace0b7a6751b648130967a86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8b7bfb39e30907edf9f64b2b16645631a1ef457403c1d25ad0f9daa0171e00fc11dcb6e675a1d910e7a855e8ea164409c63b868d9e65ae9a990cc8f968fec86
|
7
|
+
data.tar.gz: ffe9414bd5b548a51f536e43cfa33e578dfedf9435373a588c1cf6b79c289438a2489f19c734752be27f22be4df3ce48d0bc2685fcb56f89f3454061cbbd00cc
|
data/.rubocop.yml
CHANGED
@@ -17,13 +17,16 @@ Lint/UselessAssignment:
|
|
17
17
|
Exclude:
|
18
18
|
- '**/spec/**/*'
|
19
19
|
|
20
|
-
# We could potentially enable the
|
20
|
+
# We could potentially enable the 3 below:
|
21
21
|
Layout/FirstHashElementIndentation:
|
22
22
|
Enabled: false
|
23
23
|
|
24
24
|
Layout/HashAlignment:
|
25
25
|
Enabled: false
|
26
26
|
|
27
|
+
Layout/EndOfLine:
|
28
|
+
Enabled: false
|
29
|
+
|
27
30
|
# HoundCI doesn't like this rule
|
28
31
|
Layout/DotPosition:
|
29
32
|
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
CheckstyleError = Struct.new(:file_name, :line, :column, :severity, :message, :source) do
|
4
|
-
def self.generate(node, parent_node, sub_regex)
|
4
|
+
def self.generate(node, parent_node, sub_regex)
|
5
5
|
relative_path = parent_node[:name].sub(sub_regex, "")
|
6
6
|
|
7
7
|
CheckstyleError.new(
|
@@ -7,22 +7,22 @@ module Danger
|
|
7
7
|
#
|
8
8
|
# @example Parse the XML file, and let the plugin do your reporting
|
9
9
|
#
|
10
|
-
# checkstyle_format.
|
10
|
+
# checkstyle_format.base_regex = %r{^.*?\/src\/}
|
11
11
|
# checkstyle_format.report 'app/build/reports/checkstyle/checkstyle.xml'
|
12
12
|
#
|
13
13
|
# @example Parse the XML text, and let the plugin do your reporting
|
14
14
|
#
|
15
|
-
# checkstyle_format.
|
15
|
+
# checkstyle_format.base_regex = %r{^.*?\/src\/}
|
16
16
|
# checkstyle_format.report_by_text '<?xml ...'
|
17
17
|
#
|
18
18
|
# @see noboru-i/danger-checkstyle_format
|
19
19
|
# @tags lint, reporting
|
20
20
|
#
|
21
21
|
class DangerCheckstyleFormat < Plugin
|
22
|
-
# Base
|
22
|
+
# Base regex for converting the full paths into relative paths.
|
23
23
|
# Defaults to nil.
|
24
24
|
# @return [String]
|
25
|
-
attr_accessor :
|
25
|
+
attr_accessor :base_regex
|
26
26
|
|
27
27
|
# Report checkstyle warnings
|
28
28
|
#
|
@@ -57,13 +57,10 @@ module Danger
|
|
57
57
|
present_elements = doc.nodes.first.nodes.reject do |test|
|
58
58
|
test.nodes.empty?
|
59
59
|
end
|
60
|
-
|
61
|
-
# base_path_suffix = @base_path.end_with?("/") ? "" : "/"
|
62
|
-
# base_path = @base_path + base_path_suffix
|
63
60
|
|
64
61
|
present_elements.flat_map do |parent|
|
65
62
|
parent.nodes.map do |child|
|
66
|
-
CheckstyleError.generate(child, parent, @
|
63
|
+
CheckstyleError.generate(child, parent, @base_regex)
|
67
64
|
end
|
68
65
|
end
|
69
66
|
end
|
@@ -72,13 +69,14 @@ module Danger
|
|
72
69
|
if inline_mode
|
73
70
|
send_inline_comment(errors)
|
74
71
|
else
|
75
|
-
|
72
|
+
# TODO: not implemented.
|
73
|
+
raise "Not implemented."
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
77
|
def send_inline_comment(errors)
|
80
78
|
errors.each do |error|
|
81
|
-
puts "Sending inline comment to file #{error.file_name}, line #{error.line}"
|
79
|
+
# puts "Sending inline comment to file #{error.file_name}, line #{error.line}"
|
82
80
|
warn(error.message, file: error.file_name, line: error.line)
|
83
81
|
end
|
84
82
|
end
|
@@ -29,7 +29,7 @@ module Danger
|
|
29
29
|
|
30
30
|
describe ".parse" do
|
31
31
|
subject(:errors) do
|
32
|
-
@checkstyle_format.
|
32
|
+
@checkstyle_format.base_regex = %r{^.*?/to/}
|
33
33
|
@checkstyle_format.send(:parse, File.read("spec/fixtures/checkstyle.xml"))
|
34
34
|
end
|
35
35
|
it "have 4 items" do
|