# File lib/kwala/actions/cyclomatic_complexity.rb, line 128 def count_violations(file) if !File.exists?(file) return 0 end data = IO.readlines(file).join errors = 0 warnings = 0 if m = /(<table.*?>)(.*)(<\/table>)/mi.match(data) data = m[2] while m = /(<tr>.*?<\/tr>)(.*)/mi.match(data) if /^<tr><th>/ !~ m[1] # Make sure not to count the header row. if /class=\"error\"/ =~ m[1] errors += 1 elsif /class=\"warning\"/ =~ m[1] warnings += 1 end end data = m[2] end end { :total => errors + warnings, :errors => errors, :warnings => warnings } end