Class: Danger::DangerResharperInspectcode

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

Overview

Danger plugin for JetBrains ReSharper InspectCode.

Examples:

Parse the report XML file and do reporting

resharper_inspectcode.base_path = Dir.pwd
resharper_inspectcode.report 'report.xml'

See Also:

  • tumugin/danger-resharper_inspectcode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dangerfile) ⇒ DangerResharperInspectcode

Returns a new instance of DangerResharperInspectcode.



33
34
35
36
# File 'lib/resharper_inspectcode/plugin.rb', line 33

def initialize(dangerfile)
  super(dangerfile)
  @base_path ||= Dir.pwd
end

Instance Attribute Details

#base_pathString

Base path of report file

Returns:

  • (String)


16
17
18
# File 'lib/resharper_inspectcode/plugin.rb', line 16

def base_path
  @base_path
end

Instance Method Details

#report(file) ⇒ void

This method returns an undefined value.

Report warnings

Parameters:

  • file (String)

    File path of ReSharper InspectCode report file



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/resharper_inspectcode/plugin.rb', line 21

def report(file)
  raise "Please specify file name." if file.empty?

  filepath = @base_path + (@base_path.end_with?("/") ? "" : "/") + file
  raise "No report file was found at #{filepath}" unless File.exist?(filepath)

  issues = ReportParser.parse_report_xml(filepath)
  issues.each do |issue|
    warn(issue.message, file: issue.file, line: issue.line)
  end
end