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-25.0.0 lib/quality/tools/flog.rb
quality-24.0.0 lib/quality/tools/flog.rb
quality-23.0.7 lib/quality/tools/flog.rb
quality-23.0.6 lib/quality/tools/flog.rb
quality-23.0.5 lib/quality/tools/flog.rb
quality-23.0.4 lib/quality/tools/flog.rb
quality-23.0.3 lib/quality/tools/flog.rb
quality-23.0.2 lib/quality/tools/flog.rb
quality-23.0.1 lib/quality/tools/flog.rb
quality-23.0.0 lib/quality/tools/flog.rb