-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
executable file
·42 lines (36 loc) · 1013 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'rspec/core/rake_task'
require "rake/tasklib"
require "flog"
require 'ci/reporter/rake/rspec'
require 'yard'
require 'yard/rake/yardoc_task'
RSpec::Core::RakeTask.new(:spec => ["ci:setup:rspec"]) do |t|
t.pattern = 'spec/**/*_spec.rb'
end
task :default => :spec
desc "Analyze for code complexity"
task :flog do
flog = Flog.new
flog.flog [ "lib" ]
threshold = 10
bad_methods = flog.totals.select do | name, score |
name != "main#none" && score > threshold
end
bad_methods.sort do | a, b |
a[ 1 ] <=> b[ 1 ]
end.reverse.each do | name, score |
puts "%8.1f: %s" % [ score, name ]
end
unless bad_methods.empty?
raise "#{ bad_methods.size } methods have a flog complexity > #{ threshold }"
end
end
YARD::Rake::YardocTask.new(:yard) do |y|
y.options = ["lib/**/*.rb", "examples/**/*.rb", "--output-dir", "yardoc"]
end
namespace :yardoc do
desc "generates yardoc files to yardoc/"
task :generate => :yard do
puts "Yardoc files generated at yardoc/"
end
end