danger-checkstyle_formatter 0.0.1 → 0.0.2

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: 2fa439c0c2eacb8943b28f8620970be83bf74702710da4c22f39100af3cb9174
4
- data.tar.gz: b08d08d063db89ddf5dd2c52f0fda97f14cb9e16e9c5b8f5dd0ee8b59a95f6f2
3
+ metadata.gz: 313c129a86402d906ec66558913984510f2ee2383f10f953cf49329605f9a28d
4
+ data.tar.gz: 40c72d863de1a76f9966fb40cba03a6d3db8632496c1fd80aaed479d70617c0c
5
5
  SHA512:
6
- metadata.gz: 75f20cc610cc65ba1e82a085d7fc53b03b2f1a7dc45529b3aea381e832d18046ec211aa24c3633443acd8c5bdf54219cb42e36f3713d04e46cc724205eaff9cb
7
- data.tar.gz: 6321330dd3d017ea3f604ad3f347b4be18467065d7af96ad054e1edbfb982500b0894e68b7226dfa40e2c65cd145f540d5a4b26dbaba7637345a4ea6f4c01058
6
+ metadata.gz: 573f0b33bbdd9426d6dacc97909bc4fa829ae11bd487c416ace88ee91baf662b073471326d09ea00f224a0730570f68e72d787134fafe8770c8beae209669f38
7
+ data.tar.gz: 2cb06bef03beeb8085b9fa22533e0ae4664dedd42b4eb0bd35385545e24f154d39ce6f841ce5f293734cf1aa7e1aab3fca938948dbb9a72ea5c9dbdc36965e38
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-checkstyle_formatter (0.0.1)
4
+ danger-checkstyle_formatter (0.0.2)
5
5
  danger-plugin-api (~> 1.0)
6
6
  ox (~> 2.0)
7
7
 
@@ -1,3 +1,3 @@
1
1
  module CheckstyleFormatter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -73,7 +73,7 @@ module Danger
73
73
 
74
74
  def send_inline_comment(errors)
75
75
  errors.each do |error|
76
- fail(error.message, file: error.file_name, line: error.line)
76
+ warn(error.message, file: error.file_name, line: error.line)
77
77
  end
78
78
  end
79
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-checkstyle_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - noboru-i
@@ -182,8 +182,6 @@ files:
182
182
  - README.md
183
183
  - Rakefile
184
184
  - danger-checkstyle_format.gemspec
185
- - lib/checkstyle_format/gem_version.rb
186
- - lib/checkstyle_format/plugin.rb
187
185
  - lib/checkstyle_formatter/checkstyle_error.rb
188
186
  - lib/checkstyle_formatter/gem_version.rb
189
187
  - lib/checkstyle_formatter/plugin.rb
@@ -1,3 +0,0 @@
1
- module CheckstyleFormatter
2
- VERSION = "0.0.1"
3
- end
@@ -1,80 +0,0 @@
1
- require_relative "checkstyle_error"
2
-
3
- module Danger
4
- # Danger plugin for checkstyle formatted xml file.
5
- #
6
- # @example Parse the XML file, and let the plugin do your reporting
7
- #
8
- # checkstyle_format.base_path = Dir.pwd
9
- # checkstyle_format.report 'app/build/reports/checkstyle/checkstyle.xml'
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
- #
16
- # @see noboru-i/danger-checkstyle_format
17
- # @tags lint, reporting
18
- #
19
- class DangerCheckstyleFormatter < Plugin
20
- # Base path of `name` attributes in `file` tag.
21
- # Defaults to nil.
22
- # @return [String]
23
- attr_accessor :base_path
24
-
25
- # Report checkstyle warnings
26
- #
27
- # @return [void]
28
- def report(file, inline_mode = true)
29
- raise "Please specify file name." if file.empty?
30
- raise "No checkstyle file was found at #{file}" unless File.exist? file
31
- errors = parse(File.read(file))
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)
44
- end
45
-
46
- private
47
-
48
- def parse(text)
49
- require "ox"
50
-
51
- doc = Ox.parse(text)
52
- present_elements = doc.nodes.first.nodes.reject do |test|
53
- test.nodes.empty?
54
- end
55
- base_path_suffix = @base_path.end_with?("/") ? "" : "/"
56
- base_path = @base_path + base_path_suffix
57
- elements = present_elements.flat_map do |parent|
58
- parent.nodes.map do |child|
59
- CheckstyleError.generate(child, parent, base_path)
60
- end
61
- end
62
-
63
- elements
64
- end
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
-
74
- def send_inline_comment(errors)
75
- errors.each do |error|
76
- fail(error.message, file: error.file_name, line: error.line)
77
- end
78
- end
79
- end
80
- end