Class: Danger::DangerCheckstyleFormat

Inherits:
Plugin
  • Object
show all
Defined in:
lib/checkstyle_format/plugin.rb

Overview

Danger plugin for checkstyle xml files.

Examples:

Parse the XML file, and let the plugin do your reporting


checkstyle_format.base_regex = %r{^.*?\/src\/}
checkstyle_format.report 'app/build/reports/checkstyle/checkstyle.xml'

Parse the XML text, and let the plugin do your reporting


checkstyle_format.base_regex = %r{^.*?\/src\/}
checkstyle_format.report_by_text '<?xml ...'

See Also:

  • noboru-i/danger-checkstyle_format

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_regexString

Base regex for converting the full paths into relative paths. Defaults to nil.

Returns:

  • (String)


25
26
27
# File 'lib/checkstyle_format/plugin.rb', line 25

def base_regex
  @base_regex
end

Instance Method Details

#report(file, inline_mode: true) ⇒ void

This method returns an undefined value.

Report checkstyle warnings



30
31
32
33
34
35
36
37
# File 'lib/checkstyle_format/plugin.rb', line 30

def report(file, inline_mode: true)
  raise "Please specify file name." if file.empty?
  raise "No checkstyle file was found at #{file}" unless File.exist? file

  errors = parse(File.read(file))

  send_comment(errors, inline_mode)
end

#report_by_text(text, inline_mode: true) ⇒ void

This method returns an undefined value.

Report checkstyle warnings by XML text



42
43
44
45
46
47
48
# File 'lib/checkstyle_format/plugin.rb', line 42

def report_by_text(text, inline_mode: true)
  raise "Please specify xml text." if text.empty?

  errors = parse(text)

  send_comment(errors, inline_mode)
end