Sha256: 3961f700b6dbc8b5f1d9e325052360ea8a0c04fcbbfcca52b124e88420b25c22

Contents?: true

Size: 883 Bytes

Versions: 11

Compression:

Stored size: 883 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-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

11 entries across 11 versions & 1 rubygems

Version Path
quality-36.1.0 lib/quality/tools/rubocop.rb
quality-36.0.0 lib/quality/tools/rubocop.rb
quality-35.2.1 lib/quality/tools/rubocop.rb
quality-35.2.0 lib/quality/tools/rubocop.rb
quality-35.1.1 lib/quality/tools/rubocop.rb
quality-35.0.1 lib/quality/tools/rubocop.rb
quality-35.0.0 lib/quality/tools/rubocop.rb
quality-34.0.2 lib/quality/tools/rubocop.rb
quality-34.0.1 lib/quality/tools/rubocop.rb
quality-34.0.0 lib/quality/tools/rubocop.rb
quality-33.0.0 lib/quality/tools/rubocop.rb