Class: Danger::DangerCheckstyleReports
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerCheckstyleReports
- Defined in:
- lib/checkstyle_reports/plugin.rb
Overview
Comment checkstyle reports.
You need to specify the project root. You don’t need do it if it is same with git’s top-level path.
checkstyle_reports.root_path=/path/to/project
Constant Summary collapse
- REPORT_METHODS =
%i[message warn fail].freeze
Instance Attribute Summary collapse
-
#filtering ⇒ Object
Enable filtering Only show messages within changed files.
-
#filtering_lines ⇒ Object
Only show messages for the modified lines.
-
#inline_comment ⇒ Boolean
Optional Create inline comment if true.
-
#min_severity ⇒ String, Symbol
Optional minimum severity to be reported (inclusive).
-
#report_method ⇒ String, Symbol
Optional Set report method.
-
#reported_files ⇒ Array<String>
readonly
The array of files which include at least one error.
-
#root_path ⇒ String
Optional An absolute path to a root.
Instance Method Summary collapse
-
#report(xml_file, modified_files_only: true) ⇒ void
Report errors based on the given xml file if needed.
Instance Attribute Details
#filtering ⇒ Object
Enable filtering Only show messages within changed files.
60 61 62 |
# File 'lib/checkstyle_reports/plugin.rb', line 60 def filtering @filtering end |
#filtering_lines ⇒ Object
Only show messages for the modified lines.
63 64 65 |
# File 'lib/checkstyle_reports/plugin.rb', line 63 def filtering_lines @filtering_lines end |
#inline_comment ⇒ Boolean
Optional Create inline comment if true.
44 45 46 |
# File 'lib/checkstyle_reports/plugin.rb', line 44 def inline_comment @inline_comment end |
#min_severity ⇒ String, Symbol
Optional minimum severity to be reported (inclusive)
50 51 52 |
# File 'lib/checkstyle_reports/plugin.rb', line 50 def min_severity @min_severity end |
#report_method ⇒ String, Symbol
Optional Set report method
56 57 58 |
# File 'lib/checkstyle_reports/plugin.rb', line 56 def report_method @report_method end |
#reported_files ⇒ Array<String> (readonly)
The array of files which include at least one error
68 69 70 |
# File 'lib/checkstyle_reports/plugin.rb', line 68 def reported_files @reported_files end |
#root_path ⇒ String
Optional An absolute path to a root. To comment errors to VCS, this needs to know relative path of files from the root.
38 39 40 |
# File 'lib/checkstyle_reports/plugin.rb', line 38 def root_path @root_path end |
Instance Method Details
#report(xml_file, modified_files_only: true) ⇒ void
This method returns an undefined value.
Report errors based on the given xml file if needed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/checkstyle_reports/plugin.rb', line 75 def report(xml_file, modified_files_only: true) raise 'File path must not be empty' if xml_file.empty? raise 'File not found' unless File.exist?(xml_file) @min_severity = (min_severity || :error).to_sym @report_method = (report_method || :fail).to_sym raise 'Unknown severity found' unless CheckstyleReports::Severity::VALUES.include?(min_severity) raise 'Unknown report method' unless REPORT_METHODS.include?(report_method) files = parse_xml(xml_file, modified_files_only) @reported_files = files.map(&:relative_path) do_comment(files) unless files.empty? end |