summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-11 15:29:19 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-11 15:29:19 +0000
commit7bca4cabc220c03a2bfb19a873421a764a3011d6 (patch)
treeb9ce4cc975b825b633968119d8843295aa2c1db6
parentdfd8ae8a8457e08f3e2da7732c59dbf70e541460 (diff)
parent6748dd2fd0b2cf694661e910c6c1bb6ac2be69a1 (diff)
downloadgitlab-ce-7bca4cabc220c03a2bfb19a873421a764a3011d6.tar.gz
Merge branch 'flog' into 'master'
Add method complexity check to CI Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> See merge request !1783
-rw-r--r--.gitlab-ci.yml8
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock4
-rw-r--r--lib/tasks/flog.rake25
4 files changed, 38 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cf6d28b01af..062fda322a6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -73,3 +73,11 @@ brakeman:
tags:
- ruby
- mysql
+
+flog:
+ script:
+ - bundle exec rake flog
+ tags:
+ - ruby
+ - mysql
+ allow_failure: true
diff --git a/Gemfile b/Gemfile
index 6ee0e4ae286..5e2db97892c 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 49dc9ff119c..6b352fa8b38 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..3bfe999ae74
--- /dev/null
+++ b/lib/tasks/flog.rake
@@ -0,0 +1,25 @@
+desc 'Code complexity analyze via flog'
+task :flog do
+ output = %x(bundle exec flog -m app/ lib/gitlab)
+ exit_code = 0
+ minimum_score = 70
+ 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 > minimum_score
+ exit_code = 1
+ puts "High complexity in #{method}. Score: #{score}"
+ end
+ end
+
+ exit exit_code
+end