class Danger::DangerRubocopJunitParser
This is your plugin class. Any attributes or methods you expose here will be available from within your Dangerfile.
To be published on the Danger
plugins site, you will need to have the public interface documented. Danger
uses [YARD](yardoc.org/) for generating documentation from your plugin source, and you can verify by running `danger plugins lint` or `bundle exec rake spec`.
You should replace these comments with a public description of your library.
@example Process the rubocop results sending inline comments to the Githup PR
rubocop_junit_parser.results_path = 'path/to/results' rubocop_junit_parser.process
@see Marc Fernandez/danger-rubocop_junit_parser @tags rubocop, inline, javascript
Attributes
Path to your json formatted rubocop results
@return [String]
Public Instance Methods
Process the rubocop results from the path specified and sends inline comments to the Github PR
@return [void]
# File lib/rubocop_junit_parser/plugin.rb, line 32 def process return if results_path.nil? failures.each { |result| send_comment(result) } end
Private Instance Methods
# File lib/rubocop_junit_parser/plugin.rb, line 45 def failures ::Nokogiri.XML(open(results_path).read).xpath('//failure') .map { |failure| RubocopJunitFailure.new(failure: failure) } .select { |failure| modified_files.include?(failure.file_path) } end
# File lib/rubocop_junit_parser/plugin.rb, line 39 def modified_files @modified_files ||= ( git.modified_files - git.deleted_files ) + git.added_files end
# File lib/rubocop_junit_parser/plugin.rb, line 51 def send_comment(failure) fail(failure.message, file: failure.file_path, line: failure.line) end