metric_fu 4.6.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.metrics +6 -0
- data/.travis.yml +6 -5
- data/CONTRIBUTING.md +15 -3
- data/Gemfile +3 -8
- data/Gemfile.devtools +3 -3
- data/HISTORY.md +23 -2
- data/README.md +42 -38
- data/checksum/metric_fu-4.6.0.gem.sha512 +1 -0
- data/gemfiles/Gemfile.travis +7 -0
- data/lib/metric_fu/cli/helper.rb +2 -1
- data/lib/metric_fu/configuration.rb +0 -2
- data/lib/metric_fu/formatter/html.rb +2 -0
- data/lib/metric_fu/formatter/syntax.rb +47 -0
- data/lib/metric_fu/gem_version.rb +44 -11
- data/lib/metric_fu/io.rb +5 -5
- data/lib/metric_fu/loader.rb +12 -5
- data/lib/metric_fu/metric.rb +10 -0
- data/lib/metric_fu/metrics/base_template.rb +2 -2
- data/lib/metric_fu/metrics/cane/cane.rb +1 -0
- data/lib/metric_fu/metrics/churn/churn.rb +16 -42
- data/lib/metric_fu/metrics/churn/init.rb +7 -1
- data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -0
- data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +1 -0
- data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +2 -0
- data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +5 -0
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +3 -0
- data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +8 -4
- data/lib/metric_fu/metrics/hotspots/hotspots.rb +11 -0
- data/lib/metric_fu/metrics/reek/reek.rb +1 -1
- data/lib/metric_fu/metrics/reek/reek_hotspot.rb +0 -1
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +1 -0
- data/lib/metric_fu/reporting/graphs/grapher.rb +0 -1
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +8 -59
- data/lib/metric_fu/run.rb +1 -1
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/bluff.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/buttons.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/default.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/integrity.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/rcov.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/reset.css +0 -0
- data/lib/metric_fu/{reporting/templates/awesome → templates}/css/syntax.css +0 -0
- data/lib/metric_fu/templates/report.html.erb +32 -0
- data/lib/metric_fu/templates/report.rb +36 -0
- data/lib/metric_fu/utility.rb +4 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +11 -2
- data/spec/cli/helper_spec.rb +33 -33
- data/spec/metric_fu/configuration_spec.rb +20 -20
- data/spec/metric_fu/data_structures/line_numbers_spec.rb +12 -11
- data/spec/metric_fu/data_structures/location_spec.rb +27 -26
- data/spec/metric_fu/formatter/html_spec.rb +18 -8
- data/spec/metric_fu/formatter/yaml_spec.rb +14 -3
- data/spec/metric_fu/formatter_spec.rb +5 -5
- data/spec/metric_fu/loader_spec.rb +1 -1
- data/spec/metric_fu/metric_spec.rb +2 -2
- data/spec/metric_fu/metrics/base_template_spec.rb +50 -50
- data/spec/metric_fu/metrics/cane/cane_spec.rb +29 -28
- data/spec/metric_fu/metrics/churn/churn_spec.rb +10 -33
- data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +9 -8
- data/spec/metric_fu/metrics/flay/flay_spec.rb +14 -13
- data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +16 -15
- data/spec/metric_fu/metrics/flog/flog_spec.rb +10 -9
- data/spec/metric_fu/metrics/generator_spec.rb +19 -19
- data/spec/metric_fu/metrics/graph_spec.rb +11 -9
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +5 -0
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +11 -6
- data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +4 -3
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +16 -10
- data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +2 -1
- data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +2 -1
- data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +8 -2
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +4 -8
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +10 -9
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +8 -7
- data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +8 -8
- data/spec/metric_fu/metrics/rcov/rcov_hotspot_spec.rb +7 -4
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +15 -14
- data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +10 -9
- data/spec/metric_fu/metrics/reek/reek_spec.rb +17 -15
- data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +9 -8
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +4 -3
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +13 -10
- data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +13 -12
- data/spec/metric_fu/metrics/stats/stats_spec.rb +16 -14
- data/spec/metric_fu/reporter_spec.rb +8 -7
- data/spec/metric_fu/reporting/graphs/grapher_spec.rb +1 -1
- data/spec/metric_fu/reporting/result_spec.rb +12 -11
- data/spec/metric_fu/run_spec.rb +24 -8
- data/spec/spec_helper.rb +1 -2
- data/spec/support/helper_methods.rb +14 -1
- metadata +124 -57
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
- data/lib/metric_fu/initial_requires.rb +0 -13
- data/lib/metric_fu/load_files.rb +0 -34
@@ -1,20 +1,21 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'flog/flog' }
|
2
3
|
|
3
4
|
describe MetricFu::FlogGenerator do
|
4
5
|
|
5
6
|
break if metric_not_activated?(:flog)
|
6
7
|
|
7
8
|
before :each do
|
8
|
-
File.
|
9
|
+
allow(File).to receive(:directory?).and_return(true)
|
9
10
|
options = MetricFu::Metric.get_metric(:flog).run_options
|
10
11
|
@flog = MetricFu::FlogGenerator.new(options)
|
11
12
|
end
|
12
13
|
|
13
14
|
describe "emit method" do
|
14
15
|
it "should look for files and flog them" do
|
15
|
-
FlogCLI.
|
16
|
-
FlogCLI.
|
17
|
-
flogger.
|
16
|
+
expect(FlogCLI).to receive(:parse_options).with(["--all","--continue"]).and_return("options")
|
17
|
+
expect(FlogCLI).to receive(:new).with("options").and_return(flogger = double('flogger'))
|
18
|
+
expect(flogger).to receive(:flog).with("lib")
|
18
19
|
@flog.emit
|
19
20
|
end
|
20
21
|
end
|
@@ -28,8 +29,8 @@ describe MetricFu::FlogGenerator do
|
|
28
29
|
second_full_method_name => '/file/location.rb:22'},
|
29
30
|
:totals => {first_full_method_name => 11.11,
|
30
31
|
second_full_method_name => 22.22})
|
31
|
-
flogger.
|
32
|
-
flogger.
|
32
|
+
expect(flogger).to receive(:calculate)
|
33
|
+
expect(flogger).to receive(:each_by_score).and_yield(
|
33
34
|
first_full_method_name, 11.11, {:branch => 11.1, :puts => 1.1}
|
34
35
|
).and_yield(
|
35
36
|
second_full_method_name, 22.22, {:branch => 22.2, :puts => 2.2}
|
@@ -37,7 +38,7 @@ describe MetricFu::FlogGenerator do
|
|
37
38
|
@flog.instance_variable_set(:@flogger, flogger)
|
38
39
|
@flog.analyze
|
39
40
|
method_containers = @flog.instance_variable_get(:@method_containers)
|
40
|
-
method_containers.size.
|
41
|
+
expect(method_containers.size).to eq(1)
|
41
42
|
|
42
43
|
expected={:methods=>{"ClassName#first_method_name" => { :path=>"/file/location.rb:11",
|
43
44
|
:score=>11.11,
|
@@ -53,7 +54,7 @@ describe MetricFu::FlogGenerator do
|
|
53
54
|
:highest_score=>22.22,
|
54
55
|
:name=>"ClassName"}
|
55
56
|
|
56
|
-
method_containers["ClassName"].to_h.
|
57
|
+
expect(method_containers["ClassName"].to_h).to eq(expected)
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -70,7 +71,7 @@ describe MetricFu::FlogGenerator do
|
|
70
71
|
:average => 7.3,
|
71
72
|
:method_containers => ['container_2', 'container_3', 'container_1']}}
|
72
73
|
|
73
|
-
@flog.to_h.
|
74
|
+
expect(@flog.to_h).to eq(expected)
|
74
75
|
end
|
75
76
|
|
76
77
|
end
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe MetricFu::Generator do
|
4
4
|
|
5
|
-
include
|
5
|
+
include TestConstruct::Helpers
|
6
6
|
|
7
7
|
|
8
8
|
class ConcreteClass < MetricFu::Generator
|
@@ -30,33 +30,33 @@ describe MetricFu::Generator do
|
|
30
30
|
describe "ConcreteClass#metric_directory" do
|
31
31
|
it "should be '{artifact_dir}/scratch/concreteclass'" do
|
32
32
|
concrete_metric = double('concrete_metric')
|
33
|
-
MetricFu::Metric.
|
34
|
-
concrete_metric.
|
33
|
+
expect(MetricFu::Metric).to receive(:get_metric).with(:concrete).and_return(concrete_metric)
|
34
|
+
expect(concrete_metric).to receive(:run_options).and_return({})
|
35
35
|
compare_paths(ConcreteClass.metric_directory, scratch_directory('concrete'))
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#metric_directory' do
|
40
40
|
it 'should return the results of ConcreteClass#metric_directory' do
|
41
|
-
ConcreteClass.
|
42
|
-
@concrete_class.metric_directory.
|
41
|
+
allow(ConcreteClass).to receive(:metric_directory).and_return('foo')
|
42
|
+
expect(@concrete_class.metric_directory).to eq('foo')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#generate_result" do
|
47
47
|
it 'should raise an error when calling #emit' do
|
48
48
|
@abstract_class = MetricFu::Generator.new
|
49
|
-
|
49
|
+
expect { @abstract_class.generate_result }.to raise_error
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'should call #analyze' do
|
53
53
|
@abstract_class = MetricFu::Generator.new
|
54
|
-
|
54
|
+
expect { @abstract_class.generate_result }.to raise_error
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should call #to_h' do
|
58
58
|
@abstract_class = MetricFu::Generator.new
|
59
|
-
|
59
|
+
expect { @abstract_class.generate_result }.to raise_error
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -64,13 +64,13 @@ describe MetricFu::Generator do
|
|
64
64
|
|
65
65
|
%w[emit analyze].each do |meth|
|
66
66
|
it "should call ##{meth}" do
|
67
|
-
@concrete_class.
|
67
|
+
expect(@concrete_class).to receive("#{meth}")
|
68
68
|
@concrete_class.generate_result
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should call #to_h" do
|
73
|
-
@concrete_class.
|
73
|
+
expect(@concrete_class).to receive(:to_h)
|
74
74
|
@concrete_class.generate_result
|
75
75
|
end
|
76
76
|
|
@@ -105,31 +105,31 @@ describe MetricFu::Generator do
|
|
105
105
|
|
106
106
|
it "should return entire pathlist given no exclude pattens" do
|
107
107
|
files = @concrete_class.remove_excluded_files(@paths)
|
108
|
-
files.
|
108
|
+
expect(files).to eq(@paths)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should filter filename at root level" do
|
112
112
|
files = @concrete_class.remove_excluded_files(@paths, ['basic.rb'])
|
113
|
-
files.
|
113
|
+
expect(files).not_to include('basic.rb')
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should remove files that are two levels deep" do
|
117
117
|
files = @concrete_class.remove_excluded_files(@paths, ['**/fake.rb'])
|
118
|
-
files.
|
118
|
+
expect(files).not_to include('lib/fake/fake.rb')
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should remove files from an excluded directory" do
|
122
122
|
files = @concrete_class.remove_excluded_files(@paths, ['lib/bad/**'])
|
123
|
-
files.
|
124
|
-
files.
|
125
|
-
files.
|
123
|
+
expect(files).not_to include('lib/bad/one.rb')
|
124
|
+
expect(files).not_to include('lib/bad/two.rb')
|
125
|
+
expect(files).not_to include('lib/bad/three.rb')
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should support shell alternation globs" do
|
129
129
|
files = @concrete_class.remove_excluded_files(@paths, ['lib/this/{ben,dan}_file.rb'])
|
130
|
-
files.
|
131
|
-
files.
|
132
|
-
files.
|
130
|
+
expect(files).not_to include('lib/this/dan_file.rb')
|
131
|
+
expect(files).not_to include('lib/this/ben_file.rb')
|
132
|
+
expect(files).to include('lib/this/avdi_file.rb')
|
133
133
|
end
|
134
134
|
|
135
135
|
end
|
@@ -5,7 +5,7 @@ describe MetricFu do
|
|
5
5
|
|
6
6
|
describe "responding to #graph" do
|
7
7
|
it "should return an instance of Graph" do
|
8
|
-
MetricFu.graph.
|
8
|
+
expect(MetricFu.graph).to be_a(Graph)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -18,25 +18,27 @@ describe MetricFu::Graph do
|
|
18
18
|
|
19
19
|
describe "setting the date on the graph" do
|
20
20
|
|
21
|
+
# TODO better test
|
21
22
|
it "should set the date once for one data point" do
|
22
23
|
metric_file = "metric_fu/tmp/_data/20101105.yml"
|
23
|
-
MetricFu::Utility.
|
24
|
-
MetricFu::Utility.
|
24
|
+
expect(MetricFu::Utility).to receive(:glob).and_return([metric_file].sort)
|
25
|
+
expect(MetricFu::Utility).to receive(:load_yaml).with(metric_file).and_return("Metrics")
|
25
26
|
double_grapher = double
|
26
|
-
double_grapher.
|
27
|
-
double_grapher.
|
27
|
+
expect(double_grapher).to receive(:get_metrics).with("Metrics", "11/5")
|
28
|
+
expect(double_grapher).to receive(:graph!)
|
28
29
|
|
29
30
|
@graph.graphers = [double_grapher]
|
30
31
|
@graph.generate
|
31
32
|
end
|
32
33
|
|
34
|
+
# TODO better test
|
33
35
|
it "should set the date when the data directory isn't in the default place" do
|
34
36
|
metric_file = "/some/kind/of/weird/directory/somebody/configured/_data/20101105.yml"
|
35
|
-
MetricFu::Utility.
|
36
|
-
MetricFu::Utility.
|
37
|
+
expect(MetricFu::Utility).to receive(:glob).and_return([metric_file].sort)
|
38
|
+
expect(MetricFu::Utility).to receive(:load_yaml).with(metric_file).and_return("Metrics")
|
37
39
|
double_grapher = double
|
38
|
-
double_grapher.
|
39
|
-
double_grapher.
|
40
|
+
expect(double_grapher).to receive(:get_metrics).with("Metrics", "11/5")
|
41
|
+
expect(double_grapher).to receive(:graph!)
|
40
42
|
|
41
43
|
@graph.graphers = [double_grapher]
|
42
44
|
@graph.generate
|
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
MetricFu.metrics_require { 'hotspots/analysis/analyzed_problems' }
|
2
3
|
|
3
4
|
describe MetricFu::HotspotAnalyzedProblems do
|
4
5
|
|
6
|
+
before do
|
7
|
+
enable_hotspots
|
8
|
+
end
|
9
|
+
|
5
10
|
def analyzed_problems(result_hash)
|
6
11
|
@analyzed_problems ||= {}
|
7
12
|
@analyzed_problems.fetch(result_hash) do
|
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
MetricFu.metrics_require { 'hotspots/analysis/analyzer_tables' }
|
2
3
|
|
3
4
|
describe MetricFu::AnalyzerTables do
|
4
5
|
|
6
|
+
before do
|
7
|
+
enable_hotspots
|
8
|
+
end
|
9
|
+
|
5
10
|
def analyzer_table(result_hash)
|
6
11
|
@analyzer_tables ||= {}
|
7
12
|
@analyzer_tables.fetch(result_hash) do
|
@@ -31,17 +36,17 @@ describe MetricFu::AnalyzerTables do
|
|
31
36
|
|
32
37
|
it "should have codeLOC" do
|
33
38
|
row = @table.find{|row| row['stat_name'] == :codeLOC}
|
34
|
-
row['stat_value'].
|
39
|
+
expect(row['stat_value']).to eq(4222)
|
35
40
|
end
|
36
41
|
|
37
42
|
it "should have testLOC" do
|
38
43
|
row = @table.find{|row| row['stat_name'] == :testLOC}
|
39
|
-
row['stat_value'].
|
44
|
+
expect(row['stat_value']).to eq(2111)
|
40
45
|
end
|
41
46
|
|
42
47
|
it "should have code_to_test_ratio" do
|
43
48
|
row = @table.find{|row| row['stat_name'] == :code_to_test_ratio}
|
44
|
-
row['stat_value'].
|
49
|
+
expect(row['stat_value']).to eq(2)
|
45
50
|
end
|
46
51
|
|
47
52
|
end
|
@@ -55,16 +60,16 @@ describe MetricFu::AnalyzerTables do
|
|
55
60
|
|
56
61
|
specify "all records should have full file_path" do
|
57
62
|
@table.each do |row|
|
58
|
-
row['file_path'].
|
63
|
+
expect(row['file_path']).to eq('lib/client/client.rb')
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
62
67
|
specify "all records should have class name" do
|
63
|
-
@table.select{|rows| rows.fetch(:class_name, :no_key) == nil }.
|
68
|
+
expect(@table.select{|rows| rows.fetch(:class_name, :no_key) == nil }.size).to eq(0)
|
64
69
|
end
|
65
70
|
|
66
71
|
specify "one record should not have method name" do
|
67
|
-
@table.select{|rows| rows.fetch(:method_name, :no_key) == nil }.
|
72
|
+
expect(@table.select{|rows| rows.fetch(:method_name, :no_key) == nil }.size).to eq(0)
|
68
73
|
end
|
69
74
|
|
70
75
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'hotspots/analysis/ranking' }
|
2
3
|
|
3
4
|
describe MetricFu::Ranking do
|
4
5
|
|
@@ -9,14 +10,14 @@ describe MetricFu::Ranking do
|
|
9
10
|
ranking[:a] = 10
|
10
11
|
ranking[:b] = 50
|
11
12
|
ranking[:c] = 1
|
12
|
-
ranking.top.
|
13
|
+
expect(ranking.top).to eq([:b,:a, :c])
|
13
14
|
end
|
14
15
|
|
15
16
|
specify "lowest item is at 0 percentile" do
|
16
17
|
ranking = Ranking.new
|
17
18
|
ranking[:a] = 10
|
18
19
|
ranking[:b] = 50
|
19
|
-
ranking.percentile(:a).
|
20
|
+
expect(ranking.percentile(:a)).to eq(0)
|
20
21
|
end
|
21
22
|
|
22
23
|
specify "highest item is at high percentile" do
|
@@ -25,7 +26,7 @@ describe MetricFu::Ranking do
|
|
25
26
|
ranking[:b] = 50
|
26
27
|
ranking[:c] = 0
|
27
28
|
ranking[:d] = 5
|
28
|
-
ranking.percentile(:b).
|
29
|
+
expect(ranking.percentile(:b)).to eq(0.75)
|
29
30
|
end
|
30
31
|
|
31
32
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
MetricFu.metrics_require { 'hotspots/analysis/rankings' }
|
2
3
|
|
3
4
|
describe MetricFu::HotspotRankings do
|
4
5
|
|
6
|
+
before do
|
7
|
+
enable_hotspots
|
8
|
+
end
|
9
|
+
|
10
|
+
# TODO: This helper method is a huge smell. Make unnecessary
|
5
11
|
def rankings(result_hash)
|
6
12
|
@rankings ||= {}
|
7
13
|
@rankings.fetch(result_hash) do
|
@@ -26,7 +32,7 @@ describe MetricFu::HotspotRankings do
|
|
26
32
|
expected = [
|
27
33
|
"lib/client/client.rb",
|
28
34
|
"lib/client/foo.rb"]
|
29
|
-
rankings(result_hash).worst_files.
|
35
|
+
expect(rankings(result_hash).worst_files).to eq(expected)
|
30
36
|
end
|
31
37
|
def result_hash
|
32
38
|
@result_hash ||= HOTSPOT_DATA["several_metrics.yml"]
|
@@ -39,15 +45,15 @@ describe MetricFu::HotspotRankings do
|
|
39
45
|
end
|
40
46
|
|
41
47
|
it "gives worst method" do
|
42
|
-
rankings(@result_hash).worst_methods[0].
|
48
|
+
expect(rankings(@result_hash).worst_methods[0]).to eq("Client#client_requested_sync")
|
43
49
|
end
|
44
50
|
|
45
51
|
it "gives worst class" do
|
46
|
-
rankings(@result_hash).worst_classes[0].
|
52
|
+
expect(rankings(@result_hash).worst_classes[0]).to eq("Client")
|
47
53
|
end
|
48
54
|
|
49
55
|
it "gives worst file" do
|
50
|
-
rankings(@result_hash).worst_files[0].
|
56
|
+
expect(rankings(@result_hash).worst_files[0]).to eq("lib/client/client.rb")
|
51
57
|
end
|
52
58
|
|
53
59
|
end
|
@@ -58,11 +64,11 @@ describe MetricFu::HotspotRankings do
|
|
58
64
|
end
|
59
65
|
|
60
66
|
it "gives worst method" do
|
61
|
-
rankings(@result_hash).worst_methods[0].
|
67
|
+
expect(rankings(@result_hash).worst_methods[0]).to eq("Supr#self.handle_full_or_hash_option")
|
62
68
|
end
|
63
69
|
|
64
70
|
it "gives worst class" do
|
65
|
-
rankings(@result_hash).worst_classes[0].
|
71
|
+
expect(rankings(@result_hash).worst_classes[0]).to eq("Bitly")
|
66
72
|
end
|
67
73
|
|
68
74
|
end
|
@@ -73,15 +79,15 @@ describe MetricFu::HotspotRankings do
|
|
73
79
|
end
|
74
80
|
|
75
81
|
it "gives worst method" do
|
76
|
-
rankings(@result_hash).worst_methods[0].
|
82
|
+
expect(rankings(@result_hash).worst_methods[0]).to eq("main#none")
|
77
83
|
end
|
78
84
|
|
79
85
|
it "gives worst class" do
|
80
|
-
rankings(@result_hash).worst_classes[0].
|
86
|
+
expect(rankings(@result_hash).worst_classes[0]).to eq("main")
|
81
87
|
end
|
82
88
|
|
83
89
|
it "gives worst file" do
|
84
|
-
rankings(@result_hash).worst_files[0].
|
90
|
+
expect(rankings(@result_hash).worst_files[0]).to eq("lib/generators/rcov.rb:57")
|
85
91
|
end
|
86
92
|
|
87
93
|
end
|
@@ -93,7 +99,7 @@ describe MetricFu::HotspotRankings do
|
|
93
99
|
end
|
94
100
|
|
95
101
|
it "gives worst file" do
|
96
|
-
rankings(@result_hash).worst_files[0].
|
102
|
+
expect(rankings(@result_hash).worst_files[0]).to eq("lib/client/client.rb")
|
97
103
|
end
|
98
104
|
|
99
105
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'hotspots/hotspot_analyzer' }
|
2
3
|
|
3
|
-
describe HotspotAnalyzer do
|
4
|
+
describe MetricFu::HotspotAnalyzer do
|
4
5
|
|
5
6
|
it "should have its own tests regarding how it orchestrates the analysis of results, rankings, tables, and analyzed_problems"
|
6
7
|
|
@@ -1,11 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
MetricFu.metrics_require { 'hotspots/hotspot' }
|
3
|
+
|
4
|
+
describe MetricFu::Hotspot do
|
5
|
+
|
6
|
+
before do
|
7
|
+
enable_hotspots
|
8
|
+
end
|
2
9
|
|
3
|
-
describe "MetricFu::Hotspot" do
|
4
10
|
it "returns an array of of the analyzers that subclass it" do
|
5
11
|
expected_analyzers = [ReekHotspot, RoodiHotspot,
|
6
12
|
FlogHotspot, ChurnHotspot, SaikuroHotspot,
|
7
13
|
FlayHotspot, StatsHotspot, RcovHotspot]
|
8
14
|
|
9
|
-
MetricFu::Hotspot.analyzers.size.
|
15
|
+
expect(MetricFu::Hotspot.analyzers.size).to eq(expected_analyzers.size)
|
10
16
|
end
|
11
17
|
end
|
@@ -1,22 +1,17 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'hotspots/hotspots' }
|
2
3
|
|
3
4
|
describe MetricFu::HotspotsGenerator do
|
4
5
|
describe "analyze method" do
|
5
|
-
before :each do
|
6
|
-
MetricFu::Configuration.run {}
|
7
|
-
File.stub(:directory?).and_return(true)
|
8
|
-
@yaml = HOTSPOT_DATA["generator.yml"]
|
9
|
-
end
|
10
6
|
|
11
7
|
it "should be empty on error" do
|
12
8
|
hotspots = MetricFu::HotspotsGenerator.new
|
13
9
|
hotspots.instance_variable_set(:@analyzer, nil)
|
14
10
|
result = hotspots.analyze
|
15
|
-
result.
|
11
|
+
expect(result).to eq({:files => [], :classes => [], :methods => []})
|
16
12
|
end
|
17
13
|
|
18
14
|
it "should put the changes into a hash" do
|
19
|
-
MetricFu.result.should_receive(:result_hash).and_return(@yaml)
|
20
15
|
hotspots = MetricFu::HotspotsGenerator.new
|
21
16
|
hotspots.analyze
|
22
17
|
result = hotspots.to_h[:hotspots]
|
@@ -44,7 +39,8 @@ describe MetricFu::HotspotsGenerator do
|
|
44
39
|
# really testing the output of analyzed_problems#worst_items
|
45
40
|
it "should return the worst item granularities: files, classes, methods" do
|
46
41
|
hotspots = MetricFu::HotspotsGenerator.new
|
47
|
-
|
42
|
+
yaml = HOTSPOT_DATA["generator.yml"]
|
43
|
+
analyzer = HotspotAnalyzer.new(yaml)
|
48
44
|
expect(hotspots.analyze.keys).to eq([:files, :classes, :methods])
|
49
45
|
end
|
50
46
|
end
|