Sha256: 98687e1611fbf0d711cbb74e186b0d838c89788d9bf61d8ae28f8808c5e74784

Contents?: true

Size: 970 Bytes

Versions: 20

Compression:

Stored size: 970 Bytes

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
        "--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

20 entries across 20 versions & 1 rubygems

Version Path
quality-29.0.0 lib/quality/tools/rubocop.rb
quality-28.0.0 lib/quality/tools/rubocop.rb
quality-27.4.0 lib/quality/tools/rubocop.rb
quality-27.3.1 lib/quality/tools/rubocop.rb
quality-27.3.0 lib/quality/tools/rubocop.rb
quality-27.2.0 lib/quality/tools/rubocop.rb
quality-27.1.1 lib/quality/tools/rubocop.rb
quality-27.1.0 lib/quality/tools/rubocop.rb
quality-27.0.0 lib/quality/tools/rubocop.rb
quality-26.0.0 lib/quality/tools/rubocop.rb
quality-25.0.0 lib/quality/tools/rubocop.rb
quality-24.0.0 lib/quality/tools/rubocop.rb
quality-23.0.7 lib/quality/tools/rubocop.rb
quality-23.0.6 lib/quality/tools/rubocop.rb
quality-23.0.5 lib/quality/tools/rubocop.rb
quality-23.0.4 lib/quality/tools/rubocop.rb
quality-23.0.3 lib/quality/tools/rubocop.rb
quality-23.0.2 lib/quality/tools/rubocop.rb
quality-23.0.1 lib/quality/tools/rubocop.rb
quality-23.0.0 lib/quality/tools/rubocop.rb