Sha256: 2747689bdcc5e52fc01e0400c2966224a222237438c4daf70e726953fbdd0105

Contents?: true

Size: 959 Bytes

Versions: 9

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

module Quality
  module Tools
    # Adds 'rubocop' tool support to quality gem
    class Rubocop < Tool
      def rubocop_args
        [
          '--force-exclusion',
          '--require rubocop-minitest',
          '--require rubocop-rake',
          '--require rubocop-rspec',
          '--format emacs',
          *ruby_files,
        ].join(' ')
      end

      def quality_rubocop
        ratchet_quality_cmd('rubocop',
                            gives_error_code_on_violations: true,
                            args: rubocop_args) do |line|
          self.class.count_rubocop_violations(line)
        end
      end

      def self.count_rubocop_violations(line)
        if line =~ /^.* file[s|] inspected, (.*) offence[s|] detected$/
          0
        elsif line =~ /^warning: .*/
          # don't count internal rubocop errors/warnings
          0
        else
          1
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
quality-40.0.1 lib/quality/tools/rubocop.rb
quality-40.0.0 lib/quality/tools/rubocop.rb
quality-39.0.1 lib/quality/tools/rubocop.rb
quality-38.0.1 lib/quality/tools/rubocop.rb
quality-38.0.0 lib/quality/tools/rubocop.rb
quality-37.1.1 lib/quality/tools/rubocop.rb
quality-37.1.0 lib/quality/tools/rubocop.rb
quality-37.0.1 lib/quality/tools/rubocop.rb
quality-37.0.0 lib/quality/tools/rubocop.rb