danger-checkstyle_xml 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 258f42658fb6340318ebe52c9f7cb905ced63c26399d375b83a4b5f74818ac30
4
- data.tar.gz: 9f8d3825b0d46a4f3c01e92d52df5d3a60c49c16bec72d3c561d14cc84329842
3
+ metadata.gz: cd740ce3fb5ca517dc3568735af078687506142537344f1ce5ae60f74f130a10
4
+ data.tar.gz: 5470bd1a659ec87a018802f9b86dd79e1ba7a819ace0b7a6751b648130967a86
5
5
  SHA512:
6
- metadata.gz: 9d5c58ea3c4e369bd5c825d0148880231107ab0cdffd644f4c0a6983f6fcf57c36045ee45fad1a44a7fe241b76aaf95393a72e3d357d1b6d8cc945a150b69eb4
7
- data.tar.gz: 5fdb28f9d9cf07fc3aa1462c9932e96b1bd3b98f2f5ed2c7451a66a5f4fc9c2e6a8e9cae0d38c05c1e06302477cfedfeab361af5ad1149db5c1374e7bbb2decc
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 2 below:
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
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-checkstyle_xml (0.0.1)
4
+ danger-checkstyle_xml (0.0.5)
5
5
  danger-plugin-api (~> 1.0)
6
6
  ox (~> 2.14)
7
7
 
@@ -1,13 +1,8 @@
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, base_path)
5
- # Print base path, full path, and relative path
6
- puts "Base path: #{base_path}"
7
- puts "Parent node path: #{parent_node[:name]}"
8
-
9
- relative_path = parent_node[:name].sub(/^#{base_path}/, "")
10
- puts "Relative path: #{relative_path}"
4
+ def self.generate(node, parent_node, sub_regex)
5
+ relative_path = parent_node[:name].sub(sub_regex, "")
11
6
 
12
7
  CheckstyleError.new(
13
8
  relative_path,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CheckstyleFormat
4
- VERSION = "0.0.3".freeze
4
+ VERSION = "0.0.5"
5
5
  end
@@ -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.base_path = Dir.pwd
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.base_path = Dir.pwd
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 path of `name` attributes in `file` tag.
22
+ # Base regex for converting the full paths into relative paths.
23
23
  # Defaults to nil.
24
24
  # @return [String]
25
- attr_accessor :base_path
25
+ attr_accessor :base_regex
26
26
 
27
27
  # Report checkstyle warnings
28
28
  #
@@ -57,14 +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
-
63
- base_path = @base_path + base_path_suffix
64
60
 
65
61
  present_elements.flat_map do |parent|
66
62
  parent.nodes.map do |child|
67
- CheckstyleError.generate(child, parent, base_path)
63
+ CheckstyleError.generate(child, parent, @base_regex)
68
64
  end
69
65
  end
70
66
  end
@@ -73,13 +69,14 @@ module Danger
73
69
  if inline_mode
74
70
  send_inline_comment(errors)
75
71
  else
76
- raise "not implemented." # TODO: not implemented.
72
+ # TODO: not implemented.
73
+ raise "Not implemented."
77
74
  end
78
75
  end
79
76
 
80
77
  def send_inline_comment(errors)
81
78
  errors.each do |error|
82
- 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}"
83
80
  warn(error.message, file: error.file_name, line: error.line)
84
81
  end
85
82
  end
@@ -29,7 +29,7 @@ module Danger
29
29
 
30
30
  describe ".parse" do
31
31
  subject(:errors) do
32
- @checkstyle_format.base_path = "/path/to"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-checkstyle_xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - noboru-i