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
-
#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
#inline_comment ⇒ Boolean
Optional Create inline comment if true.
45 46 47 |
# File 'lib/checkstyle_reports/plugin.rb', line 45 def inline_comment @inline_comment end |
#min_severity ⇒ String, Symbol
Optional minimum severity to be reported (inclusive)
51 52 53 |
# File 'lib/checkstyle_reports/plugin.rb', line 51 def min_severity @min_severity end |
#report_method ⇒ String, Symbol
Optional Set report method
57 58 59 |
# File 'lib/checkstyle_reports/plugin.rb', line 57 def report_method @report_method end |
#reported_files ⇒ Array<String> (readonly)
The array of files which include at least one error
62 63 64 |
# File 'lib/checkstyle_reports/plugin.rb', line 62 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.
39 40 41 |
# File 'lib/checkstyle_reports/plugin.rb', line 39 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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/checkstyle_reports/plugin.rb', line 69 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 |