danger-checkstyle_xml 0.0.3 → 0.0.5
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/.rubocop.yml +4 -1
 - data/Gemfile.lock +1 -1
 - data/lib/checkstyle_format/checkstyle_error.rb +2 -7
 - data/lib/checkstyle_format/gem_version.rb +1 -1
 - data/lib/checkstyle_format/plugin.rb +8 -11
 - 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,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,  
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
       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,
         
     | 
| 
         @@ -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,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,  
     | 
| 
      
 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 
     | 
    
         
            -
                     
     | 
| 
      
 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. 
     | 
| 
      
 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
         
     |