summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-10 18:34:05 +0100
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-10 18:34:05 +0100
commit58429d9b26b2f2b62fecab012fce0ebe36571129 (patch)
tree9e61e29f5b4fc4e92020b0d3755036858ba8710e
parent463fc52fa80c7f0c9fc715a58f1e7096e0bfb345 (diff)
downloadgitlab-ce-flog.tar.gz
Add method complexity check to CIflog
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--.gitlab-ci.yml7
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock4
-rw-r--r--lib/tasks/flog.rake24
4 files changed, 36 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cf6d28b01af..476dabe5e3d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -73,3 +73,10 @@ brakeman:
tags:
- ruby
- mysql
+
+flog:
+ script:
+ - bundle exec rake flog
+ tags:
+ - ruby
+ - mysql
diff --git a/Gemfile b/Gemfile
index c73aa26bd0a..91a93215336 100644
--- a/Gemfile
+++ b/Gemfile
@@ -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
diff --git a/Gemfile.lock b/Gemfile.lock
index dca8606806a..0fc22829cfd 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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
diff --git a/lib/tasks/flog.rake b/lib/tasks/flog.rake
new file mode 100644
index 00000000000..4cb19c0c937
--- /dev/null
+++ b/lib/tasks/flog.rake
@@ -0,0 +1,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