Class: Threat::Plugins::Rubocop
- Inherits:
-
Danger::Plugin
- Object
- Danger::Plugin
- Threat::Plugins::Rubocop
- Defined in:
- lib/threat/plugins/rubocop.rb
Overview
This plugin runs Ribocop and warns about found violations
Usage:
Dangerfile
“‘ruby danger.import_dangerfile(gem: ’threat’)
rspec.run! “‘
Instance Method Summary collapse
Instance Method Details
#run! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/threat/plugins/rubocop.rb', line 16 def run! files_to_lint = git.modified_files + git.added_files result = `bundle exec rubocop --force-exclusion --format json #{files_to_lint.join(' ')}` return if $CHILD_STATUS.exitstatus.zero? json_result = JSON.parse(result) json_result['files'].each do |file| file_path = file['path'] file['offenses'].each do |offence| line = offence.dig('location', 'line') warn("Rubocop: #{offence['message']} at #{file_path}:#{line}") end end end |