Sha256: 6bc93257662fa18ddde3de194e7b4d5fe089b715788930fa7fa9ac36e5c79c79

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

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
    # @return [void]
    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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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