Commit 58429d9b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add method complexity check to CI

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 463fc52f
......@@ -73,3 +73,10 @@ brakeman:
tags:
- ruby
- mysql
flog:
script:
- bundle exec rake flog
tags:
- ruby
- mysql
......@@ -259,6 +259,7 @@ group :development, :test do
gem 'rubocop', '~> 0.28.0', require: false
gem 'coveralls', '~> 0.8.2', require: false
gem 'simplecov', '~> 0.10.0', require: false
gem 'flog', require: false
gem 'benchmark-ips', require: false
end
......
......@@ -194,6 +194,9 @@ GEM
ffi (1.9.10)
fission (0.5.0)
CFPropertyList (~> 2.2)
flog (4.3.2)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.4)
flowdock (0.7.0)
httparty (~> 0.7)
multi_json
......@@ -821,6 +824,7 @@ DEPENDENCIES
enumerize (~> 0.7.0)
factory_girl_rails (~> 4.3.0)
ffaker (~> 2.0.0)
flog
fog (~> 1.25.0)
font-awesome-rails (~> 4.2)
foreman
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment