metric_fu 4.3.1 → 4.4.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.
- checksums.yaml +7 -0
- data/.metrics +55 -26
- data/.travis.yml +4 -1
- data/AUTHORS +12 -0
- data/Gemfile +1 -0
- data/HISTORY.md +24 -0
- data/README.md +27 -22
- data/checksum/metric_fu-4.3.1.gem.sha512 +1 -0
- data/checksum/metric_fu-4.4.0.gem.sha512 +1 -0
- data/lib/metric_fu.rb +28 -79
- data/lib/metric_fu/cli/helper.rb +1 -1
- data/lib/metric_fu/cli/parser.rb +1 -1
- data/lib/metric_fu/configuration.rb +104 -150
- data/lib/metric_fu/environment.rb +88 -0
- data/lib/metric_fu/formatter.rb +23 -0
- data/lib/metric_fu/formatter/html.rb +12 -9
- data/lib/metric_fu/initial_requires.rb +1 -0
- data/lib/metric_fu/io.rb +60 -1
- data/lib/metric_fu/load_files.rb +4 -2
- data/lib/metric_fu/loader.rb +62 -0
- data/lib/metric_fu/metric.rb +102 -0
- data/lib/metric_fu/metrics/base_template.rb +15 -9
- data/lib/metric_fu/metrics/cane/cane.rb +9 -5
- data/lib/metric_fu/metrics/cane/init.rb +35 -13
- data/lib/metric_fu/metrics/churn/churn.rb +5 -1
- data/lib/metric_fu/metrics/churn/init.rb +24 -4
- data/lib/metric_fu/metrics/flay/flay.rb +7 -3
- data/lib/metric_fu/metrics/flay/init.rb +29 -13
- data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +1 -1
- data/lib/metric_fu/metrics/flog/flog.rb +14 -38
- data/lib/metric_fu/metrics/flog/init.rb +30 -7
- data/lib/metric_fu/metrics/generator.rb +21 -6
- data/lib/metric_fu/metrics/graph.rb +2 -2
- data/lib/metric_fu/metrics/hotspots/hotspots.rb +5 -1
- data/lib/metric_fu/metrics/hotspots/init.rb +21 -5
- data/lib/metric_fu/metrics/rails_best_practices/init.rb +29 -5
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +20 -27
- data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +1 -1
- data/lib/metric_fu/metrics/rcov/init.rb +40 -15
- data/lib/metric_fu/metrics/rcov/rcov.rb +15 -10
- data/lib/metric_fu/metrics/reek/init.rb +25 -6
- data/lib/metric_fu/metrics/reek/reek.rb +52 -31
- data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +1 -1
- data/lib/metric_fu/metrics/roodi/init.rb +25 -6
- data/lib/metric_fu/metrics/roodi/roodi.rb +7 -3
- data/lib/metric_fu/metrics/saikuro/init.rb +22 -6
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +8 -3
- data/lib/metric_fu/metrics/stats/init.rb +28 -5
- data/lib/metric_fu/metrics/stats/stats.rb +24 -6
- data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +2 -2
- data/lib/metric_fu/parser_ext.rb +15 -0
- data/lib/metric_fu/reporting/graphs/engines/gchart.rb +1 -1
- data/lib/metric_fu/reporting/graphs/engines/init.rb +18 -4
- data/lib/metric_fu/reporting/graphs/grapher.rb +1 -1
- data/lib/metric_fu/reporting/result.rb +13 -6
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +1 -1
- data/lib/metric_fu/run.rb +7 -10
- data/lib/metric_fu/sexp_ext.rb +11 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +23 -20
- data/spec/cli/helper_spec.rb +5 -16
- data/spec/metric_fu/configuration_spec.rb +62 -88
- data/spec/metric_fu/formatter/html_spec.rb +26 -16
- data/spec/metric_fu/formatter/yaml_spec.rb +2 -2
- data/spec/metric_fu/metric_spec.rb +50 -0
- data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
- data/spec/metric_fu/metrics/cane/cane_spec.rb +19 -24
- data/spec/metric_fu/metrics/churn/churn_spec.rb +8 -8
- data/spec/metric_fu/metrics/flay/flay_spec.rb +7 -13
- data/spec/metric_fu/metrics/flog/flog_spec.rb +63 -58
- data/spec/metric_fu/metrics/generator_spec.rb +4 -0
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +7 -7
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +14 -33
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +17 -18
- data/spec/metric_fu/metrics/reek/reek_spec.rb +9 -10
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +5 -11
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +15 -14
- data/spec/metric_fu/metrics/stats/stats_spec.rb +5 -6
- data/spec/metric_fu/reporting/graphs/engines/bluff_spec.rb +2 -3
- data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +12 -9
- data/spec/metric_fu/reporting/result_spec.rb +3 -3
- data/spec/run_spec.rb +45 -29
- data/spec/spec_helper.rb +7 -0
- data/spec/support/helper_methods.rb +9 -0
- data/spec/support/suite.rb +17 -11
- metadata +59 -56
- data/bin/mf-rails_best_practices +0 -9
- data/bin/mf-stats +0 -7
@@ -1,72 +1,77 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
describe Flog do
|
3
|
-
if MetricFu.configuration.mri?
|
4
|
-
before :each do
|
5
|
-
MetricFu::Configuration.run {}
|
6
|
-
File.stub(:directory?).and_return(true)
|
7
|
-
@flog = MetricFu::Flog.new('base_dir')
|
8
|
-
end
|
9
2
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
describe MetricFu::FlogGenerator do
|
4
|
+
|
5
|
+
break if metric_not_activated?(:flog)
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
File.stub(:directory?).and_return(true)
|
9
|
+
options = MetricFu::Metric.get_metric(:flog).run_options
|
10
|
+
@flog = MetricFu::FlogGenerator.new(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "emit method" do
|
14
|
+
it "should look for files and flog them" do
|
15
|
+
FlogCLI.should_receive(:parse_options).with(["--all","--continue"]).and_return("options")
|
16
|
+
FlogCLI.should_receive(:new).with("options").and_return(flogger = double('flogger'))
|
17
|
+
flogger.should_receive(:flog).with("lib")
|
18
|
+
@flog.emit
|
18
19
|
end
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
describe "analyze method" do
|
23
|
+
it "should harvest the flog information and put it into method_containers" do
|
24
|
+
first_full_method_name = "ClassName#first_method_name"
|
25
|
+
second_full_method_name = "ClassName#second_method_name"
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
flogger = double('flogger', :method_locations => {first_full_method_name => '/file/location.rb:11',
|
28
|
+
second_full_method_name => '/file/location.rb:22'},
|
29
|
+
:totals => {first_full_method_name => 11.11,
|
30
|
+
second_full_method_name => 22.22})
|
31
|
+
flogger.should_receive(:calculate)
|
32
|
+
flogger.should_receive(:each_by_score).and_yield(
|
33
|
+
first_full_method_name, 11.11, {:branch => 11.1, :puts => 1.1}
|
34
|
+
).and_yield(
|
35
|
+
second_full_method_name, 22.22, {:branch => 22.2, :puts => 2.2}
|
36
|
+
)
|
37
|
+
@flog.instance_variable_set(:@flogger, flogger)
|
38
|
+
@flog.analyze
|
39
|
+
method_containers = @flog.instance_variable_get(:@method_containers)
|
40
|
+
method_containers.size.should == 1
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
expected={:methods=>{"ClassName#first_method_name" => { :path=>"/file/location.rb:11",
|
43
|
+
:score=>11.11,
|
44
|
+
:operators=>{ :branch=>11.1,
|
45
|
+
:puts=>1.1}},
|
46
|
+
"ClassName#second_method_name" => {:path=>"/file/location.rb:22",
|
47
|
+
:score=>22.22,
|
48
|
+
:operators=>{ :branch=>22.2,
|
49
|
+
:puts=>2.2}}},
|
50
|
+
:path=>"/file/location.rb",
|
51
|
+
:average_score=>((11.11 + 22.22) / 2.0),
|
52
|
+
:total_score=>33.33,
|
53
|
+
:highest_score=>22.22,
|
54
|
+
:name=>"ClassName"}
|
49
55
|
|
50
|
-
|
51
|
-
end
|
56
|
+
method_containers["ClassName"].to_h.should == expected
|
52
57
|
end
|
58
|
+
end
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
expected = {:flog => { :total => 111.1,
|
64
|
-
:average => 7.3,
|
65
|
-
:method_containers => ['container_2', 'container_3', 'container_1']}}
|
60
|
+
describe "to_h method" do
|
61
|
+
it "should make-a nice hash" do
|
62
|
+
flogger = double('flogger', :total_score => 111.1, :average => 7.3)
|
63
|
+
@flog.instance_variable_set(:@flogger, flogger)
|
64
|
+
method_containers = {:ignore_me_1 => double('container_1', :highest_score => 11.1, :to_h => 'container_1'),
|
65
|
+
:ignore_me_2 => double('container_2', :highest_score => 33.3, :to_h => 'container_2'),
|
66
|
+
:ignore_me_3 => double('container_3', :highest_score => 22.2, :to_h => 'container_3')}
|
67
|
+
@flog.instance_variable_set(:@method_containers, method_containers)
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
+
expected = {:flog => { :total => 111.1,
|
70
|
+
:average => 7.3,
|
71
|
+
:method_containers => ['container_2', 'container_3', 'container_1']}}
|
69
72
|
|
73
|
+
@flog.to_h.should == expected
|
70
74
|
end
|
75
|
+
|
71
76
|
end
|
72
77
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'multi_json'
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe MetricFu::HotspotsGenerator do
|
5
5
|
|
6
6
|
describe "analyze method" do
|
7
7
|
before :each do
|
@@ -59,32 +59,32 @@ END
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should be empty on error" do
|
62
|
-
hotspots = MetricFu::
|
62
|
+
hotspots = MetricFu::HotspotsGenerator.new
|
63
63
|
hotspots.instance_variable_set(:@analyzer, nil)
|
64
64
|
result = hotspots.analyze
|
65
65
|
result.should == {}
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should return yaml results" do
|
69
|
-
hotspots = MetricFu::
|
69
|
+
hotspots = MetricFu::HotspotsGenerator.new
|
70
70
|
analyzer = HotspotAnalyzer.new(@yaml)
|
71
71
|
hotspots.instance_variable_set(:@analyzer, analyzer)
|
72
72
|
result = hotspots.analyze
|
73
73
|
expected = MultiJson.load("{\"methods\":[{\"location\":{\"class_name\":\"Client\",\"method_name\":\"Client#client_requested_sync\",\"file_path\":\"lib/client/client.rb\",\"hash\":7919384682,\"simple_method_name\":\"#client_requested_sync\"},\"details\":{\"reek\":\"found 1 code smells\",\"flog\":\"complexity is 37.9\"}}],\"classes\":[{\"location\":{\"class_name\":\"Client\",\"method_name\":null,\"file_path\":\"lib/client/client.rb\",\"hash\":7995629750},\"details\":{\"reek\":\"found 2 code smells\",\"flog\":\"complexity is 37.9\"}}],\"files\":[{\"location\":{\"class_name\":null,\"method_name\":null,\"file_path\":\"lib/client/client.rb\",\"hash\":-5738801681},\"details\":{\"reek\":\"found 2 code smells\",\"flog\":\"complexity is 37.9\",\"churn\":\"detected high level of churn (changed 54 times)\"}},{\"location\":{\"class_name\":null,\"method_name\":null,\"file_path\":\"lib/client/foo.rb\",\"hash\":-7081271905},\"details\":{\"churn\":\"detected high level of churn (changed 52 times)\"}}]}")
|
74
|
-
compare_hashes(MultiJson.load(hotspots.to_h[:hotspots]
|
74
|
+
compare_hashes(MultiJson.load(MultiJson.dump(hotspots.to_h[:hotspots])), expected)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should put the changes into a hash" do
|
78
|
-
hotspots = MetricFu::
|
78
|
+
hotspots = MetricFu::HotspotsGenerator.new
|
79
79
|
analyzer = HotspotAnalyzer.new(@yaml)
|
80
80
|
hotspots.instance_variable_set(:@analyzer, analyzer)
|
81
81
|
hotspots.analyze
|
82
82
|
expected = MultiJson.load("{\"methods\":[{\"location\":{\"class_name\":\"Client\",\"method_name\":\"Client#client_requested_sync\",\"file_path\":\"lib/client/client.rb\",\"hash\":7919384682,\"simple_method_name\":\"#client_requested_sync\"},\"details\":{\"reek\":\"found 1 code smells\",\"flog\":\"complexity is 37.9\"}}],\"classes\":[{\"location\":{\"class_name\":\"Client\",\"method_name\":null,\"file_path\":\"lib/client/client.rb\",\"hash\":7995629750},\"details\":{\"reek\":\"found 2 code smells\",\"flog\":\"complexity is 37.9\"}}],\"files\":[{\"location\":{\"class_name\":null,\"method_name\":null,\"file_path\":\"lib/client/client.rb\",\"hash\":-5738801681},\"details\":{\"reek\":\"found 2 code smells\",\"flog\":\"complexity is 37.9\",\"churn\":\"detected high level of churn (changed 54 times)\"}},{\"location\":{\"class_name\":null,\"method_name\":null,\"file_path\":\"lib/client/foo.rb\",\"hash\":-7081271905},\"details\":{\"churn\":\"detected high level of churn (changed 52 times)\"}}]}")
|
83
|
-
compare_hashes(MultiJson.load(hotspots.to_h[:hotspots]
|
83
|
+
compare_hashes(MultiJson.load(MultiJson.dump(hotspots.to_h[:hotspots])), expected)
|
84
84
|
end
|
85
85
|
# really testing the output of analyzed_problems#worst_items
|
86
86
|
it "should return the worst item granularities: files, classes, methods" do
|
87
|
-
hotspots = MetricFu::
|
87
|
+
hotspots = MetricFu::HotspotsGenerator.new
|
88
88
|
analyzer = HotspotAnalyzer.new(@yaml)
|
89
89
|
hotspots.instance_variable_set(:@analyzer, analyzer)
|
90
90
|
hotspots.analyze.keys.should =~ [:files, :classes, :methods]
|
@@ -1,43 +1,24 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RailsBestPracticesGenerator do
|
4
|
+
|
5
|
+
break if metric_not_activated?(:rails_best_practices)
|
6
|
+
|
4
7
|
describe "emit method" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
practices.emit
|
8
|
+
let(:analyzer) { ::RailsBestPractices::Analyzer.new('.', { 'silent' => true }) }
|
9
|
+
context "RailsBestPractices provides the expected API" do
|
10
|
+
it { analyzer.should respond_to :analyze }
|
11
|
+
it { analyzer.should respond_to :errors }
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
15
|
describe "analyze method" do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Found 2 errors.
|
22
|
-
HERE
|
23
|
-
MetricFu::Configuration.run {}
|
24
|
-
practices = MetricFu::RailsBestPractices.new
|
25
|
-
practices.instance_variable_set(:@output, output)
|
26
|
-
@results = practices.analyze
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should get the total" do
|
30
|
-
@results[:total].should == ["Found 2 errors."]
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should get the problems" do
|
34
|
-
@results[:problems].size.should == 2
|
35
|
-
@results[:problems].first.should == { :line => "17",
|
36
|
-
:problem => "replace instance variable with local variable",
|
37
|
-
:file => "app/views/admin/testimonials/_form.html.erb" }
|
38
|
-
@results[:problems][1].should == { :line => "24,45,68,85",
|
39
|
-
:problem => "use before_filter for show,edit,update,destroy",
|
40
|
-
:file => "app/controllers/admin/campaigns_controller.rb" }
|
16
|
+
let(:error) { ::RailsBestPractices::Core::Error.new }
|
17
|
+
context "RailsBestPractices provdies the expected API" do
|
18
|
+
it { error.should respond_to :filename }
|
19
|
+
it { error.should respond_to :line_number }
|
20
|
+
it { error.should respond_to :message }
|
21
|
+
it { error.should respond_to :url }
|
41
22
|
end
|
42
23
|
end
|
43
24
|
|
@@ -1,31 +1,32 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe MetricFu::
|
3
|
+
describe MetricFu::RcovGenerator do
|
4
4
|
|
5
5
|
before :each do
|
6
|
-
MetricFu.
|
7
|
-
|
8
|
-
|
9
|
-
@
|
6
|
+
MetricFu.configuration.configure_metric(:rcov) do |rcov|
|
7
|
+
rcov.enabled = true
|
8
|
+
end
|
9
|
+
@default_options = MetricFu::Metric.get_metric(:rcov).run_options
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "emit" do
|
13
13
|
before :each do
|
14
|
-
|
15
|
-
|
14
|
+
options = {:external => nil}
|
15
|
+
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should clear out previous output and make output folder" do
|
19
19
|
@rcov.stub(:`)
|
20
|
-
FileUtils.should_receive(:rm_rf).with(MetricFu::
|
21
|
-
Dir.should_receive(:mkdir).with(MetricFu::
|
20
|
+
FileUtils.should_receive(:rm_rf).with(MetricFu::RcovGenerator.metric_directory, :verbose => false)
|
21
|
+
Dir.should_receive(:mkdir).with(MetricFu::RcovGenerator.metric_directory)
|
22
22
|
@rcov.emit
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should set the RAILS_ENV" do
|
26
26
|
FileUtils.stub(:rm_rf)
|
27
27
|
Dir.stub(:mkdir)
|
28
|
-
|
28
|
+
options = {:environment => 'metrics'}
|
29
|
+
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
29
30
|
@rcov.should_receive(:`).with(/RAILS_ENV=metrics/)
|
30
31
|
@rcov.emit
|
31
32
|
end
|
@@ -33,9 +34,10 @@ describe MetricFu::Rcov do
|
|
33
34
|
|
34
35
|
describe "with RCOV_OUTPUT fed into" do
|
35
36
|
before :each do
|
36
|
-
|
37
|
+
options = {:external => nil}
|
38
|
+
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
37
39
|
File.should_receive(:open).
|
38
|
-
with(MetricFu::
|
40
|
+
with(MetricFu::RcovGenerator.metric_directory + '/rcov.txt').
|
39
41
|
and_return(double("io", :read => RCOV_OUTPUT))
|
40
42
|
@files = @rcov.analyze
|
41
43
|
end
|
@@ -65,8 +67,8 @@ describe MetricFu::Rcov do
|
|
65
67
|
end
|
66
68
|
describe "with external configuration option set" do
|
67
69
|
before :each do
|
68
|
-
|
69
|
-
|
70
|
+
options = {:external => 'coverage/rcov.txt'}
|
71
|
+
@rcov = MetricFu::RcovGenerator.new(@default_options.merge(options))
|
70
72
|
end
|
71
73
|
|
72
74
|
it "should emit nothing if external configuration option is set" do
|
@@ -76,7 +78,7 @@ describe MetricFu::Rcov do
|
|
76
78
|
|
77
79
|
it "should open the external rcov analysis file" do
|
78
80
|
File.should_receive(:open).
|
79
|
-
with(
|
81
|
+
with('coverage/rcov.txt').
|
80
82
|
and_return(double("io", :read => RCOV_OUTPUT))
|
81
83
|
@files = @rcov.analyze
|
82
84
|
end
|
@@ -176,6 +178,3 @@ lib/templates/standard/standard_template.rb
|
|
176
178
|
HERE
|
177
179
|
|
178
180
|
end
|
179
|
-
|
180
|
-
|
181
|
-
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe MetricFu::ReekGenerator do
|
4
4
|
describe "emit" do
|
5
5
|
it "should include config parameters" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
reek
|
11
|
-
reek.should_receive(:`).with(/--config lib\/config\/\*\.reek/).and_return("")
|
6
|
+
options = {:config_file_pattern => 'lib/config/*.reek', :dirs_to_reek => []}
|
7
|
+
reek = MetricFu::ReekGenerator.new(options)
|
8
|
+
files_to_analyze = ['lib/foo.rb','lib/bar.rb']
|
9
|
+
reek.stub(:files_to_analyze).and_return(files_to_analyze)
|
10
|
+
reek.should_receive(:`).with(/--config lib\/config\/\*\.reek lib\/foo.rb lib\/bar.rb/).and_return("")
|
12
11
|
reek.emit
|
13
12
|
end
|
14
13
|
end
|
@@ -33,7 +32,7 @@ NewlineController#some_method calls current_user.<< "new line\n" multiple times
|
|
33
32
|
HERE
|
34
33
|
MetricFu::Configuration.run {}
|
35
34
|
File.stub(:directory?).and_return(true)
|
36
|
-
reek = MetricFu::
|
35
|
+
reek = MetricFu::ReekGenerator.new
|
37
36
|
reek.instance_variable_set(:@output, @lines)
|
38
37
|
@matches = reek.analyze
|
39
38
|
end
|
@@ -70,10 +69,10 @@ NewlineController#some_method calls current_user.<< "new line\n" multiple times
|
|
70
69
|
|
71
70
|
end
|
72
71
|
|
73
|
-
describe
|
72
|
+
describe MetricFu::ReekGenerator do
|
74
73
|
before :each do
|
75
74
|
MetricFu::Configuration.run {}
|
76
|
-
@reek = MetricFu::
|
75
|
+
@reek = MetricFu::ReekGenerator.new
|
77
76
|
@lines11 = <<-HERE
|
78
77
|
"app/controllers/activity_reports_controller.rb" -- 4 warnings:
|
79
78
|
ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
|
@@ -1,23 +1,17 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe MetricFu::RoodiGenerator do
|
4
4
|
describe "emit" do
|
5
5
|
it "should add config options when present" do
|
6
|
-
|
7
|
-
|
8
|
-
config.configure_metric(:roodi,{:roodi_config => 'lib/config/roodi_config.yml', :dirs_to_roodi => []})
|
9
|
-
end
|
10
|
-
roodi = MetricFu::Roodi.new
|
6
|
+
options = {:roodi_config => 'lib/config/roodi_config.yml', :dirs_to_roodi => []}
|
7
|
+
roodi = MetricFu::RoodiGenerator.new(options)
|
11
8
|
roodi.should_receive(:`).with(/-config=lib\/config\/roodi_config\.yml/).and_return("")
|
12
9
|
roodi.emit
|
13
10
|
end
|
14
11
|
|
15
12
|
it "should NOT add config options when NOT present" do
|
16
|
-
|
17
|
-
|
18
|
-
config.configure_metric(:roodi,{:dirs_to_roodi => []})
|
19
|
-
end
|
20
|
-
roodi = MetricFu::Roodi.new
|
13
|
+
options = {:dirs_to_roodi => []}
|
14
|
+
roodi = MetricFu::RoodiGenerator.new(options)
|
21
15
|
roodi.stub(:`)
|
22
16
|
roodi.should_receive(:`).with(/-config/).never
|
23
17
|
roodi.emit
|
@@ -3,10 +3,11 @@ require "spec_helper"
|
|
3
3
|
describe Saikuro do
|
4
4
|
describe "to_h method" do
|
5
5
|
before :all do
|
6
|
-
|
7
|
-
|
8
|
-
saikuro
|
9
|
-
|
6
|
+
options = {}
|
7
|
+
saikuro = MetricFu::Saikuro.new(options)
|
8
|
+
def saikuro.metric_directory
|
9
|
+
"#{resources_path}/saikuro"
|
10
|
+
end
|
10
11
|
saikuro.analyze
|
11
12
|
@output = saikuro.to_h
|
12
13
|
end
|
@@ -33,17 +34,18 @@ describe Saikuro do
|
|
33
34
|
@output[:saikuro][:methods].first[:lines].should == 15
|
34
35
|
end
|
35
36
|
end
|
36
|
-
|
37
|
+
|
37
38
|
describe "per_file_info method" do
|
38
39
|
before :all do
|
39
|
-
|
40
|
-
|
41
|
-
@saikuro
|
42
|
-
|
40
|
+
options = {}
|
41
|
+
@saikuro = MetricFu::Saikuro.new(options)
|
42
|
+
def @saikuro.metric_directory
|
43
|
+
"#{resources_path}/saikuro"
|
44
|
+
end
|
43
45
|
@saikuro.analyze
|
44
46
|
@output = @saikuro.to_h
|
45
47
|
end
|
46
|
-
|
48
|
+
|
47
49
|
it "doesn't try to get information if the file does not exist" do
|
48
50
|
File.should_receive(:exists?).at_least(:once).and_return(false)
|
49
51
|
@saikuro.per_file_info('ignore_me')
|
@@ -52,11 +54,10 @@ describe Saikuro do
|
|
52
54
|
|
53
55
|
describe "format_directories method" do
|
54
56
|
it "should format the directories" do
|
55
|
-
|
56
|
-
|
57
|
-
saikuro = MetricFu::Saikuro.new
|
57
|
+
options = {:input_directory =>["app", "lib"]}
|
58
|
+
saikuro = MetricFu::Saikuro.new(options)
|
58
59
|
|
59
|
-
MetricFu.saikuro
|
60
|
+
MetricFu::Metric.get_metric(:saikuro).run_options
|
60
61
|
|
61
62
|
saikuro.format_directories.should == "\"app | lib\""
|
62
63
|
end
|