metric_fu 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +7 -1
- data/lib/base/base_template.rb +1 -0
- data/lib/base/generator.rb +1 -0
- data/lib/graphs/engines/gchart.rb +18 -0
- data/lib/graphs/flay_grapher.rb +6 -8
- data/lib/graphs/flog_grapher.rb +9 -10
- data/lib/graphs/rails_best_practices_grapher.rb +6 -12
- data/lib/graphs/rcov_grapher.rb +6 -8
- data/lib/graphs/reek_grapher.rb +15 -17
- data/lib/graphs/roodi_grapher.rb +6 -8
- data/lib/graphs/stats_grapher.rb +7 -10
- data/spec/base/configuration_spec.rb +5 -0
- data/spec/graphs/engines/gchart_spec.rb +18 -1
- data/spec/graphs/flay_grapher_spec.rb +35 -16
- data/spec/graphs/flog_grapher_spec.rb +46 -6
- data/spec/graphs/rcov_grapher_spec.rb +35 -16
- data/spec/graphs/reek_grapher_spec.rb +44 -26
- data/spec/graphs/roodi_grapher_spec.rb +35 -16
- data/spec/resources/yml/20090630.yml +10 -1
- metadata +4 -4
data/HISTORY
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
=== MetricFu 1.5.
|
1
|
+
=== MetricFu 1.5.1 / 2010-7-28
|
2
|
+
|
3
|
+
* Patch that allows graphers to skip dates that didn't generate metrics for that graph (GitHub Issue #20). - Chris Griego
|
4
|
+
* Fixed bug where if you try and use the gchart grapher with the rails_best_practices metric, it blows up (GitHub Issue #23). - Chris Griego
|
5
|
+
* Fixed 'If coverage is 0% metric_fu will explode' bug (GitHub Issue #6). - Stew Welbourne
|
6
|
+
|
7
|
+
=== MetricFu 1.5.0 / 2010-7-27
|
2
8
|
|
3
9
|
* Fixed bug where Flay results were not being reported. Had to remove the ability to remove selected files from flay processing (undocumented feature that may go away soon if it keeps causing problems).
|
4
10
|
* Rewrote Flog parsing/processing to use Flog programmatically. Note: the yaml output for Flog has changed significantly - Pages have now become MethodContainers. This probably doesn't matter to you if you are not consuming the metric_fu yaml output.
|
data/lib/base/base_template.rb
CHANGED
data/lib/base/generator.rb
CHANGED
@@ -136,4 +136,22 @@ module MetricFu
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
+
class RailsBestPracticesGchartGrapher < RailsBestPracticesGrapher
|
140
|
+
def graph!
|
141
|
+
determine_y_axis_scale(@rails_best_practices_count)
|
142
|
+
url = Gchart.line(
|
143
|
+
:size => GCHART_GRAPH_SIZE,
|
144
|
+
:title => URI.escape("Rails Best Practices: design problems"),
|
145
|
+
:data => self.rails_best_practices_count,
|
146
|
+
:bar_colors => COLORS[0..1],
|
147
|
+
:legend => ['Problems'],
|
148
|
+
:custom => "chdlp=t",
|
149
|
+
:max_value => @max_value,
|
150
|
+
:axis_with_labels => 'x,y',
|
151
|
+
:axis_labels => [@labels.values, @yaxis],
|
152
|
+
:format => 'file',
|
153
|
+
:filename => File.join(MetricFu.output_directory, 'rails_best_practices.png')
|
154
|
+
)
|
155
|
+
end
|
156
|
+
end
|
139
157
|
end
|
data/lib/graphs/flay_grapher.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
module MetricFu
|
2
|
-
|
3
2
|
class FlayGrapher < Grapher
|
4
|
-
|
5
3
|
attr_accessor :flay_score, :labels
|
6
|
-
|
4
|
+
|
7
5
|
def initialize
|
8
6
|
super
|
9
7
|
@flay_score = []
|
10
8
|
@labels = {}
|
11
9
|
end
|
12
|
-
|
10
|
+
|
13
11
|
def get_metrics(metrics, date)
|
14
|
-
|
15
|
-
|
12
|
+
if metrics && metrics[:flay]
|
13
|
+
@flay_score.push(metrics[:flay][:total_score].to_i)
|
14
|
+
@labels.update( { @labels.size => date })
|
15
|
+
end
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
data/lib/graphs/flog_grapher.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
module MetricFu
|
2
|
-
|
3
2
|
class FlogGrapher < Grapher
|
4
|
-
|
5
3
|
attr_accessor :flog_average, :labels, :top_five_percent_average
|
6
|
-
|
4
|
+
|
7
5
|
def initialize
|
8
6
|
super
|
9
7
|
@flog_average = []
|
10
8
|
@labels = {}
|
11
9
|
@top_five_percent_average =[]
|
12
10
|
end
|
13
|
-
|
11
|
+
|
14
12
|
def get_metrics(metrics, date)
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
if metrics && metrics[:flog]
|
14
|
+
@top_five_percent_average.push(calc_top_five_percent_average(metrics))
|
15
|
+
@flog_average.push(metrics[:flog][:average])
|
16
|
+
@labels.update( { @labels.size => date })
|
17
|
+
end
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
private
|
21
|
-
|
21
|
+
|
22
22
|
def calc_top_five_percent_average(metrics)
|
23
23
|
return calc_top_five_percent_average_legacy(metrics) if metrics[:flog][:pages]
|
24
24
|
|
@@ -54,5 +54,4 @@ module MetricFu
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
58
57
|
end
|
@@ -1,25 +1,19 @@
|
|
1
1
|
module MetricFu
|
2
|
-
|
3
2
|
class RailsBestPracticesGrapher < Grapher
|
4
|
-
|
5
3
|
attr_accessor :rails_best_practices_count, :labels
|
6
|
-
|
4
|
+
|
7
5
|
def initialize
|
8
6
|
super
|
9
7
|
@rails_best_practices_count = []
|
10
8
|
@labels = {}
|
11
9
|
end
|
12
|
-
|
10
|
+
|
13
11
|
def get_metrics(metrics, date)
|
14
|
-
if metrics
|
15
|
-
size = metrics[:rails_best_practices][:problems].size
|
16
|
-
|
17
|
-
size
|
12
|
+
if metrics && metrics[:rails_best_practices]
|
13
|
+
size = (metrics[:rails_best_practices][:problems] || []).size
|
14
|
+
@rails_best_practices_count.push(size)
|
15
|
+
@labels.update( { @labels.size => date })
|
18
16
|
end
|
19
|
-
@rails_best_practices_count.push(size)
|
20
|
-
@labels.update( { @labels.size => date })
|
21
17
|
end
|
22
|
-
|
23
18
|
end
|
24
|
-
|
25
19
|
end
|
data/lib/graphs/rcov_grapher.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
module MetricFu
|
2
|
-
|
3
2
|
class RcovGrapher < Grapher
|
4
|
-
|
5
3
|
attr_accessor :rcov_percent, :labels
|
6
|
-
|
4
|
+
|
7
5
|
def initialize
|
8
6
|
super
|
9
7
|
self.rcov_percent = []
|
10
8
|
self.labels = {}
|
11
9
|
end
|
12
|
-
|
10
|
+
|
13
11
|
def get_metrics(metrics, date)
|
14
|
-
|
15
|
-
|
12
|
+
if metrics && metrics[:rcov]
|
13
|
+
self.rcov_percent.push(metrics[:rcov][:global_percent_run])
|
14
|
+
self.labels.update( { self.labels.size => date })
|
15
|
+
end
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
data/lib/graphs/reek_grapher.rb
CHANGED
@@ -1,32 +1,30 @@
|
|
1
1
|
module MetricFu
|
2
|
-
|
3
2
|
class ReekGrapher < Grapher
|
4
|
-
|
5
3
|
attr_accessor :reek_count, :labels
|
6
|
-
|
4
|
+
|
7
5
|
def initialize
|
8
6
|
super
|
9
7
|
@reek_count = {}
|
10
8
|
@labels = {}
|
11
9
|
end
|
12
|
-
|
10
|
+
|
13
11
|
def get_metrics(metrics, date)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@reek_count[code_smell[:type]][counter]
|
23
|
-
|
24
|
-
|
12
|
+
if metrics && metrics[:reek]
|
13
|
+
counter = @labels.size
|
14
|
+
@labels.update( { @labels.size => date })
|
15
|
+
|
16
|
+
metrics[:reek][:matches].each do |reek_chunk|
|
17
|
+
reek_chunk[:code_smells].each do |code_smell|
|
18
|
+
# speaking of code smell...
|
19
|
+
@reek_count[code_smell[:type]] = [] if @reek_count[code_smell[:type]].nil?
|
20
|
+
if @reek_count[code_smell[:type]][counter].nil?
|
21
|
+
@reek_count[code_smell[:type]][counter] = 1
|
22
|
+
else
|
23
|
+
@reek_count[code_smell[:type]][counter] += 1
|
24
|
+
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
data/lib/graphs/roodi_grapher.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
module MetricFu
|
2
|
-
|
3
2
|
class RoodiGrapher < Grapher
|
4
|
-
|
5
3
|
attr_accessor :roodi_count, :labels
|
6
|
-
|
4
|
+
|
7
5
|
def initialize
|
8
6
|
super
|
9
7
|
@roodi_count = []
|
10
8
|
@labels = {}
|
11
9
|
end
|
12
|
-
|
10
|
+
|
13
11
|
def get_metrics(metrics, date)
|
14
|
-
|
15
|
-
|
12
|
+
if metrics && metrics[:roodi]
|
13
|
+
@roodi_count.push(metrics[:roodi][:problems].size)
|
14
|
+
@labels.update( { @labels.size => date })
|
15
|
+
end
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
19
|
-
|
20
18
|
end
|
data/lib/graphs/stats_grapher.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
|
-
|
2
1
|
module MetricFu
|
3
|
-
|
4
2
|
class StatsGrapher < Grapher
|
5
|
-
|
6
3
|
attr_accessor :loc_counts, :lot_counts, :labels
|
7
|
-
|
4
|
+
|
8
5
|
def initialize
|
9
6
|
super
|
10
7
|
self.loc_counts = []
|
11
8
|
self.lot_counts = []
|
12
9
|
self.labels = {}
|
13
10
|
end
|
14
|
-
|
11
|
+
|
15
12
|
def get_metrics(metrics, date)
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
if metrics && metrics[:stats]
|
14
|
+
self.loc_counts.push(metrics[:stats][:codeLOC].to_i)
|
15
|
+
self.lot_counts.push(metrics[:stats][:testLOC].to_i)
|
16
|
+
self.labels.update( { self.labels.size => date })
|
17
|
+
end
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
22
|
-
|
23
20
|
end
|
@@ -115,6 +115,11 @@ describe MetricFu::Configuration do
|
|
115
115
|
should == {}
|
116
116
|
end
|
117
117
|
|
118
|
+
it 'should set @rails_best_practices to {}' do
|
119
|
+
@config.instance_variable_get(:@rails_best_practices).
|
120
|
+
should == {}
|
121
|
+
end
|
122
|
+
|
118
123
|
it 'should set @rcov to { :test_files => ["test/**/*_test.rb",
|
119
124
|
"spec/**/*_spec.rb"]
|
120
125
|
:rcov_opts => ["--sort coverage",
|
@@ -135,5 +135,22 @@ describe "Gchart graphers" do
|
|
135
135
|
grapher.graph!
|
136
136
|
end
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
|
+
describe "RailsBestPracticesGchartGrapher graph! method" do
|
140
|
+
it "should set static values for graph" do
|
141
|
+
grapher = RailsBestPracticesGchartGrapher.new
|
142
|
+
expected = {
|
143
|
+
:size => MetricFu::GchartGrapher::GCHART_GRAPH_SIZE,
|
144
|
+
:title => URI.escape("Rails Best Practices: design problems"),
|
145
|
+
:bar_colors => MetricFu::GchartGrapher::COLORS[0..1],
|
146
|
+
:legend => ['Problems'],
|
147
|
+
:custom => "chdlp=t",
|
148
|
+
:axis_with_labels => 'x,y',
|
149
|
+
:format => 'file',
|
150
|
+
:filename => File.join(MetricFu.output_directory, 'rails_best_practices.png'),
|
151
|
+
}
|
152
|
+
Gchart.should_receive(:line).with(hash_including(expected))
|
153
|
+
grapher.graph!
|
154
|
+
end
|
155
|
+
end
|
139
156
|
end
|
@@ -1,37 +1,56 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
|
-
describe FlayGrapher do
|
3
|
+
describe FlayGrapher do
|
4
4
|
before :each do
|
5
5
|
@flay_grapher = MetricFu::FlayGrapher.new
|
6
6
|
MetricFu.configuration
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should respond to flay_score and labels" do
|
10
10
|
@flay_grapher.should respond_to(:flay_score)
|
11
11
|
@flay_grapher.should respond_to(:labels)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
describe "responding to #initialize" do
|
15
15
|
it "should initialise flay_score and labels" do
|
16
16
|
@flay_grapher.flay_score.should == []
|
17
17
|
@flay_grapher.labels.should == {}
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
describe "responding to #get_metrics" do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
context "when metrics were not generated" do
|
23
|
+
before(:each) do
|
24
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "metric_missing.yml")))
|
25
|
+
@date = "1/2"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not push to flay_score" do
|
29
|
+
@flay_grapher.flay_score.should_not_receive(:push)
|
30
|
+
@flay_grapher.get_metrics(@metrics, @date)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not update labels with the date" do
|
34
|
+
@flay_grapher.labels.should_not_receive(:update)
|
35
|
+
@flay_grapher.get_metrics(@metrics, @date)
|
36
|
+
end
|
30
37
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
|
39
|
+
context "when metrics have been generated" do
|
40
|
+
before(:each) do
|
41
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
42
|
+
@date = "1/2"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should push to flay_score" do
|
46
|
+
@flay_grapher.flay_score.should_receive(:push).with(476)
|
47
|
+
@flay_grapher.get_metrics(@metrics, @date)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should update labels with the date" do
|
51
|
+
@flay_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
52
|
+
@flay_grapher.get_metrics(@metrics, @date)
|
53
|
+
end
|
35
54
|
end
|
36
55
|
end
|
37
56
|
end
|
@@ -6,13 +6,13 @@ describe MetricFu::FlogGrapher do
|
|
6
6
|
@flog_grapher = MetricFu::FlogGrapher.new
|
7
7
|
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should respond to flog_total, flog_average and labels" do
|
11
11
|
@flog_grapher.should respond_to(:flog_average)
|
12
12
|
@flog_grapher.should respond_to(:labels)
|
13
13
|
@flog_grapher.should respond_to(:top_five_percent_average)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
describe "responding to #initialize" do
|
17
17
|
it "should initialize top_five_percent_average, flog_average and labels" do
|
18
18
|
@flog_grapher.flog_average.should == []
|
@@ -20,7 +20,7 @@ describe MetricFu::FlogGrapher do
|
|
20
20
|
@flog_grapher.top_five_percent_average.should == []
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
describe "responding to #get_metrics" do
|
25
25
|
before(:each) do
|
26
26
|
methods = {}
|
@@ -45,9 +45,49 @@ describe MetricFu::FlogGrapher do
|
|
45
45
|
@flog_grapher.get_metrics(@metrics, @date)
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
context "when metrics were not generated" do
|
49
|
+
before(:each) do
|
50
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "metric_missing.yml")))
|
51
|
+
@date = "1/2"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not push to top_five_percent_average" do
|
55
|
+
@flog_grapher.top_five_percent_average.should_not_receive(:push)
|
56
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not push to flog_average" do
|
60
|
+
@flog_grapher.flog_average.should_not_receive(:push)
|
61
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should not update labels with the date" do
|
65
|
+
@flog_grapher.labels.should_not_receive(:update)
|
66
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when metrics have been generated" do
|
71
|
+
before(:each) do
|
72
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
73
|
+
@date = "1/2"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should push to top_five_percent_average" do
|
77
|
+
average = (73.6 + 68.5 + 66.1 + 46.6 + 44.8 + 44.1 + 41.2 + 36.0) / 8.0
|
78
|
+
@flog_grapher.top_five_percent_average.should_receive(:push).with(average)
|
79
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should push to flog_average" do
|
83
|
+
@flog_grapher.flog_average.should_receive(:push).with(9.9)
|
84
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should update labels with the date" do
|
88
|
+
@flog_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
89
|
+
@flog_grapher.get_metrics(@metrics, @date)
|
90
|
+
end
|
51
91
|
end
|
52
92
|
end
|
53
93
|
|
@@ -1,37 +1,56 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
|
-
describe RcovGrapher do
|
3
|
+
describe RcovGrapher do
|
4
4
|
before :each do
|
5
5
|
@rcov_grapher = MetricFu::RcovGrapher.new
|
6
6
|
MetricFu.configuration
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should respond to rcov_percent and labels" do
|
10
10
|
@rcov_grapher.should respond_to(:rcov_percent)
|
11
11
|
@rcov_grapher.should respond_to(:labels)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
describe "responding to #initialize" do
|
15
15
|
it "should initialise rcov_percent and labels" do
|
16
16
|
@rcov_grapher.rcov_percent.should == []
|
17
17
|
@rcov_grapher.labels.should == {}
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
describe "responding to #get_metrics" do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
context "when metrics were not generated" do
|
23
|
+
before(:each) do
|
24
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "metric_missing.yml")))
|
25
|
+
@date = "1/2"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not push to rcov_percent" do
|
29
|
+
@rcov_grapher.rcov_percent.should_not_receive(:push)
|
30
|
+
@rcov_grapher.get_metrics(@metrics, @date)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not update labels with the date" do
|
34
|
+
@rcov_grapher.labels.should_not_receive(:update)
|
35
|
+
@rcov_grapher.get_metrics(@metrics, @date)
|
36
|
+
end
|
30
37
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
|
39
|
+
context "when metrics have been generated" do
|
40
|
+
before(:each) do
|
41
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
42
|
+
@date = "1/2"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should push to rcov_percent" do
|
46
|
+
@rcov_grapher.rcov_percent.should_receive(:push).with(49.6)
|
47
|
+
@rcov_grapher.get_metrics(@metrics, @date)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should update labels with the date" do
|
51
|
+
@rcov_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
52
|
+
@rcov_grapher.get_metrics(@metrics, @date)
|
53
|
+
end
|
35
54
|
end
|
36
55
|
end
|
37
56
|
end
|
@@ -1,47 +1,65 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
|
-
describe ReekGrapher do
|
3
|
+
describe ReekGrapher do
|
4
4
|
before :each do
|
5
5
|
@reek_grapher = MetricFu::ReekGrapher.new
|
6
6
|
MetricFu.configuration
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should respond to reek_count and labels" do
|
10
10
|
@reek_grapher.should respond_to(:reek_count)
|
11
11
|
@reek_grapher.should respond_to(:labels)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
describe "responding to #initialize" do
|
15
15
|
it "should initialise reek_count and labels" do
|
16
16
|
@reek_grapher.reek_count.should == {}
|
17
17
|
@reek_grapher.labels.should == {}
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
describe "responding to #get_metrics" do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
"Large Class" => [1]
|
38
|
-
}
|
22
|
+
context "when metrics were not generated" do
|
23
|
+
before(:each) do
|
24
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "metric_missing.yml")))
|
25
|
+
@date = "1/2"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not set a hash of code smells to reek_count" do
|
29
|
+
@reek_grapher.get_metrics(@metrics, @date)
|
30
|
+
@reek_grapher.reek_count.should == {}
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not update labels with the date" do
|
34
|
+
@reek_grapher.labels.should_not_receive(:update)
|
35
|
+
@reek_grapher.get_metrics(@metrics, @date)
|
36
|
+
end
|
39
37
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
|
39
|
+
context "when metrics have been generated" do
|
40
|
+
before(:each) do
|
41
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
42
|
+
@date = "1/2"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should set a hash of code smells to reek_count" do
|
46
|
+
@reek_grapher.get_metrics(@metrics, @date)
|
47
|
+
@reek_grapher.reek_count.should == {
|
48
|
+
"Uncommunicative Name" => [27],
|
49
|
+
"Feature Envy" => [20],
|
50
|
+
"Utility Function" => [15],
|
51
|
+
"Long Method" => [26],
|
52
|
+
"Nested Iterators" => [12],
|
53
|
+
"Control Couple" => [4],
|
54
|
+
"Duplication" => [48],
|
55
|
+
"Large Class" => [1]
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should update labels with the date" do
|
60
|
+
@reek_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
61
|
+
@reek_grapher.get_metrics(@metrics, @date)
|
62
|
+
end
|
44
63
|
end
|
45
64
|
end
|
46
|
-
|
47
65
|
end
|
@@ -1,37 +1,56 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
2
|
|
3
|
-
describe RoodiGrapher do
|
3
|
+
describe RoodiGrapher do
|
4
4
|
before :each do
|
5
5
|
@roodi_grapher = MetricFu::RoodiGrapher.new
|
6
6
|
MetricFu.configuration
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should respond to roodi_count and labels" do
|
10
10
|
@roodi_grapher.should respond_to(:roodi_count)
|
11
11
|
@roodi_grapher.should respond_to(:labels)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
describe "responding to #initialize" do
|
15
15
|
it "should initialise roodi_count and labels" do
|
16
16
|
@roodi_grapher.roodi_count.should == []
|
17
17
|
@roodi_grapher.labels.should == {}
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
describe "responding to #get_metrics" do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
context "when metrics were not generated" do
|
23
|
+
before(:each) do
|
24
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "metric_missing.yml")))
|
25
|
+
@date = "1/2"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not push to roodi_count" do
|
29
|
+
@roodi_grapher.roodi_count.should_not_receive(:push)
|
30
|
+
@roodi_grapher.get_metrics(@metrics, @date)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not update labels with the date" do
|
34
|
+
@roodi_grapher.labels.should_not_receive(:update)
|
35
|
+
@roodi_grapher.get_metrics(@metrics, @date)
|
36
|
+
end
|
30
37
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
|
39
|
+
context "when metrics have been generated" do
|
40
|
+
before(:each) do
|
41
|
+
@metrics = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "resources", "yml", "20090630.yml")))
|
42
|
+
@date = "1/2"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should push to roodi_count" do
|
46
|
+
@roodi_grapher.roodi_count.should_receive(:push).with(13)
|
47
|
+
@roodi_grapher.get_metrics(@metrics, @date)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should update labels with the date" do
|
51
|
+
@roodi_grapher.labels.should_receive(:update).with({ 0 => "1/2" })
|
52
|
+
@roodi_grapher.get_metrics(@metrics, @date)
|
53
|
+
end
|
35
54
|
end
|
36
55
|
end
|
37
56
|
end
|
@@ -7910,4 +7910,13 @@
|
|
7910
7910
|
:name: Total
|
7911
7911
|
:loc: 23373
|
7912
7912
|
:code_to_test_ratio: 0.5
|
7913
|
-
|
7913
|
+
:rails_best_practices:
|
7914
|
+
:problems:
|
7915
|
+
- :line: "17"
|
7916
|
+
:file: ./app/views/admin/testimonials/_form.html.erb
|
7917
|
+
:problem: replace instance variable with local variable
|
7918
|
+
- :line: "24,45,68,85"
|
7919
|
+
:file: ./app/controllers/admin/campaigns_controller.rb
|
7920
|
+
:problem: use before_filter for show,edit,update,destroy
|
7921
|
+
:total:
|
7922
|
+
- Found 2 errors.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metric_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 1.5.
|
9
|
+
- 1
|
10
|
+
version: 1.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jake Scruggs
|
@@ -24,7 +24,7 @@ autorequire:
|
|
24
24
|
bindir: bin
|
25
25
|
cert_chain: []
|
26
26
|
|
27
|
-
date: 2010-07-
|
27
|
+
date: 2010-07-28 00:00:00 -05:00
|
28
28
|
default_executable:
|
29
29
|
dependencies:
|
30
30
|
- !ruby/object:Gem::Dependency
|