nielsm-metric_fu 0.9.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +38 -0
- data/README +1 -154
- data/Rakefile +9 -2
- data/TODO +3 -3
- data/lib/base/base_template.rb +146 -0
- data/lib/base/configuration.rb +207 -0
- data/lib/base/generator.rb +160 -0
- data/lib/base/graph.rb +37 -0
- data/lib/{metric_fu → base}/md5_tracker.rb +0 -0
- data/lib/base/report.rb +100 -0
- data/lib/{metric_fu → generators}/churn.rb +26 -23
- data/lib/generators/flay.rb +34 -0
- data/lib/generators/flog.rb +140 -0
- data/lib/generators/rcov.rb +87 -0
- data/lib/generators/reek.rb +37 -0
- data/lib/generators/roodi.rb +31 -0
- data/lib/generators/saikuro.rb +208 -0
- data/lib/generators/stats.rb +43 -0
- data/lib/graphs/flay_grapher.rb +34 -0
- data/lib/graphs/flog_grapher.rb +37 -0
- data/lib/graphs/rcov_grapher.rb +34 -0
- data/lib/graphs/reek_grapher.rb +44 -0
- data/lib/graphs/roodi_grapher.rb +34 -0
- data/lib/metric_fu.rb +24 -3
- data/lib/templates/awesome/awesome_template.rb +30 -0
- data/lib/templates/awesome/churn.html.erb +19 -0
- data/lib/templates/awesome/default.css +75 -0
- data/lib/templates/awesome/flay.html.erb +27 -0
- data/lib/templates/awesome/flog.html.erb +46 -0
- data/lib/templates/awesome/index.html.erb +28 -0
- data/lib/templates/awesome/layout.html.erb +27 -0
- data/lib/templates/awesome/rcov.html.erb +36 -0
- data/lib/templates/awesome/reek.html.erb +34 -0
- data/lib/templates/awesome/roodi.html.erb +21 -0
- data/lib/templates/awesome/saikuro.html.erb +71 -0
- data/lib/templates/awesome/stats.html.erb +41 -0
- data/lib/templates/{churn.html.erb → standard/churn.html.erb} +13 -4
- data/lib/templates/{default.css → standard/default.css} +20 -1
- data/lib/templates/{flay.html.erb → standard/flay.html.erb} +13 -9
- data/lib/templates/standard/flog.html.erb +53 -0
- data/lib/templates/standard/index.html.erb +38 -0
- data/lib/templates/standard/rcov.html.erb +43 -0
- data/lib/templates/standard/reek.html.erb +42 -0
- data/lib/templates/{roodi.html.erb → standard/roodi.html.erb} +11 -8
- data/lib/templates/standard/saikuro.html.erb +84 -0
- data/lib/templates/standard/standard_template.rb +26 -0
- data/lib/templates/standard/stats.html.erb +55 -0
- data/spec/base/base_template_spec.rb +161 -0
- data/spec/base/configuration_spec.rb +303 -0
- data/spec/base/generator_spec.rb +181 -0
- data/spec/{md5_tracker_spec.rb → base/md5_tracker_spec.rb} +1 -1
- data/spec/base/report_spec.rb +139 -0
- data/spec/generators/churn_spec.rb +152 -0
- data/spec/generators/flay_spec.rb +104 -0
- data/spec/generators/flog_spec.rb +219 -0
- data/spec/generators/reek_spec.rb +60 -0
- data/spec/generators/saikuro_spec.rb +58 -0
- data/spec/generators/stats_spec.rb +74 -0
- data/spec/graphs/flog_grapher_spec.rb +15 -0
- data/spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html +10 -0
- data/spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html +16 -0
- data/spec/resources/saikuro/index_cyclo.html +155 -0
- data/spec/resources/saikuro_sfiles/thing.rb_cyclo.html +10 -0
- data/spec/spec.opts +8 -0
- data/spec/spec_helper.rb +24 -7
- data/tasks/metric_fu.rake +22 -0
- data/vendor/_fonts/monaco.ttf +0 -0
- data/{lib/metric_fu → vendor}/saikuro/saikuro.rb +0 -0
- metadata +84 -66
- data/lib/metric_fu/base.rb +0 -160
- data/lib/metric_fu/flay.rb +0 -17
- data/lib/metric_fu/flog.rb +0 -129
- data/lib/metric_fu/reek.rb +0 -17
- data/lib/metric_fu/roodi.rb +0 -17
- 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/flog.html.erb +0 -38
- data/lib/templates/flog_page.html.erb +0 -25
- data/lib/templates/reek.html.erb +0 -30
- data/spec/base_spec.rb +0 -57
- data/spec/churn_spec.rb +0 -117
- data/spec/config_spec.rb +0 -110
- data/spec/flay_spec.rb +0 -19
- data/spec/flog_spec.rb +0 -208
- data/spec/reek_spec.rb +0 -26
data/lib/tasks/metric_fu.rake
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# only load configured metrics
|
2
|
-
MetricFu.metrics.each { |task| import "#{File.dirname(__FILE__)}/#{task}.rake" }
|
3
|
-
|
4
|
-
namespace :metrics do
|
5
|
-
if MetricFu::RAILS
|
6
|
-
|
7
|
-
desc "Generate coverage, cyclomatic complexity, flog, flay, railroad, reek, roodi, stats and churn reports"
|
8
|
-
task :all => MetricFu.metrics
|
9
|
-
|
10
|
-
task :set_testing_env do
|
11
|
-
RAILS_ENV = 'test'
|
12
|
-
end
|
13
|
-
|
14
|
-
desc "Generate metrics after migrating (for continuous integration)"
|
15
|
-
task :all_with_migrate => [:set_testing_env, "db:migrate", :all]
|
16
|
-
|
17
|
-
else
|
18
|
-
|
19
|
-
desc "Generate coverage, cyclomatic complexity, flog, flay, railroad and churn reports"
|
20
|
-
task :all => MetricFu.metrics
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
data/lib/tasks/metric_fu.rb
DELETED
data/lib/tasks/railroad.rake
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
namespace :metrics do
|
2
|
-
|
3
|
-
RAILROAD_DIR = File.join(MetricFu::BASE_DIRECTORY, 'railroad')
|
4
|
-
RAILROAD_FILE = File.join(RAILROAD_DIR, 'index.html')
|
5
|
-
|
6
|
-
task :railroad => ['railroad:all'] do
|
7
|
-
end
|
8
|
-
|
9
|
-
namespace :railroad do
|
10
|
-
|
11
|
-
desc "Create all railroad reports"
|
12
|
-
task :all => [:models, :controllers, :aasm] do
|
13
|
-
#system("open #{RAILROAD_INDEX}") if PLATFORM['darwin']
|
14
|
-
end
|
15
|
-
|
16
|
-
desc "Create a railroad models report"
|
17
|
-
task :models do
|
18
|
-
#mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
|
19
|
-
`railroad -M -a -m -l -v | neato -Tpng > #{File.join(MetricFu::BASE_DIRECTORY,'model-diagram.png')}`
|
20
|
-
#`echo "<a href=\"railroad/models.png\">Model diagram</a><br />" >> #{RAILROAD_FILE}`
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "Create a railroad controllers report"
|
24
|
-
task :controllers do
|
25
|
-
#mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
|
26
|
-
`railroad -C -l -v | neato -Tpng > #{File.join(MetricFu::BASE_DIRECTORY,'controller-diagram.png')}`
|
27
|
-
#`echo "<a href=\"railroad/controllers.png\">Controller diagram</a><br />" >> #{RAILROAD_FILE}`
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "Create a railroad acts_as_state_machine report"
|
31
|
-
task :aasm do
|
32
|
-
#mkdir_p(RAILROAD_DIR) unless File.directory?(RAILROAD_DIR)
|
33
|
-
`railroad -A -l -v | neato -Tpng > #{File.join(MetricFu::BASE_DIRECTORY,'aasm-diagram.png')}`
|
34
|
-
#`echo "<a href=\"railroad/aasm.png\">State machine diagram</a><br />" >> #{RAILROAD_FILE}`
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
data/lib/tasks/reek.rake
DELETED
data/lib/tasks/roodi.rake
DELETED
data/lib/tasks/saikuro.rake
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
namespace :metrics do
|
4
|
-
|
5
|
-
desc "A cyclomatic complexity report using Saikuro"
|
6
|
-
task :saikuro do
|
7
|
-
SAIKURO_DIR = File.join(MetricFu::BASE_DIRECTORY, 'saikuro')
|
8
|
-
SAIKURO = File.expand_path(File.join(File.dirname(__FILE__), '..', 'metric_fu', 'saikuro', 'saikuro.rb'))
|
9
|
-
|
10
|
-
raise "SAIKURO_OPTIONS is now MetricFu::SAIKURO_OPTIONS" if defined?(SAIKURO_OPTIONS)
|
11
|
-
options = { :output_directory => SAIKURO_DIR,
|
12
|
-
:input_directory => MetricFu::CODE_DIRS,
|
13
|
-
:cyclo => "",
|
14
|
-
:filter_cyclo => "0",
|
15
|
-
:warn_cyclo => "5",
|
16
|
-
:error_cyclo => "7"}
|
17
|
-
|
18
|
-
options.merge!(MetricFu::SAIKURO_OPTIONS) if defined?(MetricFu::SAIKURO_OPTIONS)
|
19
|
-
options_string = options.inject(""){ |o, h| o + "--#{h.join(' ')} " }
|
20
|
-
|
21
|
-
sh %{ruby "#{SAIKURO}" #{options_string}} do |ok, response|
|
22
|
-
unless ok
|
23
|
-
puts "Saikuro failed with exit status: #{response.exitstatus}"
|
24
|
-
exit 1
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
if File.exist? "#{SAIKURO_DIR}/index_cyclo.html"
|
29
|
-
mv "#{SAIKURO_DIR}/index_cyclo.html",
|
30
|
-
"#{SAIKURO_DIR}/index.html"
|
31
|
-
end
|
32
|
-
|
33
|
-
system("open #{SAIKURO_DIR}/index.html") if MetricFu.open_in_browser?
|
34
|
-
end
|
35
|
-
end
|
data/lib/tasks/stats.rake
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
namespace :metrics do
|
2
|
-
|
3
|
-
STATS_DIR = File.join(MetricFu::BASE_DIRECTORY, 'stats')
|
4
|
-
STATS_FILE = File.join(STATS_DIR, 'index.html')
|
5
|
-
|
6
|
-
desc "A stats report"
|
7
|
-
task :stats do
|
8
|
-
mkdir_p(STATS_DIR) unless File.directory?(STATS_DIR)
|
9
|
-
`echo '<pre>' > #{STATS_FILE}`
|
10
|
-
`rake stats >> #{STATS_FILE}`
|
11
|
-
`echo '</pre>' >> #{STATS_FILE}`
|
12
|
-
system("open #{STATS_FILE}") if MetricFu.open_in_browser?
|
13
|
-
end
|
14
|
-
end
|
data/lib/templates/flog.html.erb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>Flog Reporter</title>
|
4
|
-
<style>
|
5
|
-
<%= inline_css("default.css") %>
|
6
|
-
</style>
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<h1>Flog Results</h1>
|
10
|
-
<p><a href='http://ruby.sadi.st/Flog.html'>Flog</a> measures code complexity.</p>
|
11
|
-
<table>
|
12
|
-
<tr>
|
13
|
-
<th>File</th>
|
14
|
-
<th>Total score</th>
|
15
|
-
<th>Methods</th>
|
16
|
-
<th>Average score</th>
|
17
|
-
<th>Highest score</th>
|
18
|
-
</tr>
|
19
|
-
<% pages.sort {|x,y| y.highest_score <=> x.highest_score }.each_with_index do |page, count| %>
|
20
|
-
<tr class='<%= cycle("light", "dark", count) %>'>
|
21
|
-
<td><a href='<%= page.path %>'><%= page.path.sub('.html', '.rb') %></a></td>
|
22
|
-
<td class='score'><%= sprintf(SCORE_FORMAT, page.score) %></td>
|
23
|
-
<td class='score'><%= page.scanned_methods.length %></td>
|
24
|
-
<td class='score'><%= sprintf(SCORE_FORMAT, page.average_score) %></td>
|
25
|
-
<td class='score'><%= sprintf(SCORE_FORMAT, page.highest_score) %></td>
|
26
|
-
</tr>
|
27
|
-
<% end %>
|
28
|
-
<tr>
|
29
|
-
<td><strong>Totals</strong></td>
|
30
|
-
<td class='score'><strong><%= sprintf(SCORE_FORMAT, pages.inject(0){|sum, page| sum + page.score }) %></strong></td>
|
31
|
-
<td class='score'><strong><%= pages.inject(0){|sum, page| sum + page.scanned_methods.length } %></strong></td>
|
32
|
-
<td class='score'></td>
|
33
|
-
<td class='score'></td>
|
34
|
-
</tr>
|
35
|
-
</table>
|
36
|
-
<p>Generated on <%= Time.now.localtime %></p>
|
37
|
-
</body>
|
38
|
-
</html>
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<style>
|
4
|
-
<%= inline_css("default.css") %>
|
5
|
-
</style>
|
6
|
-
</head>
|
7
|
-
<body>
|
8
|
-
<p>Score: <%= score %></p>
|
9
|
-
<% scanned_methods.each do |sm| %>
|
10
|
-
<p><strong><%= sm.name %> (<%= sm.score %>)</strong></p>
|
11
|
-
<table>
|
12
|
-
<tr>
|
13
|
-
<th>Score</th>
|
14
|
-
<th>Operator</th>
|
15
|
-
</tr>
|
16
|
-
<% sm.operators.each_with_index do |operator, count| %>
|
17
|
-
<tr class='<%= cycle("light", "dark", count) %>'>
|
18
|
-
<td class='score'><%= sprintf(SCORE_FORMAT, operator.score) %></td>
|
19
|
-
<td class='score'><%= operator.operator %></td>
|
20
|
-
</tr>
|
21
|
-
<% end %>
|
22
|
-
</table>
|
23
|
-
<% end %>
|
24
|
-
</body>
|
25
|
-
</html>
|
data/lib/templates/reek.html.erb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>Reek Results</title>
|
4
|
-
<style>
|
5
|
-
<%= inline_css("default.css") %>
|
6
|
-
</style>
|
7
|
-
</head>
|
8
|
-
|
9
|
-
<body>
|
10
|
-
<h1>Reek Results</h1>
|
11
|
-
<p><a href="http://reek.rubyforge.org/">Reek</a> detects common code smells in ruby code.</p>
|
12
|
-
<table>
|
13
|
-
<tr>
|
14
|
-
<th>File Path</th>
|
15
|
-
<th>Code Smell</th>
|
16
|
-
</tr>
|
17
|
-
<% @matches.each_with_index do |match, count| %>
|
18
|
-
<tr class='<%= cycle("light", "dark", count) %>'>
|
19
|
-
<td><%= match.first %></td>
|
20
|
-
<td>
|
21
|
-
<% match[1..-1].each do |line| %>
|
22
|
-
<%= line %><br>
|
23
|
-
<% end %>
|
24
|
-
</td>
|
25
|
-
</tr>
|
26
|
-
<% end %>
|
27
|
-
</table>
|
28
|
-
<p>Generated on <%= Time.now.localtime %></p>
|
29
|
-
</body>
|
30
|
-
</html>
|
data/spec/base_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe MetricFu::Base::Generator do
|
4
|
-
describe "save_html" do
|
5
|
-
it "should save to a index.html in the base_dir" do
|
6
|
-
@generator = MetricFu::Base::Generator.new
|
7
|
-
@generator.should_receive(:open).with("#{MetricFu::BASE_DIRECTORY}/generator/index.html", "w")
|
8
|
-
@generator.save_html("<html>")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should save to a custom.html to the base_dir if 'custom' is passed as name" do
|
12
|
-
@generator = MetricFu::Base::Generator.new
|
13
|
-
@generator.should_receive(:open).with("#{MetricFu::BASE_DIRECTORY}/generator/metric_fu/custom.html", "w")
|
14
|
-
@generator.save_html("<html>", 'metric_fu/custom.html')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "generate_report class method" do
|
19
|
-
it "should create a new Generator and call generate_report on it" do
|
20
|
-
@generator = mock('generator')
|
21
|
-
@generator.should_receive(:generate_report)
|
22
|
-
MetricFu::Base::Generator.should_receive(:new).and_return(@generator)
|
23
|
-
MetricFu::Base::Generator.generate_report('base_dir')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "generate_html" do
|
28
|
-
it "should create a new Generator and call generate_report on it" do
|
29
|
-
@generator = MetricFu::Base::Generator.new
|
30
|
-
@generator.should_receive(:open).with("#{MetricFu::BASE_DIRECTORY}/generator/index.html", "w")
|
31
|
-
@generator.should_receive(:generate_html).and_return('<html>')
|
32
|
-
@generator.generate_report
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "cycle" do
|
37
|
-
it "should create a new Generator and call generate_report on it" do
|
38
|
-
@generator = MetricFu::Base::Generator.new
|
39
|
-
@generator.cycle("light", "dark", 0).should == 'light'
|
40
|
-
@generator.cycle("light", "dark", 1).should == 'dark'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "template_name" do
|
45
|
-
it "should return the class name in lowercase" do
|
46
|
-
@generator = MetricFu::Base::Generator.new
|
47
|
-
@generator.template_name.should == 'generator'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "metric_dir" do
|
52
|
-
it "should return tmp/metric_fu/{the class name in lowercase}" do
|
53
|
-
MetricFu::Base::Generator.metric_dir.should == "#{MetricFu::BASE_DIRECTORY}/generator"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
data/spec/churn_spec.rb
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe MetricFu::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
|
117
|
-
end
|
data/spec/config_spec.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe MetricFu::Configuration do
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|