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,19 +1,20 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'roodi/roodi' }
|
2
3
|
|
3
4
|
describe MetricFu::RoodiGenerator do
|
4
5
|
describe "emit" do
|
5
6
|
it "should add config options when present" do
|
6
7
|
options = {:roodi_config => 'lib/config/roodi_config.yml', :dirs_to_roodi => []}
|
7
8
|
roodi = MetricFu::RoodiGenerator.new(options)
|
8
|
-
roodi.
|
9
|
+
expect(roodi).to receive(:run!).with(/-config=lib\/config\/roodi_config\.yml/).and_return("")
|
9
10
|
roodi.emit
|
10
11
|
end
|
11
12
|
|
12
13
|
it "should NOT add config options when NOT present" do
|
13
14
|
options = {:dirs_to_roodi => []}
|
14
15
|
roodi = MetricFu::RoodiGenerator.new(options)
|
15
|
-
roodi.
|
16
|
-
roodi.
|
16
|
+
allow(roodi).to receive(:run!)
|
17
|
+
expect(roodi).to receive(:run!).with(/-config/).never
|
17
18
|
roodi.emit
|
18
19
|
end
|
19
20
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'saikuro/saikuro' }
|
2
3
|
|
3
4
|
describe MetricFu::SaikuroGenerator do
|
4
5
|
STUB_TEST_DATA = lambda do |generator|
|
@@ -6,7 +7,9 @@ describe MetricFu::SaikuroGenerator do
|
|
6
7
|
def generator.metric_directory
|
7
8
|
FIXTURE.fixtures_path.join("saikuro").to_s
|
8
9
|
end
|
9
|
-
generator.
|
10
|
+
def generator.clear_scratch_files!
|
11
|
+
# no-op
|
12
|
+
end
|
10
13
|
end
|
11
14
|
describe "to_h method" do
|
12
15
|
before do
|
@@ -19,25 +22,25 @@ describe MetricFu::SaikuroGenerator do
|
|
19
22
|
end
|
20
23
|
|
21
24
|
it "should find the filename of a file" do
|
22
|
-
@output[:saikuro][:files].first[:filename].
|
25
|
+
expect(@output[:saikuro][:files].first[:filename]).to eq('app/controllers/users_controller.rb')
|
23
26
|
end
|
24
27
|
|
25
28
|
it "should find the name of the classes" do
|
26
|
-
@output[:saikuro][:classes].first[:name].
|
27
|
-
@output[:saikuro][:classes][1][:name].
|
29
|
+
expect(@output[:saikuro][:classes].first[:name]).to eq("UsersController")
|
30
|
+
expect(@output[:saikuro][:classes][1][:name]).to eq("SessionsController")
|
28
31
|
end
|
29
32
|
|
30
33
|
it "should put the most complex method first" do
|
31
|
-
@output[:saikuro][:methods].first[:name].
|
32
|
-
@output[:saikuro][:methods].first[:complexity].
|
34
|
+
expect(@output[:saikuro][:methods].first[:name]).to eq("UsersController#create")
|
35
|
+
expect(@output[:saikuro][:methods].first[:complexity]).to eq(4)
|
33
36
|
end
|
34
37
|
|
35
38
|
it "should find the complexity of a method" do
|
36
|
-
@output[:saikuro][:methods].first[:complexity].
|
39
|
+
expect(@output[:saikuro][:methods].first[:complexity]).to eq(4)
|
37
40
|
end
|
38
41
|
|
39
42
|
it "should find the lines of a method" do
|
40
|
-
@output[:saikuro][:methods].first[:lines].
|
43
|
+
expect(@output[:saikuro][:methods].first[:lines]).to eq(15)
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
@@ -51,7 +54,7 @@ describe MetricFu::SaikuroGenerator do
|
|
51
54
|
end
|
52
55
|
|
53
56
|
it "doesn't try to get information if the file does not exist" do
|
54
|
-
@saikuro.
|
57
|
+
expect(@saikuro).to receive(:file_not_exists?).at_least(:once).and_return(true)
|
55
58
|
@saikuro.per_file_info('ignore_me')
|
56
59
|
end
|
57
60
|
end
|
@@ -61,7 +64,7 @@ describe MetricFu::SaikuroGenerator do
|
|
61
64
|
it "should parse nested START/END sections" do
|
62
65
|
path = FIXTURE.fixtures_path.join("saikuro_sfiles", "thing.rb_cyclo.html").to_s
|
63
66
|
sfile = MetricFu::SaikuroScratchFile.new path
|
64
|
-
sfile.elements.map { |e| e.complexity }.sort.
|
67
|
+
expect(sfile.elements.map { |e| e.complexity }.sort).to eql(["0","0","2"])
|
65
68
|
end
|
66
69
|
end
|
67
70
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'stats/stats_grapher' }
|
2
3
|
|
3
4
|
describe StatsGrapher do
|
4
5
|
before :each do
|
@@ -7,16 +8,16 @@ describe StatsGrapher do
|
|
7
8
|
end
|
8
9
|
|
9
10
|
it "should respond to loc_counts and lot_counts and labels" do
|
10
|
-
@stats_grapher.
|
11
|
-
@stats_grapher.
|
12
|
-
@stats_grapher.
|
11
|
+
expect(@stats_grapher).to respond_to(:loc_counts)
|
12
|
+
expect(@stats_grapher).to respond_to(:lot_counts)
|
13
|
+
expect(@stats_grapher).to respond_to(:labels)
|
13
14
|
end
|
14
15
|
|
15
16
|
describe "responding to #initialize" do
|
16
17
|
it "should initialise loc_counts and lot_counts and labels" do
|
17
|
-
@stats_grapher.loc_counts.
|
18
|
-
@stats_grapher.lot_counts.
|
19
|
-
@stats_grapher.labels.
|
18
|
+
expect(@stats_grapher.loc_counts).to eq([])
|
19
|
+
expect(@stats_grapher.lot_counts).to eq([])
|
20
|
+
expect(@stats_grapher.labels).to eq({})
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -28,17 +29,17 @@ describe StatsGrapher do
|
|
28
29
|
end
|
29
30
|
|
30
31
|
it "should not push to loc_counts" do
|
31
|
-
@stats_grapher.loc_counts.
|
32
|
+
expect(@stats_grapher.loc_counts).not_to receive(:push)
|
32
33
|
@stats_grapher.get_metrics(@metrics, @date)
|
33
34
|
end
|
34
35
|
|
35
36
|
it "should not push to lot_counts" do
|
36
|
-
@stats_grapher.lot_counts.
|
37
|
+
expect(@stats_grapher.lot_counts).not_to receive(:push)
|
37
38
|
@stats_grapher.get_metrics(@metrics, @date)
|
38
39
|
end
|
39
40
|
|
40
41
|
it "should not update labels with the date" do
|
41
|
-
@stats_grapher.labels.
|
42
|
+
expect(@stats_grapher.labels).not_to receive(:update)
|
42
43
|
@stats_grapher.get_metrics(@metrics, @date)
|
43
44
|
end
|
44
45
|
end
|
@@ -50,17 +51,17 @@ describe StatsGrapher do
|
|
50
51
|
end
|
51
52
|
|
52
53
|
it "should push to loc_counts" do
|
53
|
-
@stats_grapher.loc_counts.
|
54
|
+
expect(@stats_grapher.loc_counts).to receive(:push).with(15935)
|
54
55
|
@stats_grapher.get_metrics(@metrics, @date)
|
55
56
|
end
|
56
57
|
|
57
58
|
it "should push to lot_counts" do
|
58
|
-
@stats_grapher.lot_counts.
|
59
|
+
expect(@stats_grapher.lot_counts).to receive(:push).with(7438)
|
59
60
|
@stats_grapher.get_metrics(@metrics, @date)
|
60
61
|
end
|
61
62
|
|
62
63
|
it "should update labels with the date" do
|
63
|
-
@stats_grapher.labels.
|
64
|
+
expect(@stats_grapher.labels).to receive(:update).with({ 0 => "01022003" })
|
64
65
|
@stats_grapher.get_metrics(@metrics, @date)
|
65
66
|
end
|
66
67
|
end
|
@@ -1,16 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'stats/stats' }
|
2
3
|
|
3
4
|
describe StatsGenerator do
|
4
5
|
describe "emit method" do
|
5
6
|
it "should gather the raw data" do
|
6
7
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
7
8
|
MetricFu.configure.reset
|
8
|
-
File.
|
9
|
+
allow(File).to receive(:directory?).and_return(true)
|
9
10
|
stats = MetricFu::StatsGenerator.new
|
10
11
|
stats.emit
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
#TODO review tested output
|
14
16
|
describe "analyze method" do
|
15
17
|
before :each do
|
16
18
|
@lines = <<-HERE.gsub(/^\s*/, "")
|
@@ -34,32 +36,32 @@ describe StatsGenerator do
|
|
34
36
|
HERE
|
35
37
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
36
38
|
MetricFu.configure.reset
|
37
|
-
File.
|
39
|
+
allow(File).to receive(:directory?).and_return(true)
|
38
40
|
stats = MetricFu::StatsGenerator.new
|
39
41
|
stats.instance_variable_set('@output', @lines)
|
40
42
|
@results = stats.analyze
|
41
43
|
end
|
42
44
|
|
43
45
|
it "should get code Lines Of Code" do
|
44
|
-
@results[:codeLOC].
|
46
|
+
expect(@results[:codeLOC]).to eq(915)
|
45
47
|
end
|
46
48
|
|
47
49
|
it "should get test Lines Of Code" do
|
48
|
-
@results[:testLOC].
|
50
|
+
expect(@results[:testLOC]).to eq(2226)
|
49
51
|
end
|
50
52
|
|
51
53
|
it "should get code to test ratio" do
|
52
|
-
@results[:code_to_test_ratio].
|
54
|
+
expect(@results[:code_to_test_ratio]).to eq(2.4)
|
53
55
|
end
|
54
56
|
|
55
57
|
it "should get data on models" do
|
56
58
|
model_data = @results[:lines].find {|line| line[:name] == "Models"}
|
57
|
-
model_data[:classes].
|
58
|
-
model_data[:methods].
|
59
|
-
model_data[:loc].
|
60
|
-
model_data[:lines].
|
61
|
-
model_data[:methods_per_class].
|
62
|
-
model_data[:loc_per_method].
|
59
|
+
expect(model_data[:classes]).to eq(9)
|
60
|
+
expect(model_data[:methods]).to eq(31)
|
61
|
+
expect(model_data[:loc]).to eq(285)
|
62
|
+
expect(model_data[:lines]).to eq(351)
|
63
|
+
expect(model_data[:methods_per_class]).to eq(3)
|
64
|
+
expect(model_data[:loc_per_method]).to eq(7)
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'handles code to test ratio is ratio is 1:NaN' do
|
@@ -73,7 +75,7 @@ describe StatsGenerator do
|
|
73
75
|
HERE
|
74
76
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
75
77
|
MetricFu.configure.reset
|
76
|
-
File.
|
78
|
+
allow(File).to receive(:directory?).and_return(true)
|
77
79
|
stats = MetricFu::StatsGenerator.new(MetricFu::Metric.get_metric(:stats).run_options)
|
78
80
|
stats.instance_variable_set('@output', lines)
|
79
81
|
@results = stats.analyze
|
@@ -85,10 +87,10 @@ describe StatsGenerator do
|
|
85
87
|
it "should put things into a hash" do
|
86
88
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
87
89
|
MetricFu.configure.reset
|
88
|
-
File.
|
90
|
+
allow(File).to receive(:directory?).and_return(true)
|
89
91
|
stats = MetricFu::StatsGenerator.new
|
90
92
|
stats.instance_variable_set(:@stats, "the_stats")
|
91
|
-
stats.to_h[:stats].
|
93
|
+
expect(stats.to_h[:stats]).to eq("the_stats")
|
92
94
|
end
|
93
95
|
end
|
94
96
|
end
|
@@ -1,24 +1,25 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.lib_require { 'reporter' }
|
2
3
|
|
3
4
|
describe MetricFu::Reporter do
|
4
5
|
|
5
6
|
context 'given a single formatter' do
|
6
7
|
before do
|
7
8
|
@formatter = double('formatter')
|
8
|
-
@formatter.
|
9
|
+
allow(@formatter).to receive(:to_a).and_return([@formatter])
|
9
10
|
@reporter = Reporter.new(@formatter)
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'notifies the formatter' do
|
13
|
-
@formatter.
|
14
|
-
@formatter.
|
14
|
+
expect(@formatter).to receive(:start)
|
15
|
+
expect(@formatter).to receive(:finish)
|
15
16
|
@reporter.start
|
16
17
|
@reporter.finish
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'only sends notifications when supported by formatter' do
|
20
|
-
@formatter.
|
21
|
-
@formatter.
|
21
|
+
allow(@formatter).to receive(:respond_to?).with(:display_results).and_return(false)
|
22
|
+
expect(@formatter).not_to receive(:display_results)
|
22
23
|
@reporter.display_results
|
23
24
|
end
|
24
25
|
end
|
@@ -31,8 +32,8 @@ describe MetricFu::Reporter do
|
|
31
32
|
|
32
33
|
it 'notifies all formatters' do
|
33
34
|
@formatters.each do |formatter|
|
34
|
-
formatter.
|
35
|
-
formatter.
|
35
|
+
expect(formatter).to receive(:start)
|
36
|
+
expect(formatter).to receive(:finish)
|
36
37
|
end
|
37
38
|
@reporter.start
|
38
39
|
@reporter.finish
|
@@ -18,7 +18,7 @@ describe "Bluff graphers responding to #graph!" do
|
|
18
18
|
graphs.each do |key, val|
|
19
19
|
val.graph!
|
20
20
|
output_dir = File.expand_path(File.join(MetricFu::Io::FileSystem.directory('output_directory')))
|
21
|
-
|
21
|
+
expect{ File.read(File.join(output_dir, "#{key.to_s.downcase}.js")) }.not_to raise_error
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.reporting_require { 'result' }
|
2
3
|
|
3
4
|
describe MetricFu do
|
4
5
|
|
5
6
|
describe "#result" do
|
6
7
|
it 'should return an instance of Result' do
|
7
|
-
MetricFu.result.instance_of?(Result).
|
8
|
+
expect(MetricFu.result.instance_of?(Result)).to be(true)
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
@@ -18,9 +19,9 @@ describe MetricFu::Result do
|
|
18
19
|
describe "#as_yaml" do
|
19
20
|
it 'should call #result_hash' do
|
20
21
|
result_hash = double('result_hash')
|
21
|
-
result_hash.
|
22
|
+
expect(result_hash).to receive(:to_yaml)
|
22
23
|
|
23
|
-
@result.
|
24
|
+
expect(@result).to receive(:result_hash).and_return(result_hash)
|
24
25
|
@result.as_yaml
|
25
26
|
end
|
26
27
|
end
|
@@ -31,20 +32,20 @@ describe MetricFu::Result do
|
|
31
32
|
describe "#add" do
|
32
33
|
it 'should add a passed hash to the result_hash instance variable' do
|
33
34
|
result_type = double('result_type')
|
34
|
-
result_type.
|
35
|
+
allow(result_type).to receive(:to_s).and_return('type')
|
35
36
|
|
36
37
|
result_inst = double('result_inst')
|
37
|
-
result_type.
|
38
|
+
expect(result_type).to receive(:new).and_return(result_inst)
|
38
39
|
|
39
|
-
result_inst.
|
40
|
-
result_inst.
|
40
|
+
expect(result_inst).to receive(:generate_result).and_return({:a => 'b'})
|
41
|
+
expect(result_inst).to receive(:respond_to?).and_return(false)
|
41
42
|
|
42
|
-
MetricFu::Generator.
|
43
|
+
expect(MetricFu::Generator).to receive(:get_generator).
|
43
44
|
with(result_type).and_return(result_type)
|
44
45
|
result_hash = double('result_hash')
|
45
|
-
result_hash.
|
46
|
-
@result.
|
47
|
-
@result.
|
46
|
+
expect(result_hash).to receive(:merge!).with({:a => 'b'})
|
47
|
+
expect(@result).to receive(:result_hash).and_return(result_hash)
|
48
|
+
expect(@result).to receive(:metric_options_for_result_type).with(result_type)
|
48
49
|
@result.add(result_type)
|
49
50
|
end
|
50
51
|
end
|
data/spec/metric_fu/run_spec.rb
CHANGED
@@ -29,9 +29,18 @@ describe MetricFu do
|
|
29
29
|
# limited set, so we can test the basic functionality
|
30
30
|
# without significantly slowing down the specs.
|
31
31
|
MetricFu.configuration.configure_metrics do |metric|
|
32
|
-
if metric.name == :
|
32
|
+
if metric.name == :reek
|
33
33
|
metric.enable
|
34
34
|
metric.activated = true
|
35
|
+
# so this doesn't seem to always be true
|
36
|
+
# @bf4 adding that line you thought I didn't need made tests pass for me
|
37
|
+
# but they failed on one of the travis builds.
|
38
|
+
# swapping this line all seem to pass every run
|
39
|
+
# I don't understand what is happening in run_external well enough
|
40
|
+
# need some help debugging
|
41
|
+
# but tests seem more stable without it.
|
42
|
+
# metric.should_receive(:run_external).and_return('')
|
43
|
+
allow(metric).to receive(:run_external).and_return('')
|
35
44
|
else
|
36
45
|
metric.enabled = false
|
37
46
|
end
|
@@ -156,17 +165,22 @@ describe MetricFu do
|
|
156
165
|
|
157
166
|
it "displays help" do
|
158
167
|
out = metric_fu "--help"
|
159
|
-
out.
|
168
|
+
expect(out).to include helper.banner
|
160
169
|
end
|
161
170
|
|
162
171
|
it "displays version" do
|
163
172
|
out = metric_fu "--version"
|
164
|
-
out.
|
173
|
+
expect(out).to include "#{MetricFu::VERSION}"
|
165
174
|
end
|
166
175
|
|
167
176
|
it "errors on unknown flags" do
|
168
|
-
|
169
|
-
out
|
177
|
+
failure = false
|
178
|
+
out = metric_fu "--asdasdasda" do |message|
|
179
|
+
# swallow the error message
|
180
|
+
failure = true
|
181
|
+
end
|
182
|
+
expect(out).to include 'invalid option'
|
183
|
+
expect(failure).to be_truthy
|
170
184
|
end
|
171
185
|
|
172
186
|
end
|
@@ -184,11 +198,13 @@ describe MetricFu do
|
|
184
198
|
# Catch system exit so that it doesn't halt spec.
|
185
199
|
rescue SystemExit => system_exit
|
186
200
|
status = system_exit.success? ? "SUCCESS" : "FAILURE"
|
187
|
-
message << "#{status} with code #{system_exit.status}: "
|
188
|
-
|
201
|
+
message << "#{status} with code #{system_exit.status}: "
|
202
|
+
message << "#{system_exit.message} #{system_exit.backtrace}"
|
189
203
|
end
|
190
204
|
}
|
191
|
-
|
205
|
+
if message.start_with?('FAILURE')
|
206
|
+
block_given? ? yield(message) : STDERR.puts(message)
|
207
|
+
end
|
192
208
|
out
|
193
209
|
end
|
194
210
|
|
data/spec/spec_helper.rb
CHANGED
@@ -16,7 +16,7 @@ if ENV['COVERAGE']
|
|
16
16
|
end
|
17
17
|
|
18
18
|
require 'date'
|
19
|
-
require '
|
19
|
+
require 'test_construct'
|
20
20
|
require 'json'
|
21
21
|
require 'pry-nav'
|
22
22
|
|
@@ -33,7 +33,6 @@ Dir[MetricFu.root_dir + "/spec/support/**/*.rb"].each {|f| require f}
|
|
33
33
|
RSpec.configure do |config|
|
34
34
|
config.mock_with :rspec
|
35
35
|
|
36
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
37
36
|
config.filter_run focus: true
|
38
37
|
config.run_all_when_everything_filtered = true
|
39
38
|
config.filter_run_excluding :slow unless ENV["SLOW_SPECS"]
|
@@ -1,3 +1,16 @@
|
|
1
|
+
def enable_hotspots
|
2
|
+
MetricFu.configure
|
3
|
+
hotspot_metrics = MetricFu::Metric.metrics.map(&:name)
|
4
|
+
hotspot_metrics.each do |metric_name|
|
5
|
+
path = "#{metric_name}/#{metric_name}_hotspot"
|
6
|
+
begin
|
7
|
+
MetricFu.metrics_require { path }
|
8
|
+
rescue LoadError
|
9
|
+
# No hotspot, but that's ok
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
1
14
|
def metric_not_activated?(metric_name)
|
2
15
|
MetricFu.configuration.configure_metrics
|
3
16
|
if MetricFu::Metric.get_metric(metric_name.intern).activate
|
@@ -14,5 +27,5 @@ def breaks_when?(bool)
|
|
14
27
|
end
|
15
28
|
|
16
29
|
def compare_paths(path1, path2)
|
17
|
-
File.join(MetricFu.root_dir, path1).
|
30
|
+
expect(File.join(MetricFu.root_dir, path1)).to eq(File.join(MetricFu.root_dir, path2))
|
18
31
|
end
|