Sha256: 9eaaa8623dc5b6f97893cd55a1a98326ce14cd445ebe4e534c62fde4789705c9

Contents?: true

Size: 740 Bytes

Versions: 7

Compression:

Stored size: 740 Bytes

Contents

module Warder
  # responsible for run code complexity validation
  class CodeComplexityRunner < Runner
    CLI_OPTION = 'c'
    CLI_FULL_OPTION = 'code-complexity'
    DESCRIPTION = 'Run code complexity validation'
    COMMAND_NAME = 'flog'
    FLOG_SCORE = SCORE
    FAILURE_REGEXP = /^\s+(\d+.\d+)\:\s.*$/
    TOTAL_REGEXP = /^\s+\d+.\d+\:.*(total|average)$/

    private

    def command_with_options
      "#{COMMAND_NAME} -a -c -g -m #{@options.files}"
    end

    def failed?(line)
      match = FAILURE_REGEXP.match(line)
      return false if total?(line)
      match && match[1].to_f > FLOG_SCORE
    end

    def printable?(line)
      failed?(line)
    end

    def total?(line)
      TOTAL_REGEXP.match(line)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
warder-0.1.9 lib/warder/code_complexity_runner.rb
warder-0.1.8 lib/warder/code_complexity_runner.rb
warder-0.1.7 lib/warder/code_complexity_runner.rb
warder-0.1.6 lib/warder/code_complexity_runner.rb
warder-0.1.5 lib/warder/code_complexity_runner.rb
warder-0.1.4 lib/warder/code_complexity_runner.rb
warder-0.1.3 lib/warder/code_complexity_runner.rb