Sha256: 6af4ab3390f1c7957a368ab34dbaf1c1a4bbc61e910fe250b683e633756126b2

Contents?: true

Size: 822 Bytes

Versions: 9

Compression:

Stored size: 822 Bytes

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
quality-22.0.0 lib/quality/tools/flog.rb
quality-21.0.6 lib/quality/tools/flog.rb
quality-21.0.5 lib/quality/tools/flog.rb
quality-21.0.4 lib/quality/tools/flog.rb
quality-21.0.3 lib/quality/tools/flog.rb
quality-21.0.2 lib/quality/tools/flog.rb
quality-21.0.1 lib/quality/tools/flog.rb
quality-20.1.1 lib/quality/tools/flog.rb
quality-21.0.0 lib/quality/tools/flog.rb