Sha256: 909cb4a9efeb9404509cd99c94ca7538bc6da453862ea84321128982211fde7b

Contents?: true

Size: 853 Bytes

Versions: 30

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

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

      private

      def quality_flog
        args = "--all --continue --methods-only #{ruby_files.join(' ')}"
        ratchet_quality_cmd('flog', args: args, emacs_format: true) do |line|
          self.class.count_violations_in_flog_output(line)
        end
      end

      # See Flog.included
      module ClassMethods
        def count_violations_in_flog_output(line, threshold = 50)
          return 0 if line =~ /^ *([0-9.]*): flog total$/

          return 0 unless line =~ /^ *([0-9.]*): (.*) .*.rb:[0-9]*$/

          score = Regexp.last_match[1].to_i

          return 1 if score > threshold

          0
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
quality-32.1.1 lib/quality/tools/flog.rb
quality-32.1.0 lib/quality/tools/flog.rb
quality-32.0.0 lib/quality/tools/flog.rb
quality-31.3.0 lib/quality/tools/flog.rb
quality-31.2.1 lib/quality/tools/flog.rb
quality-31.2.0 lib/quality/tools/flog.rb
quality-31.1.0 lib/quality/tools/flog.rb
quality-31.0.0 lib/quality/tools/flog.rb
quality-30.0.1 lib/quality/tools/flog.rb
quality-30.0.0 lib/quality/tools/flog.rb
quality-29.0.0 lib/quality/tools/flog.rb
quality-28.0.0 lib/quality/tools/flog.rb
quality-27.4.0 lib/quality/tools/flog.rb
quality-27.3.1 lib/quality/tools/flog.rb
quality-27.3.0 lib/quality/tools/flog.rb
quality-27.2.0 lib/quality/tools/flog.rb
quality-27.1.1 lib/quality/tools/flog.rb
quality-27.1.0 lib/quality/tools/flog.rb
quality-27.0.0 lib/quality/tools/flog.rb
quality-26.0.0 lib/quality/tools/flog.rb