jscruggs-metric_fu 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +6 -2
- data/lib/generators/flog.rb +8 -1
- data/spec/generators/flog_spec.rb +12 -1
- 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
- metadata +7 -1
data/HISTORY
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
=== MetricFu 1.1.1 / 2009-6-29
|
2
|
+
|
3
|
+
* Fix for empty flog files
|
4
|
+
|
1
5
|
=== MetricFu 1.1.0 / 2009-6-22
|
2
6
|
|
3
|
-
* Flog, flay, reek, roodi, and rcov reports now graph progress over time. Well done Nick
|
4
|
-
* 'Awesome' template has been brought in so that reports look 90% less 'ghetto.' Also done by Nick
|
7
|
+
* Flog, flay, reek, roodi, and rcov reports now graph progress over time. Well done Nick Quaranto and Edouard Brière.
|
8
|
+
* 'Awesome' template has been brought in so that reports look 90% less 'ghetto.' Also done by Nick Quaranto and Edouard Brière.
|
5
9
|
* Added links to TextMate (which keep getting removed. Probably by me. Sorry.) -- David Chelimsky
|
6
10
|
* Fixed a bug for scratch files which have a size of 0 -- Kevin Hall
|
7
11
|
* Changed gem dependencies from install-time in gemspec to runtime when each of the generators is loaded. This allows use of github gems (i.e. relevance-rcov instead of rcov) and also allows you to install only the gems for the metrics you plan on using. -- Alex Rothenberg
|
data/lib/generators/flog.rb
CHANGED
@@ -64,10 +64,17 @@ module MetricFu
|
|
64
64
|
total_flog_score = @pages.inject(0) {|total, page| total += page.score}
|
65
65
|
sorted_pages = @pages.sort_by {|page| page.score }.reverse
|
66
66
|
{:flog => { :total => total_flog_score,
|
67
|
-
:average =>
|
67
|
+
:average => average_score(total_flog_score, number_of_methods),
|
68
68
|
:pages => sorted_pages.map {|page| page.to_h}}}
|
69
69
|
end
|
70
70
|
|
71
|
+
private
|
72
|
+
|
73
|
+
def average_score(total_flog_score, number_of_methods)
|
74
|
+
return 0 if total_flog_score == 0
|
75
|
+
round_to_tenths(total_flog_score/number_of_methods)
|
76
|
+
end
|
77
|
+
|
71
78
|
def flog_results
|
72
79
|
Dir.glob("#{metric_directory}/**/*.txt")
|
73
80
|
end
|
@@ -178,7 +178,7 @@ describe Flog do
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
-
describe "to_h function" do
|
181
|
+
describe "to_h function with results" do
|
182
182
|
before :each do
|
183
183
|
MetricFu::Configuration.run {}
|
184
184
|
File.stub!(:directory?).and_return(true)
|
@@ -205,4 +205,15 @@ describe Flog do
|
|
205
205
|
@flog_hash[:flog][:pages].first[:path].should == "/app/controllers/user_controller.rb"
|
206
206
|
end
|
207
207
|
end
|
208
|
+
|
209
|
+
describe "to_h function with zero total" do
|
210
|
+
it "should not blow up" do
|
211
|
+
MetricFu::Configuration.run {}
|
212
|
+
File.stub!(:directory?).and_return(true)
|
213
|
+
flog = MetricFu::Flog.new('base_dir')
|
214
|
+
flog.should_receive(:open).and_return("") # some sort of empty or unparsable file
|
215
|
+
Dir.should_receive(:glob).and_return(["empty_file.txt"])
|
216
|
+
flog.analyze
|
217
|
+
end
|
218
|
+
end
|
208
219
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
describe MetricFu::FlogGrapher do
|
3
|
+
it "should not fall over when given empty results" do
|
4
|
+
MetricFu::Configuration.run {}
|
5
|
+
|
6
|
+
gruff_line = Gruff::Line.new(MetricFu.graph_size)
|
7
|
+
gruff_line.stub!(:write)
|
8
|
+
Gruff::Line.stub!(:new).and_return(gruff_line)
|
9
|
+
|
10
|
+
grapher = FlogGrapher.new()
|
11
|
+
metrics_hash = {:flog => {:average => 0, :pages => [], :total => 0}}
|
12
|
+
grapher.get_metrics(metrics_hash ,"20090629")
|
13
|
+
grapher.graph!
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
-- START --
|
2
|
+
Type:Global Name: Complexity:0 Lines:1
|
3
|
+
-- END --
|
4
|
+
-- START SessionsController --
|
5
|
+
Type:Class Name:SessionsController Complexity:6 Lines:40
|
6
|
+
Type:Def Name:new Complexity:2 Lines:2
|
7
|
+
Type:Def Name:create Complexity:2 Lines:19
|
8
|
+
Type:Def Name:destroy Complexity:1 Lines:4
|
9
|
+
Type:Def Name:note_failed_signin Complexity:1 Lines:3
|
10
|
+
-- END SessionsController --
|
@@ -0,0 +1,16 @@
|
|
1
|
+
-- START UsersController --
|
2
|
+
Type:Class Name:UsersController Complexity:25 Lines:111
|
3
|
+
Type:Def Name:signup Complexity:1 Lines:3
|
4
|
+
Type:Def Name:new Complexity:1 Lines:2
|
5
|
+
Type:Def Name:edit Complexity:1 Lines:3
|
6
|
+
Type:Def Name:update Complexity:2 Lines:8
|
7
|
+
Type:Def Name:index Complexity:1 Lines:2
|
8
|
+
Type:Def Name:create Complexity:4 Lines:15
|
9
|
+
Type:Def Name:thank_you Complexity:2 Lines:10
|
10
|
+
Type:Def Name:destroy Complexity:1 Lines:3
|
11
|
+
Type:Def Name:add_primary_site Complexity:1 Lines:4
|
12
|
+
Type:Def Name:users_have_changed Complexity:3 Lines:8
|
13
|
+
Type:Def Name:after_create_page Complexity:2 Lines:6
|
14
|
+
Type:Def Name:sanitize_params Complexity:3 Lines:3
|
15
|
+
Type:Def Name:authorize_user Complexity:3 Lines:5
|
16
|
+
-- END UsersController --
|
@@ -0,0 +1,155 @@
|
|
1
|
+
<html><head><title>Index for cyclomatic complexity</title></head>
|
2
|
+
<style>
|
3
|
+
body {
|
4
|
+
margin: 20px;
|
5
|
+
padding: 0;
|
6
|
+
font-size: 12px;
|
7
|
+
font-family: bitstream vera sans, verdana, arial, sans serif;
|
8
|
+
background-color: #efefef;
|
9
|
+
}
|
10
|
+
|
11
|
+
table {
|
12
|
+
border-collapse: collapse;
|
13
|
+
/*border-spacing: 0;*/
|
14
|
+
border: 1px solid #666;
|
15
|
+
background-color: #fff;
|
16
|
+
margin-bottom: 20px;
|
17
|
+
}
|
18
|
+
|
19
|
+
table, th, th+th, td, td+td {
|
20
|
+
border: 1px solid #ccc;
|
21
|
+
}
|
22
|
+
|
23
|
+
table th {
|
24
|
+
font-size: 12px;
|
25
|
+
color: #fc0;
|
26
|
+
padding: 4px 0;
|
27
|
+
background-color: #336;
|
28
|
+
}
|
29
|
+
|
30
|
+
th, td {
|
31
|
+
padding: 4px 10px;
|
32
|
+
}
|
33
|
+
|
34
|
+
td {
|
35
|
+
font-size: 13px;
|
36
|
+
}
|
37
|
+
|
38
|
+
.class_name {
|
39
|
+
font-size: 17px;
|
40
|
+
margin: 20px 0 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
.class_complexity {
|
44
|
+
margin: 0 auto;
|
45
|
+
}
|
46
|
+
|
47
|
+
.class_complexity>.class_complexity {
|
48
|
+
margin: 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
.class_total_complexity, .class_total_lines, .start_token_count, .file_count {
|
52
|
+
font-size: 13px;
|
53
|
+
font-weight: bold;
|
54
|
+
}
|
55
|
+
|
56
|
+
.class_total_complexity, .class_total_lines {
|
57
|
+
color: #c00;
|
58
|
+
}
|
59
|
+
|
60
|
+
.start_token_count, .file_count {
|
61
|
+
color: #333;
|
62
|
+
}
|
63
|
+
|
64
|
+
.warning {
|
65
|
+
background-color: yellow;
|
66
|
+
}
|
67
|
+
|
68
|
+
.error {
|
69
|
+
background-color: #f00;
|
70
|
+
}
|
71
|
+
</style>
|
72
|
+
|
73
|
+
<body>
|
74
|
+
<h1>Index for cyclomatic complexity</h1>
|
75
|
+
<h2 class="class_name">Errors and Warnings</h2>
|
76
|
+
<table width="100%" border="1">
|
77
|
+
<tr><th>Class</th><th>Method</th><th>Complexity</th></tr>
|
78
|
+
|
79
|
+
<tr><td><a href="./app/controllers/activity_reports_controller.rb_cyclo.html">ActivityReportsController</a></td><td>authorize_user</td>
|
80
|
+
<td class="warning">6</td></tr>
|
81
|
+
<tr><td><a href="./app/controllers/primary_sites_controller.rb_cyclo.html">PrimarySitesController</a></td><td>create</td>
|
82
|
+
<td class="warning">5</td></tr>
|
83
|
+
<tr><td><a href="./app/controllers/primary_sites_controller.rb_cyclo.html">PrimarySitesController</a></td><td>save_link_targets</td>
|
84
|
+
<td class="warning">5</td></tr>
|
85
|
+
<tr><td><a href="./app/models/link_target.rb_cyclo.html">LinkTarget</a></td><td>update_backlink_status</td>
|
86
|
+
<td class="warning">5</td></tr>
|
87
|
+
</table>
|
88
|
+
<hr/>
|
89
|
+
<h2 class="class_name">Analyzed Files</h2>
|
90
|
+
<ul>
|
91
|
+
<li>
|
92
|
+
<p class="file_name"><a href="./app/models/user.rb_cyclo.html">app/models/user.rb</a>
|
93
|
+
</li>
|
94
|
+
<li>
|
95
|
+
<p class="file_name"><a href="./app/models/subscriber.rb_cyclo.html">app/models/subscriber.rb</a>
|
96
|
+
</li>
|
97
|
+
<li>
|
98
|
+
<p class="file_name"><a href="./app/models/primary_site.rb_cyclo.html">app/models/primary_site.rb</a>
|
99
|
+
</li>
|
100
|
+
<li>
|
101
|
+
<p class="file_name"><a href="./app/models/link_target.rb_cyclo.html">app/models/link_target.rb</a>
|
102
|
+
</li>
|
103
|
+
<li>
|
104
|
+
<p class="file_name"><a href="./app/models/comparison_site.rb_cyclo.html">app/models/comparison_site.rb</a>
|
105
|
+
</li>
|
106
|
+
<li>
|
107
|
+
<p class="file_name"><a href="./app/models/backlink_crawl_status.rb_cyclo.html">app/models/backlink_crawl_status.rb</a>
|
108
|
+
</li>
|
109
|
+
<li>
|
110
|
+
<p class="file_name"><a href="./app/models/backlink_crawl_notifier.rb_cyclo.html">app/models/backlink_crawl_notifier.rb</a>
|
111
|
+
</li>
|
112
|
+
<li>
|
113
|
+
<p class="file_name"><a href="./app/models/activity_report_measure.rb_cyclo.html">app/models/activity_report_measure.rb</a>
|
114
|
+
</li>
|
115
|
+
<li>
|
116
|
+
<p class="file_name"><a href="./app/models/activity_report.rb_cyclo.html">app/models/activity_report.rb</a>
|
117
|
+
</li>
|
118
|
+
<li>
|
119
|
+
<p class="file_name"><a href="./app/helpers/users_helper.rb_cyclo.html">app/helpers/users_helper.rb</a>
|
120
|
+
</li>
|
121
|
+
<li>
|
122
|
+
<p class="file_name"><a href="./app/helpers/sessions_helper.rb_cyclo.html">app/helpers/sessions_helper.rb</a>
|
123
|
+
</li>
|
124
|
+
<li>
|
125
|
+
<p class="file_name"><a href="./app/helpers/primary_sites_helper.rb_cyclo.html">app/helpers/primary_sites_helper.rb</a>
|
126
|
+
</li>
|
127
|
+
<li>
|
128
|
+
<p class="file_name"><a href="./app/helpers/link_targets_helper.rb_cyclo.html">app/helpers/link_targets_helper.rb</a>
|
129
|
+
</li>
|
130
|
+
<li>
|
131
|
+
<p class="file_name"><a href="./app/helpers/application_helper.rb_cyclo.html">app/helpers/application_helper.rb</a>
|
132
|
+
</li>
|
133
|
+
<li>
|
134
|
+
<p class="file_name"><a href="./app/controllers/users_controller.rb_cyclo.html">app/controllers/users_controller.rb</a>
|
135
|
+
</li>
|
136
|
+
<li>
|
137
|
+
<p class="file_name"><a href="./app/controllers/sessions_controller.rb_cyclo.html">app/controllers/sessions_controller.rb</a>
|
138
|
+
</li>
|
139
|
+
<li>
|
140
|
+
<p class="file_name"><a href="./app/controllers/primary_sites_controller.rb_cyclo.html">app/controllers/primary_sites_controller.rb</a>
|
141
|
+
</li>
|
142
|
+
<li>
|
143
|
+
<p class="file_name"><a href="./app/controllers/link_targets_controller.rb_cyclo.html">app/controllers/link_targets_controller.rb</a>
|
144
|
+
</li>
|
145
|
+
<li>
|
146
|
+
<p class="file_name"><a href="./app/controllers/bookmarklet_integration_controller.rb_cyclo.html">app/controllers/bookmarklet_integration_controller.rb</a>
|
147
|
+
</li>
|
148
|
+
<li>
|
149
|
+
<p class="file_name"><a href="./app/controllers/application.rb_cyclo.html">app/controllers/application.rb</a>
|
150
|
+
</li>
|
151
|
+
<li>
|
152
|
+
<p class="file_name"><a href="./app/controllers/activity_reports_controller.rb_cyclo.html">app/controllers/activity_reports_controller.rb</a>
|
153
|
+
</li>
|
154
|
+
</ul>
|
155
|
+
</body></html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
-- START Mod --
|
2
|
+
Type:Module Name:Mod Complexity:2 Lines:7
|
3
|
+
Type:Def Name:self.included Complexity:2 Lines:5
|
4
|
+
-- START --
|
5
|
+
Type:Class Name: Complexity:0 Lines:1
|
6
|
+
-- END --
|
7
|
+
-- END Mod --
|
8
|
+
-- START Thing --
|
9
|
+
Type:Class Name:Thing Complexity:0 Lines:2
|
10
|
+
-- END Thing --
|
data/spec/spec.opts
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jscruggs-metric_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Scruggs
|
@@ -170,4 +170,10 @@ test_files:
|
|
170
170
|
- spec/generators/reek_spec.rb
|
171
171
|
- spec/generators/saikuro_spec.rb
|
172
172
|
- spec/generators/stats_spec.rb
|
173
|
+
- spec/graphs/flog_grapher_spec.rb
|
174
|
+
- spec/resources/saikuro/app/controllers/sessions_controller.rb_cyclo.html
|
175
|
+
- spec/resources/saikuro/app/controllers/users_controller.rb_cyclo.html
|
176
|
+
- spec/resources/saikuro/index_cyclo.html
|
177
|
+
- spec/resources/saikuro_sfiles/thing.rb_cyclo.html
|
178
|
+
- spec/spec.opts
|
173
179
|
- spec/spec_helper.rb
|