summaryrefslogtreecommitdiff
path: root/lib/tasks/flog.rake
blob: 4cb19c0c937d1735030567534527a86300a21395 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
desc 'Code complexity analyze via flog'
task :flog do
  output = %x(bundle exec flog -m app/ lib/gitlab)
  exit_code = 0
  output = output.lines

  # Skip total complexity score
  output.shift

  # Skip some trash info
  output.shift

  output.each do |line|
    score, method = line.split(" ")
    score = score.to_i

    if score > 40
      exit_code = 1
      puts "High complexity in #{method}. Score: #{score}"
    end
  end

  exit exit_code
end