Sha256: 2c62913941c2a2caf3d4db3c3f8029fbf2ecce41dd6392ad9d4c974b7cc4c5fb

Contents?: true

Size: 822 Bytes

Versions: 23

Compression:

Stored size: 822 Bytes

Contents

module Quality
  module Tools
    # Adds 'flog' tool support to quality gem
    module Flog
      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

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

23 entries across 23 versions & 1 rubygems

Version Path
quality-20.1.0 lib/quality/tools/flog.rb
quality-20.0.3 lib/quality/tools/flog.rb
quality-20.0.2 lib/quality/tools/flog.rb
quality-20.0.1 lib/quality/tools/flog.rb
quality-20.0.0 lib/quality/tools/flog.rb
quality-19.2.1 lib/quality/tools/flog.rb
quality-19.2.0 lib/quality/tools/flog.rb
quality-19.1.3 lib/quality/tools/flog.rb
quality-19.1.2 lib/quality/tools/flog.rb
quality-19.1.1 lib/quality/tools/flog.rb
quality-19.1.0 lib/quality/tools/flog.rb
quality-19.0.0 lib/quality/tools/flog.rb
quality-18.0.1 lib/quality/tools/flog.rb
quality-18.0.0 lib/quality/tools/flog.rb
quality-17.2.0 lib/quality/tools/flog.rb
quality-17.1.1 lib/quality/tools/flog.rb
quality-17.1.0 lib/quality/tools/flog.rb
quality-17.0.0 lib/quality/tools/flog.rb
quality-16.0.1 lib/quality/tools/flog.rb
quality-16.0.0 lib/quality/tools/flog.rb