Sha256: 47f6880ea19862b72ee58d245542b031d64000fa85001f851381ab9fd59c4122

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Quality
  module Tools
    # Adds 'rubocop' tool support to quality gem
    module Rubocop
      def self.included(base)
        base.extend ClassMethods
      end

      private

      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

      # See Rubocop.included
      module ClassMethods
        def 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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
quality-32.1.1 lib/quality/tools/rubocop.rb
quality-32.1.0 lib/quality/tools/rubocop.rb
quality-32.0.0 lib/quality/tools/rubocop.rb
quality-31.3.0 lib/quality/tools/rubocop.rb
quality-31.2.1 lib/quality/tools/rubocop.rb
quality-31.2.0 lib/quality/tools/rubocop.rb
quality-31.1.0 lib/quality/tools/rubocop.rb
quality-31.0.0 lib/quality/tools/rubocop.rb
quality-30.0.1 lib/quality/tools/rubocop.rb
quality-30.0.0 lib/quality/tools/rubocop.rb