-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
54 lines (46 loc) · 1.19 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'flay'
require 'flay_task'
require 'flog'
require 'reek/rake/task'
require 'rubocop/rake_task'
ruby_source = FileList['lib/**/*.rb']
RSpec::Core::RakeTask.new(:spec)
task default: :spec
task quality: :rubocop
Reek::Rake::Task.new do |t|
t.fail_on_error = false
t.verbose = false
t.ruby_opts = ['-rubygems']
t.reek_opts = '--quiet'
t.source_files = ruby_source
end
FlayTask.new do |t|
t.dirs = ruby_source.map do |each|
each[/[^\/]+/]
end.uniq
t.threshold = 0
t.verbose = true
end
desc 'Analyze for code complexity'
task :flog do
flog = Flog.new(continue: true)
flog.flog(*ruby_source)
threshold = 28
bad_methods = flog.totals.select do |name, score|
!(/##{flog.no_method}$/ =~ name) && score > threshold
end
bad_methods.sort { |a, b| a[1] <=> b[1] }.reverse.each do |name, score|
printf "%8.1f: %s\n", score, name
end
unless bad_methods.empty?
$stderr.puts "#{bad_methods.size} methods have a complexity > #{threshold}"
end
end
RuboCop::RakeTask.new do |task|
task.patterns = %w(lib/**/*.rb
spec/**/*.rb
Rakefile
Gemfile)
end