Sha256: f302d39430705d1059b5edbb938776cf71d0c474e2d381b0320e4b10965fe064

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

require_relative "report_parser"

module Danger
  # Danger plugin for JetBrains ReSharper InspectCode.
  # @example Parse the report XML file and do reporting
  #          resharper_inspectcode.base_path = Dir.pwd
  #          resharper_inspectcode.report 'report.xml'
  # @see tumugin/danger-resharper_inspectcode
  # @tags C#, InspectCode, lint
  class DangerResharperInspectcode < Plugin
    # Base path of report file
    #
    # @return   [String]
    attr_accessor :base_path

    # Report warnings
    # @param file [String] File path of ReSharper InspectCode report file
    def report(file)
      raise "Please specify file name." if file.empty?
      raise "No report file was found at #{file}" if File.exist?(file)

      filepath = @base_path + (@base_path.end_with?("/") ? "" : "/") + file
      issues = ReportParser.parse_report_xml(filepath)
      issues.each do |issue|
        warn(issue.message, file: issue.file, line: issue.line)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-resharper_inspectcode-1.0.0 lib/resharper_inspectcode/plugin.rb