Sha256: a0e9347c6919aee134c571b5fe3db007a2cad702997f98da2a778181ac229b3f
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
# encoding: UTF-8 require 'json' require 'rubocop' require 'face_control/comment' module FaceControl module Checkers class RuboCop attr_writer :options def relevant_globs %w( *.gemspec *.rb *.rake Capfile Gemfile Rakefile Vagrantfile ) end def command(filenames) "rubocop --format json #{filenames}" end def parse(command_output) JSON.parse(command_output)['files'].map do |file| file['offenses'].reject do |offense| ignored_severities.include?(offense['severity']) end.map do |offense| Comment.new( file: file['path'], line: offense['location']['line'], text: text(offense, file) ) end end end private def ignored_severities @options.fetch(:ignored_severities, []) end def text(offense, file) text = offense['message'] if (link = style_guide_url(offense)) text << " — [Guide](#{link})" end text << " — #{offense['cop_name']}" end def style_guide_url(offense) cop_name = offense['cop_name'] config = ::RuboCop::ConfigLoader.default_configuration ::RuboCop::Cop::MessageAnnotator.new(config, cop_name, config.for_cop(cop_name), {}).urls.first end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
face_control-0.9.1 | lib/face_control/checkers/rubocop.rb |
face_control-0.8.6 | lib/face_control/checkers/rubocop.rb |