summaryrefslogtreecommitdiff
path: root/lib/tasks
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 /lib/tasks
parent463fc52fa80c7f0c9fc715a58f1e7096e0bfb345 (diff)
downloadgitlab-ce-58429d9b26b2f2b62fecab012fce0ebe36571129.tar.gz
Add method complexity check to CIflog
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/flog.rake24
1 files changed, 24 insertions, 0 deletions
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