Sha256: ab82b4bfb43b35e2880d8f5de433da6947c22587aac716011e706b31c7466208

Contents?: true

Size: 699 Bytes

Versions: 20

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
quality-40.0.1 lib/quality/tools/flog.rb
quality-40.0.0 lib/quality/tools/flog.rb
quality-39.0.1 lib/quality/tools/flog.rb
quality-38.0.1 lib/quality/tools/flog.rb
quality-38.0.0 lib/quality/tools/flog.rb
quality-37.1.1 lib/quality/tools/flog.rb
quality-37.1.0 lib/quality/tools/flog.rb
quality-37.0.1 lib/quality/tools/flog.rb
quality-37.0.0 lib/quality/tools/flog.rb
quality-36.1.0 lib/quality/tools/flog.rb
quality-36.0.0 lib/quality/tools/flog.rb
quality-35.2.1 lib/quality/tools/flog.rb
quality-35.2.0 lib/quality/tools/flog.rb
quality-35.1.1 lib/quality/tools/flog.rb
quality-35.0.1 lib/quality/tools/flog.rb
quality-35.0.0 lib/quality/tools/flog.rb
quality-34.0.2 lib/quality/tools/flog.rb
quality-34.0.1 lib/quality/tools/flog.rb
quality-34.0.0 lib/quality/tools/flog.rb
quality-33.0.0 lib/quality/tools/flog.rb