indirect-metric_fu 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/metric_fu/base.rb +53 -0
- data/lib/metric_fu/churn.rb +73 -113
- data/lib/metric_fu/flay_reporter.rb +17 -0
- data/lib/metric_fu/flog_reporter/base.rb +5 -14
- data/lib/metric_fu/flog_reporter/generator.rb +29 -61
- data/lib/metric_fu/flog_reporter/operator.rb +1 -1
- data/lib/metric_fu/flog_reporter/page.rb +11 -14
- data/lib/metric_fu/flog_reporter/scanned_method.rb +2 -2
- data/lib/metric_fu/md5_tracker.rb +5 -5
- data/lib/metric_fu.rb +1 -12
- data/lib/tasks/churn.rake +1 -1
- data/lib/tasks/coverage.rake +7 -5
- data/lib/tasks/flay.rake +9 -0
- data/lib/tasks/flog.rake +10 -10
- data/lib/tasks/metric_fu.rake +15 -11
- data/lib/tasks/saikuro.rake +5 -5
- data/lib/tasks/stats.rake +2 -2
- data/lib/templates/churn.css +38 -0
- data/lib/templates/churn.html.erb +19 -0
- data/lib/templates/flay.css +38 -0
- data/lib/templates/flay.html.erb +23 -0
- data/lib/templates/flog.css +39 -0
- data/lib/templates/flog.html.erb +26 -0
- data/lib/templates/flog_page.html.erb +13 -0
- data/spec/base_spec.rb +35 -0
- data/spec/churn_spec.rb +81 -34
- data/spec/flay_reporter_spec.rb +12 -0
- data/spec/flog_reporter/base_spec.rb +7 -7
- data/spec/md5_tracker_spec.rb +7 -7
- data/spec/spec_helper.rb +7 -0
- metadata +24 -3
- data/lib/metric_fu/flay.rb +0 -40
data/lib/tasks/metric_fu.rake
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
namespace :metrics do
|
2
|
-
task :prepare do
|
3
|
-
RAILS_ENV = 'test'
|
4
|
-
end
|
5
|
-
|
6
|
-
desc "Useful for continuous integration"
|
7
|
-
task :all_with_migrate => [:prepare, "db:migrate", :all]
|
8
|
-
|
9
2
|
if MetricFu::RAILS
|
10
|
-
|
11
|
-
|
3
|
+
|
4
|
+
desc "Generate coverage, cyclomatic complexity, flog, stats, duplication and churn reports"
|
5
|
+
task :all => [:coverage, :stats, :saikuro, :churn, :flog, :flay]
|
6
|
+
|
7
|
+
task :set_testing_env do
|
8
|
+
RAILS_ENV = 'test'
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Generate metrics after migrating (for continuous integration)"
|
12
|
+
task :all_with_migrate => [:set_testing_env, "db:migrate", :all]
|
13
|
+
|
12
14
|
else
|
13
|
-
|
14
|
-
|
15
|
+
|
16
|
+
desc "Generate coverage, cyclomatic complexity, flog, duplication and churn reports"
|
17
|
+
task :all => [:coverage, :saikuro, :churn, :flog, :flay]
|
18
|
+
|
15
19
|
end
|
16
20
|
end
|
data/lib/tasks/saikuro.rake
CHANGED
@@ -14,10 +14,10 @@ namespace :metrics do
|
|
14
14
|
:filter_cyclo => "0",
|
15
15
|
:warn_cyclo => "5",
|
16
16
|
:error_cyclo => "7"}
|
17
|
-
|
17
|
+
|
18
18
|
options.merge!(MetricFu::SAIKURO_OPTIONS) if defined?(MetricFu::SAIKURO_OPTIONS)
|
19
|
-
options_string = options.inject(""){ |o, h| o + "--#{h.join(' ')} " }
|
20
|
-
|
19
|
+
options_string = options.inject(""){ |o, h| o + "--#{h.join(' ')} " }
|
20
|
+
|
21
21
|
sh %{ruby "#{SAIKURO}" #{options_string}} do |ok, response|
|
22
22
|
unless ok
|
23
23
|
puts "Saikuro failed with exit status: #{response.exitstatus}"
|
@@ -26,10 +26,10 @@ namespace :metrics do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
if File.exist? "#{SAIKURO_DIR}/index_cyclo.html"
|
29
|
-
mv "#{SAIKURO_DIR}/index_cyclo.html",
|
29
|
+
mv "#{SAIKURO_DIR}/index_cyclo.html",
|
30
30
|
"#{SAIKURO_DIR}/index.html"
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
system("open #{SAIKURO_DIR}/index.html") if PLATFORM['darwin']
|
34
34
|
end
|
35
35
|
end
|
data/lib/tasks/stats.rake
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
body {
|
2
|
+
margin: 20px;
|
3
|
+
padding: 0;
|
4
|
+
font-size: 12px;
|
5
|
+
font-family: bitstream vera sans, verdana, arial, sans serif;
|
6
|
+
background-color: #efefef;
|
7
|
+
}
|
8
|
+
|
9
|
+
table {
|
10
|
+
border-collapse: collapse;
|
11
|
+
/*border-spacing: 0;*/
|
12
|
+
border: 1px solid #666;
|
13
|
+
background-color: #fff;
|
14
|
+
margin-bottom: 20px;
|
15
|
+
}
|
16
|
+
|
17
|
+
table, th, th+th, td, td+td {
|
18
|
+
border: 1px solid #ccc;
|
19
|
+
}
|
20
|
+
|
21
|
+
table th {
|
22
|
+
font-size: 12px;
|
23
|
+
color: #fc0;
|
24
|
+
padding: 4px 0;
|
25
|
+
background-color: #336;
|
26
|
+
}
|
27
|
+
|
28
|
+
th, td {
|
29
|
+
padding: 4px 10px;
|
30
|
+
}
|
31
|
+
|
32
|
+
td {
|
33
|
+
font-size: 13px;
|
34
|
+
}
|
35
|
+
|
36
|
+
.warning {
|
37
|
+
background-color: yellow;
|
38
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Source Control Churn Results</title>
|
4
|
+
<style>
|
5
|
+
<%= open(File.join(MetricFu::TEMPLATE_DIR, "#{template_name}.css")) { |f| f.read } %>
|
6
|
+
</style>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
<h1>Source Control Churn Results</h1>
|
11
|
+
<table width="100%" border="1">
|
12
|
+
<tr><th>File Path</th><th>Times Changed</th></tr>
|
13
|
+
<% @changes.to_a.sort {|x,y| y[1] <=> x[1]}.each do |change| %>
|
14
|
+
<tr><td><%= change[0] %></td><td class='warning'><%= change[1] %></td></tr>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
</table>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
body {
|
2
|
+
margin: 20px;
|
3
|
+
padding: 0;
|
4
|
+
font-size: 12px;
|
5
|
+
font-family: bitstream vera sans, verdana, arial, sans serif;
|
6
|
+
background-color: #efefef;
|
7
|
+
}
|
8
|
+
|
9
|
+
table {
|
10
|
+
border-collapse: collapse;
|
11
|
+
/*border-spacing: 0;*/
|
12
|
+
border: 1px solid #666;
|
13
|
+
background-color: #fff;
|
14
|
+
margin-bottom: 10px;
|
15
|
+
}
|
16
|
+
|
17
|
+
table, th, th+th, td, td+td {
|
18
|
+
border: 1px solid #ccc;
|
19
|
+
}
|
20
|
+
|
21
|
+
table th {
|
22
|
+
font-size: 14px;
|
23
|
+
color: #fc0;
|
24
|
+
background-color: #336;
|
25
|
+
text-align: left;
|
26
|
+
}
|
27
|
+
|
28
|
+
th, td {
|
29
|
+
padding: 4px 10px;
|
30
|
+
}
|
31
|
+
|
32
|
+
td {
|
33
|
+
font-size: 13px;
|
34
|
+
}
|
35
|
+
|
36
|
+
.warning {
|
37
|
+
background-color: yellow;
|
38
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Flay Results</title>
|
4
|
+
<style>
|
5
|
+
<%= open(File.join(MetricFu::TEMPLATE_DIR, "#{template_name}.css")) { |f| f.read } %>
|
6
|
+
</style>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
<h1>Flay Results</h1>
|
11
|
+
|
12
|
+
<% @matches.each do |match| %>
|
13
|
+
<table width="80%" border="1">
|
14
|
+
<tr><th><%= match.first %></th></tr>
|
15
|
+
<tr><td>
|
16
|
+
<% match[1..-1].each do |filename| %>
|
17
|
+
<%= link_to_filename(*filename.split(":")) %><br>
|
18
|
+
<% end %>
|
19
|
+
</td></tr>
|
20
|
+
<% end %>
|
21
|
+
</table>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
body {
|
2
|
+
background-color: rgb(240, 240, 245);
|
3
|
+
font-family: verdana, arial, helvetica;
|
4
|
+
}
|
5
|
+
|
6
|
+
table {
|
7
|
+
border-collapse: collapse;
|
8
|
+
}
|
9
|
+
|
10
|
+
table.report {
|
11
|
+
width: 100%;
|
12
|
+
}
|
13
|
+
|
14
|
+
table th {
|
15
|
+
text-align: center;
|
16
|
+
}
|
17
|
+
|
18
|
+
table td.score {
|
19
|
+
text-align: right;
|
20
|
+
}
|
21
|
+
|
22
|
+
table th {
|
23
|
+
background: #dcecff;
|
24
|
+
border: #d0d0d0 1px solid;
|
25
|
+
font-weight: bold;
|
26
|
+
}
|
27
|
+
|
28
|
+
table td {
|
29
|
+
border: #d0d0d0 1px solid;
|
30
|
+
}
|
31
|
+
|
32
|
+
table tr.light {
|
33
|
+
background-color: rgb(240, 240, 245);
|
34
|
+
}
|
35
|
+
|
36
|
+
table tr.dark {
|
37
|
+
background-color: rgb(230, 230, 235);
|
38
|
+
}
|
39
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Flog Reporter</title>
|
4
|
+
<style>
|
5
|
+
<%= open(File.join(MetricFu::TEMPLATE_DIR, "#{template_name}.css")) { |f| f.read } %>
|
6
|
+
</style>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<h1>Flogged files</h1>
|
10
|
+
<p>Generated on <%= Time.now.localtime %> with <a href='http://ruby.sadi.st/Flog.html'>flog</a></p>
|
11
|
+
<table class='report'>
|
12
|
+
<tr><th>File</th><th>Total score</th><th>Methods</th><th>Average score</th><th>Highest score</th></tr>
|
13
|
+
<% count = 0 %>
|
14
|
+
<% flog_hashes.sort {|x,y| y[:page].highest_score <=> x[:page].highest_score }.each do |flog_hash| %>
|
15
|
+
<tr class='<%= Base.cycle("light", "dark", count) %>'>
|
16
|
+
<td><a href='<%= flog_hash[:path]%>'><%= flog_hash[:path].sub('.html', '.rb') %></a></td>
|
17
|
+
<td class='score'><%= sprintf(SCORE_FORMAT, flog_hash[:page].score) %></td>
|
18
|
+
<td class='score'><%= flog_hash[:page].scanned_methods.length %></td>
|
19
|
+
<td class='score'><%= sprintf(SCORE_FORMAT, flog_hash[:page].average_score) %></td>
|
20
|
+
<td class='score'><%= sprintf(SCORE_FORMAT, flog_hash[:page].highest_score) %></td>
|
21
|
+
</tr>
|
22
|
+
<% count += 1 %>
|
23
|
+
<% end %>
|
24
|
+
</table>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
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('base_dir')
|
7
|
+
@generator.should_receive(:open).with("base_dir/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('base_dir')
|
13
|
+
@generator.should_receive(:open).with("base_dir/metric_fu/custom.html", "w")
|
14
|
+
@generator.save_html("<html>", 'metric_fu/custom')
|
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_report" do
|
28
|
+
it "should create a new Generator and call generate_report on it" do
|
29
|
+
@generator = MetricFu::Base::Generator.new('other_dir')
|
30
|
+
@generator.should_receive(:open).with("other_dir/index.html", "w")
|
31
|
+
@generator.should_receive(:generate_html).and_return('<html>')
|
32
|
+
@generator.generate_report
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/churn_spec.rb
CHANGED
@@ -1,63 +1,110 @@
|
|
1
|
-
require '
|
2
|
-
require File.dirname(__FILE__) + '/../lib/metric_fu/churn'
|
3
|
-
include MetricFu
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
2
|
|
5
3
|
describe MetricFu::Churn do
|
6
4
|
describe "generate_report" do
|
7
5
|
after do
|
8
6
|
load File.dirname(__FILE__) + '/../lib/metric_fu/churn.rb' #need to reload file to wipe out mock of private static
|
9
7
|
end
|
10
|
-
|
8
|
+
|
11
9
|
it "should strip out files that have less than the min count" do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Churn.
|
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('base_dir', :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
|
16
22
|
end
|
23
|
+
|
17
24
|
end
|
18
|
-
|
25
|
+
|
19
26
|
describe "parse_log_for_changes" do
|
20
27
|
it "should count the changes with git" do
|
21
28
|
logs = ["home_page/index.html", "README", "History.txt", "README", "History.txt", "README"]
|
22
|
-
|
23
|
-
|
24
|
-
|
29
|
+
git_mock = mock('git')
|
30
|
+
git_mock.should_receive(:get_logs).and_return(logs)
|
31
|
+
Churn::Git.should_receive(:new).and_return(git_mock)
|
32
|
+
File.should_receive(:exist?).with(".git").and_return(true)
|
33
|
+
changes = Churn.new('base_dir').send(:parse_log_for_changes)
|
25
34
|
changes["home_page/index.html"].should == 1
|
26
35
|
changes["History.txt"].should == 2
|
27
36
|
changes["README"].should == 3
|
28
37
|
end
|
29
|
-
|
38
|
+
|
30
39
|
it "should count the changes with svn" do
|
31
40
|
logs = ["home_page/index.html", "README", "History.txt", "README", "History.txt", "README"]
|
32
|
-
|
33
|
-
|
34
|
-
|
41
|
+
svn_mock = mock('svn')
|
42
|
+
svn_mock.should_receive(:get_logs).and_return(logs)
|
43
|
+
Churn::Svn.should_receive(:new).and_return(svn_mock)
|
44
|
+
File.should_receive(:exist?).with(".git").and_return(false)
|
45
|
+
File.should_receive(:exist?).with(".svn").and_return(true)
|
46
|
+
changes = Churn.new('base_dir').send(:parse_log_for_changes)
|
35
47
|
changes["home_page/index.html"].should == 1
|
36
48
|
changes["History.txt"].should == 2
|
37
49
|
changes["README"].should == 3
|
38
|
-
end
|
50
|
+
end
|
39
51
|
end
|
40
|
-
|
52
|
+
end
|
53
|
+
|
54
|
+
describe MetricFu::Churn::Svn do
|
55
|
+
|
56
|
+
describe "get_logs" do
|
57
|
+
it "should use the start date if supplied" do
|
58
|
+
@churn = Churn::Svn.new
|
59
|
+
@churn.should_receive(:`).with('svn log --verbose').and_return("")
|
60
|
+
@churn.get_logs
|
61
|
+
end
|
62
|
+
it "should use the start date if supplied" do
|
63
|
+
Time.should_receive(:now).and_return(Date.new(2001, 1, 2))
|
64
|
+
@churn = Churn::Svn.new(lambda{Date.new(2000, 1, 1)})
|
65
|
+
@churn.should_receive(:require_rails_env)
|
66
|
+
@churn.should_receive(:`).with("svn log --revision {2000-01-01}:{2001-01-02} --verbose").and_return("")
|
67
|
+
@churn.get_logs
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
41
71
|
describe "clean_up_svn_line" do
|
42
72
|
it "should return nil for non matches" do
|
43
|
-
Churn.send(:clean_up_svn_line, "Adding Google analytics").should be_nil
|
44
|
-
Churn.send(:clean_up_svn_line, "A bunch of new files").should be_nil
|
73
|
+
Churn::Svn.new.send(:clean_up_svn_line, "Adding Google analytics").should be_nil
|
74
|
+
Churn::Svn.new.send(:clean_up_svn_line, "A bunch of new files").should be_nil
|
45
75
|
end
|
46
|
-
|
76
|
+
|
47
77
|
it "should strip out all but the full path" do
|
48
|
-
Churn.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
49
|
-
Churn.send(:clean_up_svn_line, "A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
50
|
-
Churn.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
51
|
-
Churn.send(:clean_up_svn_line, " A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
52
|
-
Churn.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
53
|
-
Churn.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
54
|
-
|
55
|
-
Churn.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
56
|
-
Churn.send(:clean_up_svn_line, "M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
57
|
-
Churn.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
58
|
-
Churn.send(:clean_up_svn_line, " M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
59
|
-
Churn.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
60
|
-
Churn.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
78
|
+
Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
79
|
+
Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
80
|
+
Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
81
|
+
Churn::Svn.new.send(:clean_up_svn_line, " A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
82
|
+
Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
83
|
+
Churn::Svn.new.send(:clean_up_svn_line, "A /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
84
|
+
|
85
|
+
Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
86
|
+
Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
87
|
+
Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb ").should == "/trunk/lib/server.rb"
|
88
|
+
Churn::Svn.new.send(:clean_up_svn_line, " M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
89
|
+
Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
90
|
+
Churn::Svn.new.send(:clean_up_svn_line, "M /trunk/lib/server.rb").should == "/trunk/lib/server.rb"
|
61
91
|
end
|
62
92
|
end
|
63
93
|
end
|
94
|
+
|
95
|
+
describe MetricFu::Churn::Git do
|
96
|
+
|
97
|
+
describe "get_logs" do
|
98
|
+
it "should use the start date if supplied" do
|
99
|
+
@churn = Churn::Git.new
|
100
|
+
@churn.should_receive(:`).with('git log --name-only --pretty=format:').and_return("")
|
101
|
+
@churn.get_logs
|
102
|
+
end
|
103
|
+
it "should use the start date if supplied" do
|
104
|
+
@churn = Churn::Git.new(lambda{Date.new(2000, 1, 1)})
|
105
|
+
@churn.should_receive(:require_rails_env)
|
106
|
+
@churn.should_receive(:`).with("git log --after=2000-01-01 --name-only --pretty=format:").and_return("")
|
107
|
+
@churn.get_logs
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe MetricFu::FlayReporter do
|
4
|
+
|
5
|
+
describe "generate_html" do
|
6
|
+
it "should create a new Generator and call generate_report on it" do
|
7
|
+
@generator = MetricFu::FlayReporter.new('other_dir')
|
8
|
+
@generator.should_receive(:`).and_return("Matches found in :call (mass = 55)\n\tlib/metric_fu/flog_reporter.rb:2\n\tlib/metric_fu/flog_reporter.rb:3")
|
9
|
+
@generator.generate_html
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec'
|
2
|
-
require File.dirname(__FILE__) + '/../../lib/metric_fu'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/metric_fu/flog_reporter'
|
3
3
|
include MetricFu::FlogReporter
|
4
4
|
|
5
5
|
describe "FlogReporter::Base" do
|
@@ -36,27 +36,27 @@ MTHD
|
|
36
36
|
1.1: entryRelationship
|
37
37
|
BM
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
it "should be able to parse an alpha only method" do
|
41
41
|
page = Base.parse(@alpha_only_method)
|
42
42
|
page.should_not be_nil
|
43
43
|
page.score.should == 13.6283678106927
|
44
|
-
page.scanned_methods.size.should == 1
|
44
|
+
page.scanned_methods.size.should == 1
|
45
45
|
sm = page.scanned_methods.first
|
46
46
|
sm.name.should == 'ErrorMailer#errormail'
|
47
|
-
sm.score.should == 12.5
|
47
|
+
sm.score.should == 12.5
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it "should be able to parse method that has digits" do
|
51
51
|
page = Base.parse(@method_that_has_digits)
|
52
52
|
page.should_not be_nil
|
53
53
|
page.score.should == 7.08378429936994
|
54
|
-
page.scanned_methods.size.should == 1
|
54
|
+
page.scanned_methods.size.should == 1
|
55
55
|
sm = page.scanned_methods.first
|
56
56
|
sm.name.should == 'NoImmunizationReason#to_c32'
|
57
57
|
sm.score.should == 7.1
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
it "should be able to parse bang method" do
|
61
61
|
page = Base.parse(@bang_method)
|
62
62
|
page.should_not be_nil
|
data/spec/md5_tracker_spec.rb
CHANGED
@@ -9,11 +9,11 @@ describe MetricFu::MD5Tracker do
|
|
9
9
|
@file1 = File.new(File.join(@tmp_dir, 'file1.txt'), 'w')
|
10
10
|
@file2 = File.new(File.join(@tmp_dir, 'file2.txt'), 'w')
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
after do
|
14
14
|
FileUtils.rm_rf(@tmp_dir, :verbose => false)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "identical files should match" do
|
18
18
|
@file1.puts("Hello World")
|
19
19
|
@file1.close
|
@@ -25,7 +25,7 @@ describe MetricFu::MD5Tracker do
|
|
25
25
|
|
26
26
|
file2_md5.should == file1_md5
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
it "different files should not match" do
|
30
30
|
@file1.puts("Hello World")
|
31
31
|
@file1.close
|
@@ -37,20 +37,20 @@ describe MetricFu::MD5Tracker do
|
|
37
37
|
|
38
38
|
file2_md5.should_not == file1_md5
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "file_changed? should detect a change" do
|
42
42
|
@file2.close
|
43
|
-
|
43
|
+
|
44
44
|
@file1.puts("Hello World")
|
45
45
|
@file1.close
|
46
46
|
file1_md5 = MD5Tracker.track(@file1.path, @tmp_dir)
|
47
|
-
|
47
|
+
|
48
48
|
@file1 = File.new(File.join(@tmp_dir, 'file1.txt'), 'w')
|
49
49
|
@file1.puts("Goodbye World")
|
50
50
|
@file1.close
|
51
51
|
MD5Tracker.file_changed?(@file1.path, @tmp_dir).should be_true
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it "should detect a new file" do
|
55
55
|
@file2.close
|
56
56
|
MD5Tracker.file_changed?(@file1.path, @tmp_dir).should be_true
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indirect-metric_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Scruggs
|
@@ -41,7 +41,16 @@ dependencies:
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 0.0.0
|
43
43
|
version:
|
44
|
-
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: diff-lcs
|
46
|
+
version_requirement:
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 0.0.0
|
52
|
+
version:
|
53
|
+
description: Code metrics from Flog, Flay, RCov, Saikuro, Churn, and Rails' stats task
|
45
54
|
email: jake.scruggs@gmail.com
|
46
55
|
executables: []
|
47
56
|
|
@@ -56,8 +65,9 @@ files:
|
|
56
65
|
- TODO
|
57
66
|
- MIT-LICENSE
|
58
67
|
- Rakefile
|
68
|
+
- lib/metric_fu/base.rb
|
59
69
|
- lib/metric_fu/churn.rb
|
60
|
-
- lib/metric_fu/
|
70
|
+
- lib/metric_fu/flay_reporter.rb
|
61
71
|
- lib/metric_fu/flog_reporter/base.rb
|
62
72
|
- lib/metric_fu/flog_reporter/generator.rb
|
63
73
|
- lib/metric_fu/flog_reporter/operator.rb
|
@@ -70,10 +80,18 @@ files:
|
|
70
80
|
- lib/tasks/metric_fu.rb
|
71
81
|
- lib/tasks/churn.rake
|
72
82
|
- lib/tasks/coverage.rake
|
83
|
+
- lib/tasks/flay.rake
|
73
84
|
- lib/tasks/flog.rake
|
74
85
|
- lib/tasks/metric_fu.rake
|
75
86
|
- lib/tasks/saikuro.rake
|
76
87
|
- lib/tasks/stats.rake
|
88
|
+
- lib/templates/churn.css
|
89
|
+
- lib/templates/churn.html.erb
|
90
|
+
- lib/templates/flay.css
|
91
|
+
- lib/templates/flay.html.erb
|
92
|
+
- lib/templates/flog.css
|
93
|
+
- lib/templates/flog.html.erb
|
94
|
+
- lib/templates/flog_page.html.erb
|
77
95
|
has_rdoc: true
|
78
96
|
homepage: http://metric-fu.rubyforge.org/
|
79
97
|
post_install_message:
|
@@ -102,6 +120,9 @@ signing_key:
|
|
102
120
|
specification_version: 2
|
103
121
|
summary: A fistful of code metrics
|
104
122
|
test_files:
|
123
|
+
- spec/base_spec.rb
|
105
124
|
- spec/churn_spec.rb
|
125
|
+
- spec/flay_reporter_spec.rb
|
106
126
|
- spec/flog_reporter/base_spec.rb
|
107
127
|
- spec/md5_tracker_spec.rb
|
128
|
+
- spec/spec_helper.rb
|