Class: Danger::DangerCheckstyleFormat

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

Overview

Danger plugin for checkstyle formatted xml file.

Examples:

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


checkstyle_format.base_path = Dir.pwd
checkstyle_format.report 'app/build/reports/checkstyle/checkstyle.xml'

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


checkstyle_format.base_path = Dir.pwd
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_pathString

Base path of ‘name` attributes in `file` tag. Defaults to nil.

Returns:

  • (String)


23
24
25
# File 'lib/checkstyle_format/plugin.rb', line 23

def base_path
  @base_path
end

Instance Method Details

#report(file, inline_mode = true) ⇒ void

This method returns an undefined value.

Report checkstyle warnings



28
29
30
31
32
33
34
# File 'lib/checkstyle_format/plugin.rb', line 28

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



39
40
41
42
43
44
# File 'lib/checkstyle_format/plugin.rb', line 39

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