jscruggs-metric_fu 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +13 -0
- data/README +1 -1
- data/Rakefile +1 -29
- data/TODO +1 -2
- data/lib/base/base_template.rb +18 -6
- data/lib/base/configuration.rb +22 -2
- data/lib/base/generator.rb +15 -2
- data/lib/base/graph.rb +37 -0
- data/lib/generators/churn.rb +6 -1
- data/lib/generators/flay.rb +5 -0
- data/lib/generators/flog.rb +6 -0
- data/lib/generators/rcov.rb +10 -0
- data/lib/generators/reek.rb +5 -0
- data/lib/generators/roodi.rb +7 -0
- data/lib/generators/saikuro.rb +184 -187
- 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 +4 -0
- 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/standard/churn.html.erb +1 -0
- data/lib/templates/standard/flay.html.erb +1 -0
- data/lib/templates/standard/flog.html.erb +3 -2
- data/lib/templates/standard/rcov.html.erb +5 -4
- data/lib/templates/standard/reek.html.erb +1 -0
- data/lib/templates/standard/roodi.html.erb +1 -0
- data/lib/templates/standard/saikuro.html.erb +1 -0
- data/lib/templates/standard/stats.html.erb +1 -0
- data/spec/base/base_template_spec.rb +35 -14
- data/spec/base/configuration_spec.rb +4 -4
- data/spec/base/generator_spec.rb +23 -1
- data/spec/base/md5_tracker_spec.rb +1 -1
- data/spec/base/report_spec.rb +1 -1
- data/spec/generators/churn_spec.rb +8 -8
- data/spec/generators/flay_spec.rb +4 -1
- data/spec/generators/flog_spec.rb +10 -2
- data/spec/generators/reek_spec.rb +2 -1
- data/spec/generators/saikuro_spec.rb +22 -17
- data/spec/generators/stats_spec.rb +1 -1
- data/tasks/metric_fu.rake +8 -1
- data/vendor/_fonts/monaco.ttf +0 -0
- metadata +30 -20
- data/tasks/railroad.rake +0 -39
@@ -0,0 +1,36 @@
|
|
1
|
+
<h3>Rcov Code Coverage Results</h3>
|
2
|
+
|
3
|
+
<p>C0 code coverage information.</p>
|
4
|
+
|
5
|
+
<img src="rcov.png?<%= Time.now %>">
|
6
|
+
|
7
|
+
<p>Total Coverage: <%= @rcov.delete(:global_percent_run) %>% </p>
|
8
|
+
<table>
|
9
|
+
<tr>
|
10
|
+
<th>File Path</th>
|
11
|
+
<th>Percent run</th>
|
12
|
+
</tr>
|
13
|
+
<% count = 0 %>
|
14
|
+
<% @rcov.sort_by{ |k,v| v[:percent_run] }.each do |fname, file| %>
|
15
|
+
<tr>
|
16
|
+
<td><a href="#<%= fname.gsub(/[^a-z]+/, '_') %>"><%= fname %></a></td>
|
17
|
+
<td><%= file[:percent_run] %></td>
|
18
|
+
</tr>
|
19
|
+
<% count += 1 %>
|
20
|
+
<% end %>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<% @rcov.sort_by{ |k,v| v[:percent_run] }.each do |fname, file| %>
|
24
|
+
<h2 id="<%= fname.gsub(/[^a-z]+/, '_') %>"> <%= fname %></h2>
|
25
|
+
<div class="rcov_overflow">
|
26
|
+
<table class="rcov_code">
|
27
|
+
<% file[:lines].each_with_index do |line, index| %>
|
28
|
+
<tr>
|
29
|
+
<% css_class = line[:was_run] ? "rcov_run" : "rcov_not_run" %>
|
30
|
+
<td class="<%= css_class %>"><%= link_to_filename(fname, index + 1, "<pre>#{line[:content]}</pre>") %></td>
|
31
|
+
</tr>
|
32
|
+
<% end %>
|
33
|
+
</table>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
36
|
+
<p>Generated on <%= Time.now.localtime %></p>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<h3>Reek Results</h3>
|
2
|
+
|
3
|
+
<p><a href="http://reek.rubyforge.org/">Reek</a> detects common code smells in ruby code.</p>
|
4
|
+
|
5
|
+
<img src="reek.png?<%= Time.now %>">
|
6
|
+
|
7
|
+
<table>
|
8
|
+
<tr>
|
9
|
+
<th>File Path</th>
|
10
|
+
<th>Method</th>
|
11
|
+
<th>Description</th>
|
12
|
+
<th>Type</th>
|
13
|
+
</tr>
|
14
|
+
<% count = 0 %>
|
15
|
+
<% @reek[:matches].each do |match| %>
|
16
|
+
<% match[:code_smells].each do |smell| %>
|
17
|
+
<tr class='<%= cycle("light", "dark", count) %>'>
|
18
|
+
<td><%= link_to_filename(match[:file_path]) %></td>
|
19
|
+
<td>
|
20
|
+
<%= smell[:method] %>
|
21
|
+
</td>
|
22
|
+
<td>
|
23
|
+
<%= smell[:message] %>
|
24
|
+
</td>
|
25
|
+
<td>
|
26
|
+
<%= smell[:type] %>
|
27
|
+
</td>
|
28
|
+
</tr>
|
29
|
+
<% count += 1 %>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
</table>
|
34
|
+
<p>Generated on <%= Time.now.localtime %></p>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<h3>Roodi Results</h3>
|
2
|
+
|
3
|
+
<p><a href="http://roodi.rubyforge.org/">Roodi</a> parses your Ruby code and warns you about design issues you have based on the checks that is has configured.</p>
|
4
|
+
|
5
|
+
<img src="roodi.png?<%= Time.now %>">
|
6
|
+
|
7
|
+
<table>
|
8
|
+
<tr>
|
9
|
+
<th>File Path</th>
|
10
|
+
<th>Warning</th>
|
11
|
+
</tr>
|
12
|
+
<% count = 0 %>
|
13
|
+
<% @roodi[:problems].each do |problem| %>
|
14
|
+
<tr class='<%= cycle("light", "dark", count) %>'>
|
15
|
+
<td><%= link_to_filename(problem[:file], problem[:line]) %></td>
|
16
|
+
<td><%= problem[:problem] %></td>
|
17
|
+
</tr>
|
18
|
+
<% count += 1 %>
|
19
|
+
<% end %>
|
20
|
+
</table>
|
21
|
+
<p>Generated on <%= Time.now.localtime %></p>
|
@@ -0,0 +1,71 @@
|
|
1
|
+
<h3>Saikuro Results</h3>
|
2
|
+
<p><a href='http://saikuro.rubyforge.org/'>Saikuro</a> analyzes ruby code for cyclomatic complexity.</p>
|
3
|
+
|
4
|
+
<h2>Analyzed Methods</h2>
|
5
|
+
<table>
|
6
|
+
<tr>
|
7
|
+
<th>Method Name</th>
|
8
|
+
<th>Complexity</th>
|
9
|
+
<th># Lines</th>
|
10
|
+
</tr>
|
11
|
+
<% @saikuro[:methods].each do |method| %>
|
12
|
+
<tr>
|
13
|
+
<td><%= method[:name] %></td>
|
14
|
+
<td><%= method[:complexity] %></td>
|
15
|
+
<td><%= method[:lines] %></td>
|
16
|
+
</tr>
|
17
|
+
<% end %>
|
18
|
+
</table>
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<h2>Analyzed Classes</h2>
|
23
|
+
<table>
|
24
|
+
<tr>
|
25
|
+
<th>Class Name</th>
|
26
|
+
<th>Complexity</th>
|
27
|
+
<th># Lines</th>
|
28
|
+
</tr>
|
29
|
+
<% @saikuro[:classes].each do |klass| %>
|
30
|
+
<tr>
|
31
|
+
<td><%= klass[:name] %></td>
|
32
|
+
<td><%= klass[:complexity] %></td>
|
33
|
+
<td><%= klass[:lines] %></td>
|
34
|
+
</tr>
|
35
|
+
<% end %>
|
36
|
+
</table>
|
37
|
+
|
38
|
+
|
39
|
+
<h2>Analyzed Files</h2>
|
40
|
+
<% @saikuro[:files].each do |file| %>
|
41
|
+
<% file[:classes].each do |klass| %>
|
42
|
+
<% if !klass[:methods].empty? %>
|
43
|
+
<h3><%= file[:filename] %></h3>
|
44
|
+
<h4>Class : <%= klass[:class_name] %></h4>
|
45
|
+
<h5>Total complexity : <%= klass[:complexity] %></h5>
|
46
|
+
<h5>Total lines : <%= klass[:lines] %></h5>
|
47
|
+
<table>
|
48
|
+
<tr>
|
49
|
+
<th>Method</th>
|
50
|
+
<th>Complexity</th>
|
51
|
+
<th># Lines</th>
|
52
|
+
</tr>
|
53
|
+
<% klass[:methods].each do |method| %>
|
54
|
+
<tr>
|
55
|
+
<td>
|
56
|
+
<%= method[:name] %>
|
57
|
+
</td>
|
58
|
+
<td>
|
59
|
+
<%= method[:complexity] %>
|
60
|
+
</td>
|
61
|
+
<td>
|
62
|
+
<%= method[:lines] %>
|
63
|
+
</td>
|
64
|
+
</tr>
|
65
|
+
<% end %>
|
66
|
+
</table>
|
67
|
+
<% end %>
|
68
|
+
<% end %>
|
69
|
+
<% end %>
|
70
|
+
|
71
|
+
<p>Generated on <%= Time.now.localtime %></p>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<h3>Rake Stats Results</h3>
|
2
|
+
<p>Rails rake stats results.</p>
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Lines of Code</th>
|
6
|
+
<th>Lines of Test</th>
|
7
|
+
<th>Code to test ratio</th>
|
8
|
+
</tr>
|
9
|
+
<tr>
|
10
|
+
<td><%= @stats[:codeLOC] %></td>
|
11
|
+
<td><%= @stats[:testLOC] %></td>
|
12
|
+
<td>1:<%= @stats[:code_to_test_ratio] %></td>
|
13
|
+
</tr>
|
14
|
+
</table>
|
15
|
+
|
16
|
+
<table>
|
17
|
+
<tr>
|
18
|
+
<th>Name</th>
|
19
|
+
<th>Lines</th>
|
20
|
+
<th>LOC</th>
|
21
|
+
<th>Classes</th>
|
22
|
+
<th>Methods</th>
|
23
|
+
<th>Methods per class</th>
|
24
|
+
<th>LOC per method</th>
|
25
|
+
</tr>
|
26
|
+
<% count = 0 %>
|
27
|
+
<% @stats[:lines].each do |line| %>
|
28
|
+
<tr>
|
29
|
+
<td><%= line[:name] %></td>
|
30
|
+
<td><%= line[:lines] %></td>
|
31
|
+
<td><%= line[:loc] %></td>
|
32
|
+
<td><%= line[:classes] %></td>
|
33
|
+
<td><%= line[:methods] %></td>
|
34
|
+
<td><%= line[:methods_per_class] %></td>
|
35
|
+
<td><%= line[:loc_per_method] %></td>
|
36
|
+
</tr>
|
37
|
+
<% count += 1 %>
|
38
|
+
<% end %>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
<p>Generated on <%= Time.now.localtime %></p>
|
@@ -7,6 +7,7 @@
|
|
7
7
|
</head>
|
8
8
|
<body>
|
9
9
|
<h1>Flog Results</h1>
|
10
|
+
<a href="index.html">back to menu</a>
|
10
11
|
<p><a href='http://ruby.sadi.st/Flog.html'>Flog</a> measures code complexity.</p>
|
11
12
|
<h2>Total Flog score for all methods: <%= @flog[:total]%></h2>
|
12
13
|
<h2>Average Flog score for all methods: <%= @flog[:average]%></h2>
|
@@ -20,7 +21,7 @@
|
|
20
21
|
</tr>
|
21
22
|
<% @flog[:pages].each do |page| %>
|
22
23
|
<tr>
|
23
|
-
<td><%= page[:path] %></td>
|
24
|
+
<td><a href="#<%= page[:path].gsub(/[^a-z]+/, '_') %>"><%= page[:path] %></a></td>
|
24
25
|
<td><%= page[:score].round %></td>
|
25
26
|
<td><%= page[:scanned_methods].length %></td>
|
26
27
|
<td><%= page[:average_score].round %></td>
|
@@ -30,7 +31,7 @@
|
|
30
31
|
</table>
|
31
32
|
|
32
33
|
<% @flog[:pages].each do |page| %>
|
33
|
-
<h2><%= page[:path] %></h2>
|
34
|
+
<h2 id="<%= page[:path].gsub(/[^a-z]+/, '_') %>"><%= page[:path] %></h2>
|
34
35
|
<% page[:scanned_methods].each do |sm| %>
|
35
36
|
<p><%= sm[:name] %></p>
|
36
37
|
<table>
|
@@ -8,6 +8,7 @@
|
|
8
8
|
|
9
9
|
<body>
|
10
10
|
<h1>Rcov Code Coverage Results</h1>
|
11
|
+
<a href="index.html">back to menu</a>
|
11
12
|
<p>C0 code coverage information.</p>
|
12
13
|
<p>Total Coverage: <%= @rcov.delete(:global_percent_run) %>% </p>
|
13
14
|
<table>
|
@@ -16,17 +17,17 @@
|
|
16
17
|
<th>Percent run</th>
|
17
18
|
</tr>
|
18
19
|
<% count = 0 %>
|
19
|
-
<% @rcov.
|
20
|
+
<% @rcov.sort_by{|k,v| v[:percent_run]}.each do |e| %>
|
20
21
|
<tr>
|
21
|
-
<td><%=
|
22
|
-
<td><%=
|
22
|
+
<td><a href="#<%= e[0].gsub(/[^a-z]+/, '_') %>"><%= e[0] %></a></td>
|
23
|
+
<td><%= e[1][:percent_run] %></td>
|
23
24
|
</tr>
|
24
25
|
<% count += 1 %>
|
25
26
|
<% end %>
|
26
27
|
</table>
|
27
28
|
|
28
29
|
<% @rcov.each_pair do |fname, file| %>
|
29
|
-
<h2> <%= fname %></h2>
|
30
|
+
<h2 id="<%= fname.gsub(/[^a-z]+/, '_') %>"> <%= fname %></h2>
|
30
31
|
<table class="rcov_code">
|
31
32
|
<% file[:lines].each do |line| %>
|
32
33
|
<tr>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
require 'erb'
|
3
3
|
|
4
4
|
describe MetricFu::Template do
|
@@ -36,7 +36,7 @@ describe MetricFu::Template do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
describe 'if the template does not exist' do
|
39
|
-
it 'should return false' do
|
39
|
+
it 'should return false' do
|
40
40
|
File.should_receive(:exist?).with(@section).and_return(false)
|
41
41
|
result = @template.send(:template_exists?, @section)
|
42
42
|
result.should be_false
|
@@ -82,27 +82,48 @@ describe MetricFu::Template do
|
|
82
82
|
result.should == 'css contents'
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
describe "#link_to_filename " do
|
87
87
|
describe "when on OS X" do
|
88
88
|
before(:each) do
|
89
89
|
config = mock("configuration")
|
90
|
-
config.
|
90
|
+
config.stub!(:platform).and_return('universal-darwin-9.0')
|
91
91
|
MetricFu.stub!(:configuration).and_return(config)
|
92
|
-
File.should_receive(:expand_path).and_return('filename')
|
93
92
|
end
|
94
93
|
|
95
94
|
it 'should return a textmate protocol link' do
|
96
|
-
|
97
|
-
result = @template.send(:link_to_filename,
|
95
|
+
File.stub!(:expand_path).with('filename').and_return('/expanded/filename')
|
96
|
+
result = @template.send(:link_to_filename, 'filename')
|
97
|
+
result.should eql("<a href='txmt://open/?url=file://" \
|
98
|
+
+ "/expanded/filename'>filename</a>")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should do the right thing with a filename that starts with a slash" do
|
102
|
+
File.stub!(:expand_path).with('filename').and_return('/expanded/filename')
|
103
|
+
result = @template.send(:link_to_filename, '/filename')
|
98
104
|
result.should eql("<a href='txmt://open/?url=file://" \
|
99
|
-
+ "filename
|
105
|
+
+ "/expanded/filename'>/filename</a>")
|
100
106
|
end
|
101
107
|
|
108
|
+
it "should include a line number" do
|
109
|
+
File.stub!(:expand_path).with('filename').and_return('/expanded/filename')
|
110
|
+
result = @template.send(:link_to_filename, 'filename', 6)
|
111
|
+
result.should eql("<a href='txmt://open/?url=file://" \
|
112
|
+
+ "/expanded/filename&line=6'>filename:6</a>")
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "and given link text" do
|
116
|
+
it "should use the submitted link text" do
|
117
|
+
File.stub!(:expand_path).with('filename').and_return('/expanded/filename')
|
118
|
+
result = @template.send(:link_to_filename, 'filename', 6, 'link content')
|
119
|
+
result.should eql("<a href='txmt://open/?url=file://" \
|
120
|
+
+ "/expanded/filename&line=6'>link content</a>")
|
121
|
+
end
|
122
|
+
end
|
102
123
|
end
|
103
124
|
|
104
125
|
describe "when on other platforms" do
|
105
|
-
before(:each) do
|
126
|
+
before(:each) do
|
106
127
|
config = mock("configuration")
|
107
128
|
config.should_receive(:platform).and_return('other')
|
108
129
|
MetricFu.stub!(:configuration).and_return(config)
|
@@ -110,9 +131,9 @@ describe MetricFu::Template do
|
|
110
131
|
end
|
111
132
|
|
112
133
|
it 'should return a file protocol link' do
|
113
|
-
name = "filename"
|
134
|
+
name = "filename"
|
114
135
|
result = @template.send(:link_to_filename, name)
|
115
|
-
result.should == "<a href='file://filename'>filename
|
136
|
+
result.should == "<a href='file://filename'>filename</a>"
|
116
137
|
end
|
117
138
|
end
|
118
139
|
end
|
@@ -122,15 +143,15 @@ describe MetricFu::Template do
|
|
122
143
|
first_val = "first"
|
123
144
|
second_val = "second"
|
124
145
|
iter = 2
|
125
|
-
result = @template.send(:cycle, first_val, second_val, iter)
|
146
|
+
result = @template.send(:cycle, first_val, second_val, iter)
|
126
147
|
result.should == first_val
|
127
148
|
end
|
128
149
|
|
129
150
|
it 'should return the second_value passed if iteration passed is odd' do
|
130
151
|
first_val = "first"
|
131
152
|
second_val = "second"
|
132
|
-
iter = 1
|
133
|
-
result = @template.send(:cycle, first_val, second_val, iter)
|
153
|
+
iter = 1
|
154
|
+
result = @template.send(:cycle, first_val, second_val, iter)
|
134
155
|
result.should == second_val
|
135
156
|
end
|
136
157
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
3
|
describe MetricFu::Configuration do
|
4
4
|
|
@@ -129,7 +129,7 @@ describe MetricFu::Configuration do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'should set @template_class to StandardTemplate' do
|
132
|
-
template_class.should ==
|
132
|
+
template_class.should == AwesomeTemplate
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
|
@@ -170,7 +170,7 @@ describe MetricFu::Configuration do
|
|
170
170
|
"--no-color",
|
171
171
|
"--profile",
|
172
172
|
"--rails",
|
173
|
-
"--exclude /gems/,/Library/,spec"]}' do
|
173
|
+
"--exclude /gems/,/Library/,/usr/,spec"]}' do
|
174
174
|
@config.instance_variable_get(:@rcov).
|
175
175
|
should == { :test_files => ['test/**/*_test.rb',
|
176
176
|
'spec/**/*_spec.rb'],
|
@@ -180,7 +180,7 @@ describe MetricFu::Configuration do
|
|
180
180
|
"--no-color",
|
181
181
|
"--profile",
|
182
182
|
"--rails",
|
183
|
-
"--exclude /gems/,/Library/,spec"]}
|
183
|
+
"--exclude /gems/,/Library/,/usr/,spec"]}
|
184
184
|
end
|
185
185
|
|
186
186
|
it 'should set @saikuro to { :output_directory => @scratch_directory + "/saikuro",
|