p8-metric_fu 0.9.0 → 0.9.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +4 -1
- data/Rakefile +19 -2
- data/TODO +2 -1
- data/lib/metric_fu/base.rb +29 -6
- data/lib/metric_fu/reek.rb +8 -0
- data/lib/metric_fu/roodi.rb +1 -1
- data/lib/metric_fu.rb +17 -3
- data/spec/churn_spec.rb +114 -114
- data/spec/config_spec.rb +103 -103
- data/spec/flay_spec.rb +16 -16
- data/spec/flog_spec.rb +204 -205
- data/spec/reek_spec.rb +23 -23
- data/spec/spec_helper.rb +24 -7
- metadata +2 -2
- data/lib/metric_fu/churn.rb +0 -88
- data/lib/metric_fu/flay.rb +0 -17
- data/lib/metric_fu/flog.rb +0 -129
- data/lib/metric_fu/md5_tracker.rb +0 -52
- data/lib/metric_fu/saikuro/saikuro.rb +0 -1214
- data/lib/tasks/churn.rake +0 -9
- data/lib/tasks/coverage.rake +0 -54
- data/lib/tasks/flay.rake +0 -6
- data/lib/tasks/flog.rake +0 -69
- data/lib/tasks/metric_fu.rake +0 -24
- data/lib/tasks/metric_fu.rb +0 -6
- data/lib/tasks/railroad.rake +0 -39
- data/lib/tasks/reek.rake +0 -6
- data/lib/tasks/roodi.rake +0 -7
- data/lib/tasks/saikuro.rake +0 -35
- data/lib/tasks/stats.rake +0 -14
- data/lib/templates/churn.html.erb +0 -22
- data/lib/templates/default.css +0 -45
- data/lib/templates/flay.html.erb +0 -30
- data/lib/templates/flog.html.erb +0 -38
- data/lib/templates/flog_page.html.erb +0 -25
- data/lib/templates/reek.html.erb +0 -30
- data/lib/templates/roodi.html.erb +0 -26
- data/spec/base_spec.rb +0 -57
data/README
CHANGED
@@ -64,6 +64,9 @@ MetricFu::Configuration.run do |config|
|
|
64
64
|
config.flog = { :dirs_to_flog => ['cms/app', 'cms/lib'] }
|
65
65
|
config.flay = { :dirs_to_flay => ['cms/app', 'cms/lib'] }
|
66
66
|
config.saikuro = { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
|
67
|
+
# open_in_browser only work on OSX
|
68
|
+
# urlprefix is used to prepend to file urls when MetricsFu is run by cruise control
|
69
|
+
config.general = { :open_in_browser => true, :url_prefix => 'http://cruisecontrol.server/projects/code/my_project' }
|
67
70
|
end
|
68
71
|
|
69
72
|
|
@@ -151,4 +154,4 @@ You can also change the minimum churn count like so:
|
|
151
154
|
|
152
155
|
****Thanks****
|
153
156
|
|
154
|
-
I'd like to thank the authors of Saikuro, Flog, Rcov, CruiseControl.rb, Flay, Reek, Roodi and Rails for creating such excellent open source products. Also Andre Arko, Petrik de Heus, Sean Soper, Erik St Martin, Andy Gregorowicz, Bastien, Michael Schubert, Kurtis Seebaldt, Toby Tripp, Paul Gross, and Chirdeep Shetty for their help and advice.
|
157
|
+
I'd like to thank the authors of Saikuro, Flog, Rcov, CruiseControl.rb, Flay, Reek, Roodi and Rails for creating such excellent open source products. Also Andre Arko, Petrik de Heus, Sean Soper, Erik St Martin, Andy Gregorowicz, Bastien, Michael Schubert, Kurtis Seebaldt, Jacob Kjeldahl, Toby Tripp, Paul Gross, and Chirdeep Shetty for their help and advice.
|
data/Rakefile
CHANGED
@@ -1,11 +1,28 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/rdoctask'
|
3
3
|
require 'spec/rake/spectask'
|
4
|
-
require
|
4
|
+
require 'lib/metric_fu'
|
5
5
|
|
6
6
|
desc "Run all specs in spec directory"
|
7
7
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
8
8
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
MetricFu::Configuration.run do |config|
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :metrics do
|
15
|
+
desc "Generate all reports"
|
16
|
+
task :all do
|
17
|
+
MetricFu.metrics.each {|metric| MetricFu.report.add(metric) }
|
18
|
+
MetricFu.report.save_output(MetricFu.report.to_yaml,
|
19
|
+
MetricFu.base_directory,
|
20
|
+
'report.yml')
|
21
|
+
MetricFu.report.save_templatized_report
|
22
|
+
if MetricFu.report.open_in_browser?
|
23
|
+
MetricFu.report.show_in_browser(MetricFu.output_directory)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
task :default => [:"metrics:all"]
|
data/TODO
CHANGED
@@ -10,4 +10,5 @@
|
|
10
10
|
* Generate metrics:* rake tasks for each of CodeMetric's descendants
|
11
11
|
* Update flog specs so that they actually run flog
|
12
12
|
* Add flay specs that run flay
|
13
|
-
* Convert readme to markdown and rename to README.mkdn so github will render it
|
13
|
+
* Convert readme to markdown and rename to README.mkdn so github will render it
|
14
|
+
* Saikuro.rb falls over if tries to parse an empty file. Fair enough. We shouldn't feed it empty files
|
data/lib/metric_fu/base.rb
CHANGED
@@ -68,11 +68,10 @@ module MetricFu
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def link_to_filename(name, line = nil)
|
71
|
-
|
72
|
-
|
73
|
-
%{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}:#{line}</a>}
|
71
|
+
if MetricFu.run_by_cruise_control?
|
72
|
+
cc_link_to_filename(name, line)
|
74
73
|
else
|
75
|
-
|
74
|
+
system_link_to_filename(name, line)
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
@@ -80,6 +79,25 @@ module MetricFu
|
|
80
79
|
return first_value if iteration % 2 == 0
|
81
80
|
return second_value
|
82
81
|
end
|
82
|
+
|
83
|
+
private
|
84
|
+
def cc_link_to_filename(name, line = nil)
|
85
|
+
if MetricFu.configuration.general[:url_prefix]
|
86
|
+
MetricFu.configuration.general[:url_prefix] += '/' unless MetricFu.configuration.general[:url_prefix] =~ /\/$/
|
87
|
+
%{<a href="#{MetricFu.configuration.general[:url_prefix]}#{name}?line=#{line}##{line}">#{name}</a>}
|
88
|
+
else
|
89
|
+
%{"#{name}"} # No link for cruise control without a prefix
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def system_link_to_filename(name, line = nil)
|
94
|
+
filename = File.expand_path(name)
|
95
|
+
if PLATFORM['darwin']
|
96
|
+
%{<a href="txmt://open/?url=file://#{filename}&line=#{line}">#{name}</a>}
|
97
|
+
else
|
98
|
+
%{<a href="file://#{filename}">#{name}</a>}
|
99
|
+
end
|
100
|
+
end
|
83
101
|
end
|
84
102
|
end
|
85
103
|
|
@@ -110,7 +128,7 @@ module MetricFu
|
|
110
128
|
end
|
111
129
|
|
112
130
|
def open_in_browser?
|
113
|
-
PLATFORM['darwin'] && !
|
131
|
+
configuration.general[:open_in_browser] && PLATFORM['darwin'] && !run_by_cruise_control?
|
114
132
|
end
|
115
133
|
|
116
134
|
def saikuro
|
@@ -125,10 +143,14 @@ module MetricFu
|
|
125
143
|
configuration.roodi
|
126
144
|
end
|
127
145
|
|
146
|
+
def run_by_cruise_control?
|
147
|
+
!!ENV['CC_BUILD_ARTIFACTS']
|
148
|
+
end
|
149
|
+
|
128
150
|
end
|
129
151
|
|
130
152
|
class Configuration
|
131
|
-
attr_accessor :churn, :coverage, :flay, :flog, :metrics, :reek, :roodi, :saikuro
|
153
|
+
attr_accessor :churn, :coverage, :flay, :flog, :metrics, :reek, :roodi, :saikuro, :general
|
132
154
|
def initialize
|
133
155
|
raise "Use config.churn instead of MetricFu::CHURN_OPTIONS" if defined? ::MetricFu::CHURN_OPTIONS
|
134
156
|
raise "Use config.flog[:dirs_to_flog] instead of MetricFu::DIRECTORIES_TO_FLOG" if defined? ::MetricFu::DIRECTORIES_TO_FLOG
|
@@ -141,6 +163,7 @@ module MetricFu
|
|
141
163
|
end
|
142
164
|
|
143
165
|
def reset
|
166
|
+
@general = { :open_in_browser => true }
|
144
167
|
@churn = {}
|
145
168
|
@coverage = { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb'],
|
146
169
|
:rcov_opts => ["--sort coverage", "--html", "--rails", "--exclude /gems/,/Library/,spec"] }
|
data/lib/metric_fu/reek.rb
CHANGED
@@ -11,7 +11,15 @@ module MetricFu
|
|
11
11
|
files_to_reek = MetricFu.reek[:dirs_to_reek].map{|dir| Dir[File.join(dir, "**/*.rb")] }
|
12
12
|
output = `reek #{files_to_reek.join(" ")}`
|
13
13
|
@matches = output.chomp.split("\n\n").map{|m| m.split("\n") }
|
14
|
+
@filenames = extract_filenames(@matches.map {|m| m.first})
|
14
15
|
end
|
15
16
|
|
17
|
+
private
|
18
|
+
def extract_filenames(names)
|
19
|
+
names.map do |name|
|
20
|
+
m = name.match(/^"(.*)"/)
|
21
|
+
m.size == 2 ? m[1] : nil
|
22
|
+
end
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
data/lib/metric_fu/roodi.rb
CHANGED
data/lib/metric_fu.rb
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# Load a few things to make our lives easier elsewhere.
|
2
|
+
module MetricFu
|
3
|
+
LIB_ROOT = File.dirname(__FILE__)
|
4
|
+
end
|
5
|
+
base_dir = File.join(MetricFu::LIB_ROOT, 'base')
|
6
|
+
generator_dir = File.join(MetricFu::LIB_ROOT, 'generators')
|
7
|
+
template_dir = File.join(MetricFu::LIB_ROOT, 'templates')
|
8
|
+
|
9
|
+
# We need to require these two things first because our other classes
|
10
|
+
# depend on them.
|
11
|
+
require File.join(base_dir, 'report')
|
12
|
+
require File.join(base_dir, 'generator')
|
13
|
+
|
14
|
+
# Now load everything else that's in the directory
|
15
|
+
Dir[File.join(base_dir, '*.rb')].each{|l| require l }
|
16
|
+
Dir[File.join(generator_dir, '*.rb')].each {|l| require l }
|
17
|
+
Dir[File.join(template_dir, 'standard/*.rb')].each {|l| require l}
|
data/spec/churn_spec.rb
CHANGED
@@ -1,117 +1,117 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
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
|
-
|
3
|
+
describe Churn do
|
4
|
+
# describe "generate_report" do
|
5
|
+
# after do
|
6
|
+
# load File.dirname(__FILE__) + '/../lib/metric_fu/churn.rb' #need to reload file to wipe out mock of private static
|
7
|
+
# end
|
8
|
+
#
|
9
|
+
# it "should strip out files that have less than the min count" do
|
10
|
+
# logs = ["accept", "accept", "accept", "reject", "reject"]
|
11
|
+
# git_mock = mock('git')
|
12
|
+
# git_mock.should_receive(:get_logs).and_return(logs)
|
13
|
+
# Churn::Git.should_receive(:new).and_return(git_mock)
|
14
|
+
# churn = Churn.new(:scm => :git, :minimum_churn_count => 3)
|
15
|
+
# churn.analyze
|
16
|
+
# churn.instance_variable_get(:@changes).should == {"accept"=>3}
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# it "should have a default min count of 5" do
|
20
|
+
# churn = Churn.new('base_dir')
|
21
|
+
# churn.instance_variable_get(:@minimum_churn_count).should == 5
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# describe "template_name" do
|
27
|
+
# it "should return the class name in lowercase" do
|
28
|
+
# churn = Churn.new
|
29
|
+
# churn.template_name.should == 'churn'
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# describe "parse_log_for_changes" do
|
34
|
+
# it "should count the changes with git" do
|
35
|
+
# logs = ["home_page/index.html", "README", "History.txt", "README", "History.txt", "README"]
|
36
|
+
# git_mock = mock('git')
|
37
|
+
# git_mock.should_receive(:get_logs).and_return(logs)
|
38
|
+
# Churn::Git.should_receive(:new).and_return(git_mock)
|
39
|
+
# File.should_receive(:exist?).with(".git").and_return(true)
|
40
|
+
# changes = Churn.new.send(:parse_log_for_changes)
|
41
|
+
# changes["home_page/index.html"].should == 1
|
42
|
+
# changes["History.txt"].should == 2
|
43
|
+
# changes["README"].should == 3
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# it "should count the changes with svn" do
|
47
|
+
# logs = ["home_page/index.html", "README", "History.txt", "README", "History.txt", "README"]
|
48
|
+
# svn_mock = mock('svn')
|
49
|
+
# svn_mock.should_receive(:get_logs).and_return(logs)
|
50
|
+
# Churn::Svn.should_receive(:new).and_return(svn_mock)
|
51
|
+
# File.should_receive(:exist?).with(".git").and_return(false)
|
52
|
+
# File.should_receive(:exist?).with(".svn").and_return(true)
|
53
|
+
# changes = Churn.new.send(:parse_log_for_changes)
|
54
|
+
# changes["home_page/index.html"].should == 1
|
55
|
+
# changes["History.txt"].should == 2
|
56
|
+
# changes["README"].should == 3
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
#
|
61
|
+
# describe MetricFu::Churn::Svn do
|
62
|
+
#
|
63
|
+
# describe "get_logs" do
|
64
|
+
# it "should use the start date if supplied" do
|
65
|
+
# @churn = Churn::Svn.new
|
66
|
+
# @churn.should_receive(:`).with('svn log --verbose').and_return("")
|
67
|
+
# @churn.get_logs
|
68
|
+
# end
|
69
|
+
# it "should use the start date if supplied" do
|
70
|
+
# Time.should_receive(:now).and_return(Date.new(2001, 1, 2))
|
71
|
+
# @churn = Churn::Svn.new(lambda{Date.new(2000, 1, 1)})
|
72
|
+
# @churn.should_receive(:require_rails_env)
|
73
|
+
# @churn.should_receive(:`).with("svn log --revision {2000-01-01}:{2001-01-02} --verbose").and_return("")
|
74
|
+
# @churn.get_logs
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# describe "clean_up_svn_line" do
|
79
|
+
# it "should return nil for non matches" do
|
80
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "Adding Google analytics").should be_nil
|
81
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "A bunch of new files").should be_nil
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
# it "should strip out all but the full path" do
|
85
|
+
# Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
86
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
87
|
+
# Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
88
|
+
# Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
89
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
90
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
91
|
+
#
|
92
|
+
# Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
93
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
94
|
+
# Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
95
|
+
# Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
96
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
97
|
+
# Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
# end
|
101
|
+
#
|
102
|
+
# describe MetricFu::Churn::Git do
|
103
|
+
#
|
104
|
+
# describe "get_logs" do
|
105
|
+
# it "should use the start date if supplied" do
|
106
|
+
# @churn = Churn::Git.new
|
107
|
+
# @churn.should_receive(:`).with('git log --name-only --pretty=format:').and_return("")
|
108
|
+
# @churn.get_logs
|
109
|
+
# end
|
110
|
+
# it "should use the start date if supplied" do
|
111
|
+
# @churn = Churn::Git.new(lambda{Date.new(2000, 1, 1)})
|
112
|
+
# @churn.should_receive(:require_rails_env)
|
113
|
+
# @churn.should_receive(:`).with("git log --after=2000-01-01 --name-only --pretty=format:").and_return("")
|
114
|
+
# @churn.get_logs
|
115
|
+
# end
|
116
|
+
# end
|
59
117
|
end
|
60
|
-
|
61
|
-
describe MetricFu::Churn::Svn do
|
62
|
-
|
63
|
-
describe "get_logs" do
|
64
|
-
it "should use the start date if supplied" do
|
65
|
-
@churn = Churn::Svn.new
|
66
|
-
@churn.should_receive(:`).with('svn log --verbose').and_return("")
|
67
|
-
@churn.get_logs
|
68
|
-
end
|
69
|
-
it "should use the start date if supplied" do
|
70
|
-
Time.should_receive(:now).and_return(Date.new(2001, 1, 2))
|
71
|
-
@churn = Churn::Svn.new(lambda{Date.new(2000, 1, 1)})
|
72
|
-
@churn.should_receive(:require_rails_env)
|
73
|
-
@churn.should_receive(:`).with("svn log --revision {2000-01-01}:{2001-01-02} --verbose").and_return("")
|
74
|
-
@churn.get_logs
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "clean_up_svn_line" do
|
79
|
-
it "should return nil for non matches" do
|
80
|
-
Churn::Svn.new.send(:clean_up_svn_line, "Adding Google analytics").should be_nil
|
81
|
-
Churn::Svn.new.send(:clean_up_svn_line, "A bunch of new files").should be_nil
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should strip out all but the full path" do
|
85
|
-
Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
86
|
-
Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
87
|
-
Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
88
|
-
Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
89
|
-
Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
90
|
-
Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
91
|
-
|
92
|
-
Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
93
|
-
Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
94
|
-
Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
95
|
-
Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
96
|
-
Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
97
|
-
Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe MetricFu::Churn::Git do
|
103
|
-
|
104
|
-
describe "get_logs" do
|
105
|
-
it "should use the start date if supplied" do
|
106
|
-
@churn = Churn::Git.new
|
107
|
-
@churn.should_receive(:`).with('git log --name-only --pretty=format:').and_return("")
|
108
|
-
@churn.get_logs
|
109
|
-
end
|
110
|
-
it "should use the start date if supplied" do
|
111
|
-
@churn = Churn::Git.new(lambda{Date.new(2000, 1, 1)})
|
112
|
-
@churn.should_receive(:require_rails_env)
|
113
|
-
@churn.should_receive(:`).with("git log --after=2000-01-01 --name-only --pretty=format:").and_return("")
|
114
|
-
@churn.get_logs
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
data/spec/config_spec.rb
CHANGED
@@ -1,110 +1,110 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
3
|
describe MetricFu::Configuration do
|
4
|
-
before do
|
5
|
-
|
6
|
-
end
|
7
|
-
after do
|
8
|
-
|
9
|
-
end
|
10
|
-
describe "open_in_browser" do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
4
|
+
# before do
|
5
|
+
# MetricFu.configuration.reset
|
6
|
+
# end
|
7
|
+
# after do
|
8
|
+
# ENV['CC_BUILD_ARTIFACTS'] = nil
|
9
|
+
# end
|
10
|
+
# describe "open_in_browser" do
|
11
|
+
# it "should return false if running in cruise" do
|
12
|
+
# unless ENV['CC_BUILD_ARTIFACTS']
|
13
|
+
# MetricFu.open_in_browser?.should == !!PLATFORM['darwin']
|
14
|
+
# ENV['CC_BUILD_ARTIFACTS'] = ''
|
15
|
+
# MetricFu.open_in_browser?.should == false
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# end
|
19
19
|
|
20
|
-
describe "metrics" do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "churn" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "coverage" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
20
|
+
# describe "metrics" do
|
21
|
+
# it "should be configurable" do
|
22
|
+
# MetricFu.metrics.should == [:coverage, :churn, :flog, :flay, :reek, :roodi, :saikuro]
|
23
|
+
# MetricFu::Configuration.run do |config|
|
24
|
+
# config.metrics = [:coverage, :flog]
|
25
|
+
# end
|
26
|
+
# MetricFu.metrics.should == [:coverage, :flog]
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# describe "churn" do
|
31
|
+
# it "should be configurable" do
|
32
|
+
# now = Time.now
|
33
|
+
# MetricFu.churn.should == {}
|
34
|
+
# MetricFu::Configuration.run do |config|
|
35
|
+
# config.churn[:start_date] = now
|
36
|
+
# end
|
37
|
+
# MetricFu.churn.should == {:start_date => now }
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# describe "coverage" do
|
42
|
+
# it "should be configurable" do
|
43
|
+
# MetricFu.coverage[:test_files].should == ['test/**/*_test.rb', 'spec/**/*_spec.rb']
|
44
|
+
# MetricFu::Configuration.run do |config|
|
45
|
+
# config.coverage[:test_files] = ['test/**/test_*.rb']
|
46
|
+
# end
|
47
|
+
# MetricFu.coverage[:test_files].should == ['test/**/test_*.rb']
|
48
|
+
# end
|
49
|
+
# end
|
50
50
|
|
51
|
-
describe "flay" do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
51
|
+
# describe "flay" do
|
52
|
+
# it "should be configurable" do
|
53
|
+
# now = Time.now
|
54
|
+
# MetricFu.flay.should == { :dirs_to_flay => ['lib'] }
|
55
|
+
# MetricFu::Configuration.run do |config|
|
56
|
+
# config.flay[:dirs_to_flay] = ['cms/app', 'cms/lib']
|
57
|
+
# end
|
58
|
+
# MetricFu.flay.should == { :dirs_to_flay => ['cms/app', 'cms/lib'] }
|
59
|
+
# end
|
60
|
+
# end
|
61
61
|
|
62
|
-
describe "flog" do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
62
|
+
# describe "flog" do
|
63
|
+
# it "should be configurable" do
|
64
|
+
# MetricFu.flog.should == { :dirs_to_flog => ['lib'] }
|
65
|
+
# MetricFu::Configuration.run do |config|
|
66
|
+
# config.flog[:dirs_to_flog] = ['cms/app', 'cms/lib']
|
67
|
+
# end
|
68
|
+
# MetricFu.flog.should == { :dirs_to_flog => ['cms/app', 'cms/lib'] }
|
69
|
+
# end
|
70
|
+
# end
|
71
71
|
|
72
|
-
describe "saikuro" do
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "reek" do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
describe "roodi" do
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
110
|
-
end
|
72
|
+
# describe "saikuro" do
|
73
|
+
# it "should be configurable" do
|
74
|
+
# MetricFu.saikuro.should == {}
|
75
|
+
# MetricFu::Configuration.run do |config|
|
76
|
+
# config.saikuro = { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
|
77
|
+
# end
|
78
|
+
# MetricFu.saikuro.should == { "--warn_cyclo" => "3", "--error_cyclo" => "4" }
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# it "should only accept a Hash" do
|
82
|
+
# MetricFu.saikuro.should == {}
|
83
|
+
# lambda {
|
84
|
+
# MetricFu::Configuration.run do |config|
|
85
|
+
# config.saikuro = ''
|
86
|
+
# end
|
87
|
+
# }.should raise_error
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# describe "reek" do
|
92
|
+
# it "should be configurable" do
|
93
|
+
# MetricFu.reek.should == { :dirs_to_reek => ['lib'] }
|
94
|
+
# MetricFu::Configuration.run do |config|
|
95
|
+
# config.reek[:dirs_to_reek] = ['cms/app', 'cms/lib']
|
96
|
+
# end
|
97
|
+
# MetricFu.reek.should == { :dirs_to_reek => ['cms/app', 'cms/lib'] }
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
#
|
101
|
+
# describe "roodi" do
|
102
|
+
# it "should be configurable" do
|
103
|
+
# MetricFu.roodi.should == { :dirs_to_roodi => ['lib'] }
|
104
|
+
# MetricFu::Configuration.run do |config|
|
105
|
+
# config.roodi[:dirs_to_roodi] = ['cms/app', 'cms/lib']
|
106
|
+
# end
|
107
|
+
# MetricFu.roodi.should == { :dirs_to_roodi => ['cms/app', 'cms/lib'] }
|
108
|
+
# end
|
109
|
+
# end
|
110
|
+
end
|