Sha256: 8aec4eeae726c414b14bd8aca964b03350168c31c9124980bc4432290d7078e3

Contents?: true

Size: 939 Bytes

Versions: 6

Compression:

Stored size: 939 Bytes

Contents

module Quality
  module Tools
    # Adds 'rubocop' tool support to quality gem
    module Rubocop
      private

      def rubocop_args
        "--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.included(base)
        base.extend ClassMethods
      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

6 entries across 6 versions & 1 rubygems

Version Path
quality-20.1.0 lib/quality/tools/rubocop.rb
quality-20.0.3 lib/quality/tools/rubocop.rb
quality-20.0.2 lib/quality/tools/rubocop.rb
quality-20.0.1 lib/quality/tools/rubocop.rb
quality-20.0.0 lib/quality/tools/rubocop.rb
quality-19.2.1 lib/quality/tools/rubocop.rb