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' FAILURE_THRESHOLD = 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 number_of_issues(line) return 0 if total?(line) super end def failed?(line) number_of_issues(line) != 0 end def printable?(line) super && failed?(line) end def total?(line) TOTAL_REGEXP.match(line) end end end