metric_fu 4.6.0 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,4 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
+
MetricFu.metrics_require { 'rails_best_practices/rails_best_practices_grapher' }
|
|
2
3
|
|
|
3
4
|
describe RailsBestPracticesGrapher do
|
|
4
5
|
before :each do
|
|
@@ -7,14 +8,14 @@ describe RailsBestPracticesGrapher do
|
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
it "should respond to rails_best_practices_count and labels" do
|
|
10
|
-
@stats_grapher.
|
|
11
|
-
@stats_grapher.
|
|
11
|
+
expect(@stats_grapher).to respond_to(:rails_best_practices_count)
|
|
12
|
+
expect(@stats_grapher).to respond_to(:labels)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
describe "responding to #initialize" do
|
|
15
16
|
it "should initialise rails_best_practices_count and labels" do
|
|
16
|
-
@stats_grapher.rails_best_practices_count.
|
|
17
|
-
@stats_grapher.labels.
|
|
17
|
+
expect(@stats_grapher.rails_best_practices_count).to eq([])
|
|
18
|
+
expect(@stats_grapher.labels).to eq({})
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -26,12 +27,12 @@ describe RailsBestPracticesGrapher do
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
it "should not push to rails_best_practices_count" do
|
|
29
|
-
@stats_grapher.rails_best_practices_count.
|
|
30
|
+
expect(@stats_grapher.rails_best_practices_count).not_to receive(:push)
|
|
30
31
|
@stats_grapher.get_metrics(@metrics, @date)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
it "should not update labels with the date" do
|
|
34
|
-
@stats_grapher.labels.
|
|
35
|
+
expect(@stats_grapher.labels).not_to receive(:update)
|
|
35
36
|
@stats_grapher.get_metrics(@metrics, @date)
|
|
36
37
|
end
|
|
37
38
|
end
|
|
@@ -43,17 +44,17 @@ describe RailsBestPracticesGrapher do
|
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
it "should push to rails_best_practices_count" do
|
|
46
|
-
@stats_grapher.rails_best_practices_count.
|
|
47
|
+
expect(@stats_grapher.rails_best_practices_count).to receive(:push).with(2)
|
|
47
48
|
@stats_grapher.get_metrics(@metrics, @date)
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
it "should push 0 to rails_best_practices_count when no problems were found" do
|
|
51
|
-
@stats_grapher.rails_best_practices_count.
|
|
52
|
+
expect(@stats_grapher.rails_best_practices_count).to receive(:push).with(0)
|
|
52
53
|
@stats_grapher.get_metrics({ :rails_best_practices => {} }, @date)
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
it "should update labels with the date" do
|
|
56
|
-
@stats_grapher.labels.
|
|
57
|
+
expect(@stats_grapher.labels).to receive(:update).with({ 0 => "01022003" })
|
|
57
58
|
@stats_grapher.get_metrics(@metrics, @date)
|
|
58
59
|
end
|
|
59
60
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
+
MetricFu.metrics_require { 'rails_best_practices/rails_best_practices' }
|
|
2
3
|
|
|
3
4
|
describe RailsBestPracticesGenerator do
|
|
4
5
|
|
|
@@ -7,18 +8,18 @@ describe RailsBestPracticesGenerator do
|
|
|
7
8
|
describe "emit method" do
|
|
8
9
|
let(:analyzer) { ::RailsBestPractices::Analyzer.new('.', { 'silent' => true }) }
|
|
9
10
|
context "RailsBestPractices provides the expected API" do
|
|
10
|
-
it { analyzer.
|
|
11
|
-
it { analyzer.
|
|
11
|
+
it { expect(analyzer).to respond_to :analyze }
|
|
12
|
+
it { expect(analyzer).to respond_to :errors }
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
describe "analyze method" do
|
|
16
17
|
let(:error) { ::RailsBestPractices::Core::Error.new }
|
|
17
18
|
context "RailsBestPractices provdies the expected API" do
|
|
18
|
-
it { error.
|
|
19
|
-
it { error.
|
|
20
|
-
it { error.
|
|
21
|
-
it { error.
|
|
19
|
+
it { expect(error).to respond_to :filename }
|
|
20
|
+
it { expect(error).to respond_to :line_number }
|
|
21
|
+
it { expect(error).to respond_to :message }
|
|
22
|
+
it { expect(error).to respond_to :url }
|
|
22
23
|
end
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -27,7 +28,7 @@ describe RailsBestPracticesGenerator do
|
|
|
27
28
|
MetricFu::Configuration.run {}
|
|
28
29
|
practices = MetricFu::RailsBestPracticesGenerator.new
|
|
29
30
|
practices.instance_variable_set(:@rails_best_practices_results, "the_practices")
|
|
30
|
-
practices.to_h[:rails_best_practices].
|
|
31
|
+
expect(practices.to_h[:rails_best_practices]).to eq("the_practices")
|
|
31
32
|
end
|
|
32
33
|
end
|
|
33
34
|
end
|
|
@@ -7,14 +7,14 @@ describe RcovGrapher do
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it "should respond to rcov_percent and labels" do
|
|
10
|
-
@rcov_grapher.
|
|
11
|
-
@rcov_grapher.
|
|
10
|
+
expect(@rcov_grapher).to respond_to(:rcov_percent)
|
|
11
|
+
expect(@rcov_grapher).to 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
|
-
@rcov_grapher.rcov_percent.
|
|
17
|
-
@rcov_grapher.labels.
|
|
16
|
+
expect(@rcov_grapher.rcov_percent).to eq([])
|
|
17
|
+
expect(@rcov_grapher.labels).to eq({})
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -26,12 +26,12 @@ describe RcovGrapher do
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "should not push to rcov_percent" do
|
|
29
|
-
@rcov_grapher.rcov_percent.
|
|
29
|
+
expect(@rcov_grapher.rcov_percent).not_to receive(:push)
|
|
30
30
|
@rcov_grapher.get_metrics(@metrics, @date)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "should not update labels with the date" do
|
|
34
|
-
@rcov_grapher.labels.
|
|
34
|
+
expect(@rcov_grapher.labels).not_to receive(:update)
|
|
35
35
|
@rcov_grapher.get_metrics(@metrics, @date)
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -43,12 +43,12 @@ describe RcovGrapher do
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "should push to rcov_percent" do
|
|
46
|
-
@rcov_grapher.rcov_percent.
|
|
46
|
+
expect(@rcov_grapher.rcov_percent).to receive(:push).with(49.6)
|
|
47
47
|
@rcov_grapher.get_metrics(@metrics, @date)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should update labels with the date" do
|
|
51
|
-
@rcov_grapher.labels.
|
|
51
|
+
expect(@rcov_grapher.labels).to receive(:update).with({ 0 => "1/2" })
|
|
52
52
|
@rcov_grapher.get_metrics(@metrics, @date)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
-
|
|
2
|
+
MetricFu.metrics_require { 'hotspots/init' }
|
|
3
|
+
MetricFu.metrics_require { 'hotspots/hotspot' }
|
|
4
|
+
MetricFu.metrics_require { 'hotspots/analysis/record' }
|
|
5
|
+
MetricFu.metrics_require { 'rcov/rcov_hotspot' }
|
|
3
6
|
|
|
4
7
|
describe MetricFu::RcovHotspot do
|
|
5
8
|
describe "map" do
|
|
@@ -11,7 +14,7 @@ describe MetricFu::RcovHotspot do
|
|
|
11
14
|
MetricFu::Record.new({"percentage_uncovered"=>0.75}, nil)
|
|
12
15
|
end
|
|
13
16
|
|
|
14
|
-
it {subject.map(zero_row).
|
|
15
|
-
it {subject.map(non_zero_row).
|
|
17
|
+
it {expect(subject.map(zero_row)).to eql(0.0)}
|
|
18
|
+
it {expect(subject.map(non_zero_row)).to eql(0.75)}
|
|
16
19
|
end
|
|
17
|
-
end
|
|
20
|
+
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
+
MetricFu.metrics_require { 'rcov/rcov' }
|
|
2
3
|
|
|
3
4
|
describe MetricFu::RcovGenerator do
|
|
4
5
|
|
|
@@ -22,14 +23,14 @@ describe MetricFu::RcovGenerator do
|
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
it "should clear out previous output and make output folder" do
|
|
25
|
-
MetricFu::Utility.
|
|
26
|
-
MetricFu::Utility.
|
|
26
|
+
expect(MetricFu::Utility).to receive(:rm_rf).with(MetricFu::RcovGenerator.metric_directory, :verbose => false)
|
|
27
|
+
expect(MetricFu::Utility).to receive(:mkdir_p).with(MetricFu::RcovGenerator.metric_directory)
|
|
27
28
|
@rcov.reset_output_location
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
it "should set the RAILS_ENV" do
|
|
31
|
-
MetricFu::Utility.
|
|
32
|
-
MetricFu::Utility.
|
|
32
|
+
expect(MetricFu::Utility).to receive(:rm_rf).with(MetricFu::RcovGenerator.metric_directory, :verbose => false)
|
|
33
|
+
expect(MetricFu::Utility).to receive(:mkdir_p).with(MetricFu::RcovGenerator.metric_directory)
|
|
33
34
|
options = {:environment => 'metrics', :external => nil}
|
|
34
35
|
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
|
35
36
|
expect(@rcov.command).to include('RAILS_ENV=metrics')
|
|
@@ -40,30 +41,30 @@ describe MetricFu::RcovGenerator do
|
|
|
40
41
|
before :each do
|
|
41
42
|
options = {:external => nil}
|
|
42
43
|
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
|
43
|
-
@rcov.
|
|
44
|
+
expect(@rcov).to receive(:load_output).and_return(RCOV_OUTPUT)
|
|
44
45
|
@files = @rcov.analyze
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
describe "analyze" do
|
|
48
49
|
it "should compute percent of lines run" do
|
|
49
|
-
@files["lib/templates/awesome/awesome_template.rb"][:percent_run].
|
|
50
|
-
@files["lib/templates/standard/standard_template.rb"][:percent_run].
|
|
50
|
+
expect(@files["lib/templates/awesome/awesome_template.rb"][:percent_run]).to eq(13)
|
|
51
|
+
expect(@files["lib/templates/standard/standard_template.rb"][:percent_run]).to eq(14)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
it "should know which lines were run" do
|
|
54
|
-
@files["lib/templates/awesome/awesome_template.rb"][:lines].
|
|
55
|
-
|
|
55
|
+
expect(@files["lib/templates/awesome/awesome_template.rb"][:lines]).
|
|
56
|
+
to include({:content=>"require 'fileutils'", :was_run=>true})
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
it "should know which lines NOT were run" do
|
|
59
|
-
@files["lib/templates/awesome/awesome_template.rb"][:lines].
|
|
60
|
-
|
|
60
|
+
expect(@files["lib/templates/awesome/awesome_template.rb"][:lines]).
|
|
61
|
+
to include({:content=>" if template_exists?(section)", :was_run=>false})
|
|
61
62
|
end
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
describe "to_h" do
|
|
65
66
|
it "should calculate total percentage for all files" do
|
|
66
|
-
@rcov.to_h[:rcov][:global_percent_run].
|
|
67
|
+
expect(@rcov.to_h[:rcov][:global_percent_run]).to eq(13.7)
|
|
67
68
|
end
|
|
68
69
|
end
|
|
69
70
|
end
|
|
@@ -74,12 +75,12 @@ describe MetricFu::RcovGenerator do
|
|
|
74
75
|
end
|
|
75
76
|
|
|
76
77
|
it "should emit nothing if external configuration option is set" do
|
|
77
|
-
MetricFu::Utility.
|
|
78
|
+
expect(MetricFu::Utility).not_to receive(:rm_rf)
|
|
78
79
|
@rcov.emit
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
it "should open the external rcov analysis file" do
|
|
82
|
-
@rcov.
|
|
83
|
+
expect(@rcov).to receive(:load_output).and_return(RCOV_OUTPUT)
|
|
83
84
|
@files = @rcov.analyze
|
|
84
85
|
end
|
|
85
86
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
+
MetricFu.metrics_require { 'reek/reek_grapher' }
|
|
2
3
|
|
|
3
4
|
describe ReekGrapher do
|
|
4
5
|
before :each do
|
|
@@ -7,14 +8,14 @@ describe ReekGrapher do
|
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
it "should respond to reek_count and labels" do
|
|
10
|
-
@reek_grapher.
|
|
11
|
-
@reek_grapher.
|
|
11
|
+
expect(@reek_grapher).to respond_to(:reek_count)
|
|
12
|
+
expect(@reek_grapher).to respond_to(:labels)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
describe "responding to #initialize" do
|
|
15
16
|
it "should initialise reek_count and labels" do
|
|
16
|
-
@reek_grapher.reek_count.
|
|
17
|
-
@reek_grapher.labels.
|
|
17
|
+
expect(@reek_grapher.reek_count).to eq({})
|
|
18
|
+
expect(@reek_grapher.labels).to eq({})
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -27,11 +28,11 @@ describe ReekGrapher do
|
|
|
27
28
|
|
|
28
29
|
it "should not set a hash of code smells to reek_count" do
|
|
29
30
|
@reek_grapher.get_metrics(@metrics, @date)
|
|
30
|
-
@reek_grapher.reek_count.
|
|
31
|
+
expect(@reek_grapher.reek_count).to eq({})
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
it "should not update labels with the date" do
|
|
34
|
-
@reek_grapher.labels.
|
|
35
|
+
expect(@reek_grapher.labels).not_to receive(:update)
|
|
35
36
|
@reek_grapher.get_metrics(@metrics, @date)
|
|
36
37
|
end
|
|
37
38
|
end
|
|
@@ -44,7 +45,7 @@ describe ReekGrapher do
|
|
|
44
45
|
|
|
45
46
|
it "should set a hash of code smells to reek_count" do
|
|
46
47
|
@reek_grapher.get_metrics(@metrics, @date)
|
|
47
|
-
@reek_grapher.reek_count.
|
|
48
|
+
expect(@reek_grapher.reek_count).to eq({
|
|
48
49
|
"Uncommunicative Name" => [27],
|
|
49
50
|
"Feature Envy" => [20],
|
|
50
51
|
"Utility Function" => [15],
|
|
@@ -53,11 +54,11 @@ describe ReekGrapher do
|
|
|
53
54
|
"Control Couple" => [4],
|
|
54
55
|
"Duplication" => [48],
|
|
55
56
|
"Large Class" => [1]
|
|
56
|
-
}
|
|
57
|
+
})
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
it "should update labels with the date" do
|
|
60
|
-
@reek_grapher.labels.
|
|
61
|
+
expect(@reek_grapher.labels).to receive(:update).with({ 0 => "1/2" })
|
|
61
62
|
@reek_grapher.get_metrics(@metrics, @date)
|
|
62
63
|
end
|
|
63
64
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
+
MetricFu.metrics_require { 'reek/reek' }
|
|
2
3
|
|
|
3
4
|
describe MetricFu::ReekGenerator do
|
|
4
5
|
describe "emit" do
|
|
@@ -6,12 +7,13 @@ describe MetricFu::ReekGenerator do
|
|
|
6
7
|
options = {:config_file_pattern => 'lib/config/*.reek', :dirs_to_reek => []}
|
|
7
8
|
reek = MetricFu::ReekGenerator.new(options)
|
|
8
9
|
files_to_analyze = ['lib/foo.rb','lib/bar.rb']
|
|
9
|
-
reek.
|
|
10
|
-
reek.
|
|
10
|
+
allow(reek).to receive(:files_to_analyze).and_return(files_to_analyze)
|
|
11
|
+
expect(reek).to receive(:run!).with(/--config lib\/config\/\*\.reek lib\/foo.rb lib\/bar.rb/).and_return("")
|
|
11
12
|
reek.emit
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
#TODO review tested output
|
|
15
17
|
describe "analyze method" do
|
|
16
18
|
before :each do
|
|
17
19
|
@lines = <<-HERE
|
|
@@ -31,7 +33,7 @@ LinkTargetsController#authorize_user calls current_user.role multiple times (Dup
|
|
|
31
33
|
NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
|
|
32
34
|
HERE
|
|
33
35
|
MetricFu::Configuration.run {}
|
|
34
|
-
File.
|
|
36
|
+
allow(File).to receive(:directory?).and_return(true)
|
|
35
37
|
reek = MetricFu::ReekGenerator.new
|
|
36
38
|
reek.instance_variable_set(:@output, @lines)
|
|
37
39
|
@matches = reek.analyze
|
|
@@ -39,30 +41,30 @@ NewlineController#some_method calls current_user.<< "new line\n" multiple times
|
|
|
39
41
|
|
|
40
42
|
it "should find the code smell's method name" do
|
|
41
43
|
smell = @matches.first[:code_smells].first
|
|
42
|
-
smell[:method].
|
|
44
|
+
expect(smell[:method]).to eq("ActivityReportsController#authorize_user")
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
it "should find the code smell's type" do
|
|
46
48
|
smell = @matches[1][:code_smells].first
|
|
47
|
-
smell[:type].
|
|
49
|
+
expect(smell[:type]).to eq("Nested Iterators")
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
it "should find the code smell's message" do
|
|
51
53
|
smell = @matches[1][:code_smells].first
|
|
52
|
-
smell[:message].
|
|
54
|
+
expect(smell[:message]).to eq("is nested")
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
it "should find the code smell's type" do
|
|
56
58
|
smell = @matches.first
|
|
57
|
-
smell[:file_path].
|
|
59
|
+
expect(smell[:file_path]).to eq("app/controllers/activity_reports_controller.rb")
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
it "should NOT insert nil smells into the array when there's a newline in the method call" do
|
|
61
|
-
@matches.last[:code_smells].
|
|
62
|
-
@matches.last.
|
|
63
|
+
expect(@matches.last[:code_smells]).to eq(@matches.last[:code_smells].compact)
|
|
64
|
+
expect(@matches.last).to eq({:file_path=>"app/controllers/newline_controller.rb",
|
|
63
65
|
:code_smells=>[{:type=>"Duplication",
|
|
64
66
|
:method=>"\"",
|
|
65
|
-
:message=>"multiple times"}]}
|
|
67
|
+
:message=>"multiple times"}]})
|
|
66
68
|
# Note: hopefully a temporary solution until I figure out how to deal with newlines in the method call more effectively -Jake 5/11/2009
|
|
67
69
|
end
|
|
68
70
|
end
|
|
@@ -107,28 +109,28 @@ app/controllers/newline_controller.rb -- 1 warnings:
|
|
|
107
109
|
context 'with Reek 1.1 output format' do
|
|
108
110
|
it 'reports 1.1 style when the output is empty' do
|
|
109
111
|
@reek.instance_variable_set(:@output, "")
|
|
110
|
-
@reek.
|
|
112
|
+
expect(@reek).not_to be_reek_12
|
|
111
113
|
end
|
|
112
114
|
it 'detects 1.1 format output' do
|
|
113
115
|
@reek.instance_variable_set(:@output, @lines11)
|
|
114
|
-
@reek.
|
|
116
|
+
expect(@reek).not_to be_reek_12
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
it 'massages empty output to be unchanged' do
|
|
118
120
|
@reek.instance_variable_set(:@output, "")
|
|
119
|
-
@reek.massage_for_reek_12.
|
|
121
|
+
expect(@reek.massage_for_reek_12).to be_empty
|
|
120
122
|
end
|
|
121
123
|
end
|
|
122
124
|
|
|
123
125
|
context 'with Reek 1.2 output format' do
|
|
124
126
|
it 'detects 1.2 format output' do
|
|
125
127
|
@reek.instance_variable_set(:@output, @lines12)
|
|
126
|
-
@reek.
|
|
128
|
+
expect(@reek).to be_reek_12
|
|
127
129
|
end
|
|
128
130
|
|
|
129
131
|
it 'correctly massages 1.2 output' do
|
|
130
132
|
@reek.instance_variable_set(:@output, @lines12)
|
|
131
|
-
@reek.massage_for_reek_12.
|
|
133
|
+
expect(@reek.massage_for_reek_12).to eq(@lines11)
|
|
132
134
|
end
|
|
133
135
|
end
|
|
134
136
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
+
MetricFu.metrics_require { 'roodi/roodi_grapher' }
|
|
2
3
|
|
|
3
4
|
describe RoodiGrapher do
|
|
4
5
|
before :each do
|
|
@@ -7,14 +8,14 @@ describe RoodiGrapher do
|
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
it "should respond to roodi_count and labels" do
|
|
10
|
-
@roodi_grapher.
|
|
11
|
-
@roodi_grapher.
|
|
11
|
+
expect(@roodi_grapher).to respond_to(:roodi_count)
|
|
12
|
+
expect(@roodi_grapher).to respond_to(:labels)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
describe "responding to #initialize" do
|
|
15
16
|
it "should initialise roodi_count and labels" do
|
|
16
|
-
@roodi_grapher.roodi_count.
|
|
17
|
-
@roodi_grapher.labels.
|
|
17
|
+
expect(@roodi_grapher.roodi_count).to eq([])
|
|
18
|
+
expect(@roodi_grapher.labels).to eq({})
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -26,12 +27,12 @@ describe RoodiGrapher do
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
it "should not push to roodi_count" do
|
|
29
|
-
@roodi_grapher.roodi_count.
|
|
30
|
+
expect(@roodi_grapher.roodi_count).not_to receive(:push)
|
|
30
31
|
@roodi_grapher.get_metrics(@metrics, @date)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
it "should not update labels with the date" do
|
|
34
|
-
@roodi_grapher.labels.
|
|
35
|
+
expect(@roodi_grapher.labels).not_to receive(:update)
|
|
35
36
|
@roodi_grapher.get_metrics(@metrics, @date)
|
|
36
37
|
end
|
|
37
38
|
end
|
|
@@ -43,12 +44,12 @@ describe RoodiGrapher do
|
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
it "should push to roodi_count" do
|
|
46
|
-
@roodi_grapher.roodi_count.
|
|
47
|
+
expect(@roodi_grapher.roodi_count).to receive(:push).with(13)
|
|
47
48
|
@roodi_grapher.get_metrics(@metrics, @date)
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
it "should update labels with the date" do
|
|
51
|
-
@roodi_grapher.labels.
|
|
52
|
+
expect(@roodi_grapher.labels).to receive(:update).with({ 0 => "1/2" })
|
|
52
53
|
@roodi_grapher.get_metrics(@metrics, @date)
|
|
53
54
|
end
|
|
54
55
|
end
|