forked from trema/trema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
106 lines (84 loc) · 2.55 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#
# Author: Yasuhito Takamiya <[email protected]>
#
# Copyright (C) 2008-2011 NEC Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
require "rubygems"
require "rspec/core/rake_task"
desc "Generate a monolithic rant file"
task "build.rb" do
sh "rant-import --force --auto .mono.rant"
end
desc "Run all examples with RCov"
RSpec::Core::RakeTask.new do | t |
t.pattern = [ "spec/**/*_spec.rb", "src/examples/**/*_spec.rb" ]
t.rspec_opts = "--color --format documentation --profile"
t.rcov = true
t.rcov_opts = %[--exclude "gems/*"]
end
begin
require "rake/tasklib"
require "flay"
require "flay_task"
require "flog"
require "reek/rake/task"
require "roodi"
require "roodi_task"
desc "Enforce Ruby code quality with static analysis of code"
task :quality => [ :reek, :roodi, :flog, :flay ]
#
# See the follwing URL for details:
# http://wiki.github.com/kevinrutherford/reek/rake-task
#
Reek::Rake::Task.new do | t |
t.fail_on_error = true
t.verbose = false
t.reek_opts = "--quiet"
t.source_files = "ruby/**/*.rb"
end
RoodiTask.new do | t |
t.patterns = %w(ruby/**/*.rb spec/**/*.rb features/**/*.rb)
end
desc "Analyze for code complexity"
task :flog do
flog = Flog.new( :continue => true )
flog.flog [ "ruby" ]
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.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
FlayTask.new do | t |
# add directories such as app, bin, spec and test if need be.
t.dirs = %w( ruby )
t.threshold = 0
end
rescue LoadError
$stderr.puts "WARNING: #{ $!.message } (ignored)"
end
### Local variables:
### mode: Ruby
### coding: utf-8-unix
### indent-tabs-mode: nil
### End: