#!/usr/bin/env ruby MAX_SCORE = 45 flog_lines = `flog ./lib/`.split("\n") errors = [] flog_lines.each_with_index do |line, index| # Skip header next if index < 3 pattern = /^ *(.*): (.*) (.*):[0-9]*/ matches = line.match(pattern) next if matches.nil? score = matches[1].to_f next if score < MAX_SCORE errors << { score: score, method: matches[2], file: matches[3] } end exit 0 if errors.size == 0 puts 'Flog test failed:' errors.sort_by { |a| a[:score] }.each do |error| puts "#{error[:score]} / #{MAX_SCORE}: #{error[:method]} in #{error[:file]}" end exit 1