metric_fu 4.4.4 → 4.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.metrics +0 -3
- data/.travis.yml +1 -1
- data/.yardopts +0 -1
- data/CONTRIBUTING.md +1 -0
- data/CONTRIBUTORS +61 -2
- data/Gemfile +14 -11
- data/Gemfile.devtools +40 -0
- data/Guardfile +30 -0
- data/HISTORY.md +54 -1
- data/README.md +86 -56
- data/bin/mf-cane +8 -6
- data/bin/mf-churn +8 -7
- data/bin/mf-flay +8 -7
- data/bin/mf-reek +8 -7
- data/bin/mf-roodi +8 -7
- data/bin/mf-saikuro +8 -6
- data/certs/bf4.pem +22 -0
- data/checksum/metric_fu-4.4.4.gem.sha512 +1 -0
- data/checksum/metric_fu-4.5.0.gem.sha512 +1 -0
- data/etc/README.md +16 -0
- data/etc/erd.dot +173 -0
- data/etc/erd.png +0 -0
- data/lib/metric_fu.rb +56 -12
- data/lib/metric_fu/cli/helper.rb +8 -2
- data/lib/metric_fu/cli/parser.rb +86 -50
- data/lib/metric_fu/configuration.rb +4 -31
- data/lib/metric_fu/environment.rb +1 -1
- data/lib/metric_fu/formatter/html.rb +5 -5
- data/lib/metric_fu/gem_run.rb +68 -0
- data/lib/metric_fu/gem_version.rb +57 -0
- data/lib/metric_fu/io.rb +1 -1
- data/lib/metric_fu/load_files.rb +3 -5
- data/lib/metric_fu/loader.rb +31 -2
- data/lib/metric_fu/logging/mf_debugger.rb +1 -0
- data/lib/metric_fu/metric.rb +23 -1
- data/lib/metric_fu/metrics/cane/cane.rb +7 -3
- data/lib/metric_fu/metrics/cane/cane_grapher.rb +19 -0
- data/lib/metric_fu/metrics/cane/template_awesome/cane.html.erb +0 -4
- data/lib/metric_fu/metrics/churn/churn.rb +6 -7
- data/lib/metric_fu/metrics/flay/flay.rb +2 -4
- data/lib/metric_fu/metrics/flay/flay_grapher.rb +19 -0
- data/lib/metric_fu/metrics/flay/template_awesome/flay.html.erb +0 -4
- data/lib/metric_fu/metrics/flog/flog.rb +0 -2
- data/lib/metric_fu/metrics/flog/flog_grapher.rb +19 -0
- data/lib/metric_fu/metrics/flog/template_awesome/flog.html.erb +0 -4
- data/lib/metric_fu/metrics/generator.rb +34 -24
- data/lib/metric_fu/metrics/graph.rb +8 -14
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +7 -5
- data/lib/metric_fu/metrics/hotspots/template_awesome/hotspots.html.erb +4 -6
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices.rb +0 -2
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher.rb +19 -0
- data/lib/metric_fu/metrics/rails_best_practices/template_awesome/rails_best_practices.html.erb +0 -4
- data/lib/metric_fu/metrics/rcov/rcov_grapher.rb +19 -0
- data/lib/metric_fu/metrics/rcov/template_awesome/rcov.html.erb +0 -4
- data/lib/metric_fu/metrics/reek/init.rb +1 -1
- data/lib/metric_fu/metrics/reek/reek.rb +12 -8
- data/lib/metric_fu/metrics/reek/reek_grapher.rb +19 -0
- data/lib/metric_fu/metrics/reek/template_awesome/reek.html.erb +0 -4
- data/lib/metric_fu/metrics/roodi/roodi.rb +2 -3
- data/lib/metric_fu/metrics/roodi/roodi_grapher.rb +19 -0
- data/lib/metric_fu/metrics/roodi/template_awesome/roodi.html.erb +0 -4
- data/lib/metric_fu/metrics/saikuro/saikuro.rb +69 -33
- data/lib/metric_fu/metrics/saikuro/scratch_file.rb +8 -9
- data/lib/metric_fu/metrics/stats/stats_grapher.rb +20 -0
- data/lib/metric_fu/metrics/stats/template_awesome/stats.html.erb +0 -4
- data/lib/metric_fu/reporting/graphs/grapher.rb +69 -3
- data/lib/metric_fu/reporting/result.rb +5 -1
- data/lib/metric_fu/reporting/templates/awesome/awesome_template.rb +7 -3
- data/lib/metric_fu/run.rb +13 -7
- data/lib/metric_fu/tasks/metric_fu.rake +50 -3
- data/lib/metric_fu/utility.rb +10 -0
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +7 -4
- data/spec/dummy/.gitignore +1 -0
- data/spec/dummy/.gitkeep +0 -0
- data/spec/dummy/.metrics +4 -0
- data/spec/dummy/lib/.gitkeep +0 -0
- data/spec/dummy/spec/.gitkeep +0 -0
- data/spec/{resources/yml → fixtures}/20090630.yml +1 -1
- data/spec/{resources/yml → fixtures}/hotspots/flog.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/generator.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/generator_analysis.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/reek.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/roodi.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/saikuro.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/several_metrics.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/stats.yml +0 -0
- data/spec/{resources/yml → fixtures}/hotspots/three_metrics_on_same_file.yml +0 -0
- data/spec/{resources → fixtures}/line_numbers/foo.rb +0 -0
- data/spec/{resources → fixtures}/line_numbers/module.rb +0 -0
- data/spec/{resources → fixtures}/line_numbers/module_surrounds_class.rb +0 -0
- data/spec/{resources → fixtures}/line_numbers/two_classes.rb +0 -0
- data/spec/{resources/yml → fixtures}/metric_missing.yml +0 -0
- data/spec/{resources → fixtures}/saikuro/app/controllers/sessions_controller.rb_cyclo.html +0 -0
- data/spec/{resources → fixtures}/saikuro/app/controllers/users_controller.rb_cyclo.html +0 -0
- data/spec/{resources → fixtures}/saikuro/index_cyclo.html +0 -0
- data/spec/{resources → fixtures}/saikuro_sfiles/thing.rb_cyclo.html +0 -0
- data/spec/metric_fu/configuration_spec.rb +1 -1
- data/spec/metric_fu/data_structures/line_numbers_spec.rb +13 -11
- data/spec/metric_fu/formatter/html_spec.rb +2 -2
- data/spec/metric_fu/gem_version_spec.rb +14 -0
- data/spec/metric_fu/loader_spec.rb +12 -0
- data/spec/metric_fu/metrics/base_template_spec.rb +9 -7
- data/spec/metric_fu/metrics/cane/cane_spec.rb +7 -7
- data/spec/metric_fu/metrics/churn/churn_spec.rb +1 -1
- data/spec/metric_fu/metrics/flay/flay_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/flay/flay_spec.rb +2 -2
- data/spec/metric_fu/metrics/flog/flog_grapher_spec.rb +3 -3
- data/spec/metric_fu/metrics/generator_spec.rb +1 -35
- data/spec/metric_fu/metrics/graph_spec.rb +7 -24
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +2 -2
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +2 -2
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -5
- data/spec/metric_fu/metrics/hotspots/hotspots_spec.rb +2 -3
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/rails_best_practices/rails_best_practices_spec.rb +1 -1
- data/spec/metric_fu/metrics/rcov/rcov_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/rcov/rcov_spec.rb +1 -4
- data/spec/metric_fu/metrics/reek/reek_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/reek/reek_spec.rb +1 -1
- data/spec/metric_fu/metrics/roodi/roodi_grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/roodi/roodi_spec.rb +3 -3
- data/spec/metric_fu/metrics/saikuro/saikuro_spec.rb +14 -10
- data/spec/metric_fu/metrics/stats/stats_grapher_spec.rb +2 -2
- data/spec/metric_fu/reporting/graphs/{engines/bluff_spec.rb → grapher_spec.rb} +8 -2
- data/spec/{run_spec.rb → metric_fu/run_spec.rb} +8 -13
- data/spec/spec_helper.rb +30 -5
- data/spec/support/deferred_garbaged_collection.rb +34 -0
- data/spec/support/helper_methods.rb +1 -15
- data/spec/support/suite.rb +4 -24
- data/spec/support/test_fixtures.rb +39 -0
- data/spec/support/timeout.rb +7 -0
- metadata +129 -104
- metadata.gz.sig +1 -0
- data/lib/metric_fu/metrics/cane/cane_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/cane/cane_gchart_grapher.rb +0 -25
- data/lib/metric_fu/metrics/flay/flay_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/flay/flay_gchart_grapher.rb +0 -20
- data/lib/metric_fu/metrics/flog/flog_bluff_grapher.rb +0 -17
- data/lib/metric_fu/metrics/flog/flog_gchart_grapher.rb +0 -28
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/rails_best_practices/rails_best_practices_gchart_grapher.rb +0 -27
- data/lib/metric_fu/metrics/rcov/rcov_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/rcov/rcov_gchart_grapher.rb +0 -22
- data/lib/metric_fu/metrics/reek/reek_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/reek/reek_gchart_grapher.rb +0 -30
- data/lib/metric_fu/metrics/roodi/roodi_bluff_grapher.rb +0 -16
- data/lib/metric_fu/metrics/roodi/roodi_gchart_grapher.rb +0 -20
- data/lib/metric_fu/metrics/stats/stats_bluff_grapher.rb +0 -17
- data/lib/metric_fu/metrics/stats/stats_gchart_grapher.rb +0 -27
- data/lib/metric_fu/reporting/graphs/engines/bluff.rb +0 -33
- data/lib/metric_fu/reporting/graphs/engines/gchart.rb +0 -72
- data/lib/metric_fu/reporting/graphs/engines/init.rb +0 -19
- data/lib/metric_fu_requires.rb +0 -63
- data/spec/metric_fu/reporting/graphs/engines/gchart_spec.rb +0 -161
@@ -76,7 +76,7 @@ describe MetricFu::Formatter::HTML do
|
|
76
76
|
|
77
77
|
it "can open the results in the browser" do
|
78
78
|
formatter = MetricFu::Formatter::HTML.new
|
79
|
-
formatter.should_receive(:system).with("open #{
|
79
|
+
formatter.should_receive(:system).with("open #{MetricFu.run_path.join(directory('output_directory')).join('index.html')}")
|
80
80
|
formatter.finish
|
81
81
|
formatter.display_results
|
82
82
|
end
|
@@ -127,7 +127,7 @@ describe MetricFu::Formatter::HTML do
|
|
127
127
|
|
128
128
|
it "can open the results in the browser from the custom output directory" do
|
129
129
|
formatter = MetricFu::Formatter::HTML.new(output: @output)
|
130
|
-
path =
|
130
|
+
path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}/index.html")
|
131
131
|
formatter.should_receive(:system).with("open #{path}")
|
132
132
|
formatter.finish
|
133
133
|
formatter.display_results
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
MetricFu.lib_require { 'gem_version' }
|
3
|
+
|
4
|
+
describe MetricFu::GemVersion do
|
5
|
+
|
6
|
+
it 'has a list of gem deps' do
|
7
|
+
gem_version = MetricFu::GemVersion.new
|
8
|
+
gem_deps = gem_version.gem_runtime_dependencies.map(&:name)
|
9
|
+
MetricFu::Metric.metrics.reject{|metric| metric.name == :hotspots || metric.name == :stats}.map(&:name).map(&:to_s).each do |metric_name|
|
10
|
+
expect(gem_deps).to include(metric_name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MetricFu do
|
4
|
+
|
5
|
+
it "loads the .metrics file" do
|
6
|
+
# Global only for testing that this file gets loaded
|
7
|
+
$metric_file_loaded = false
|
8
|
+
MetricFu.loader.load_user_configuration
|
9
|
+
$metric_file_loaded.should be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require 'tempfile'
|
2
3
|
require 'erb'
|
3
4
|
|
4
5
|
describe MetricFu::Template do
|
@@ -22,22 +23,23 @@ describe MetricFu::Template do
|
|
22
23
|
|
23
24
|
before(:each) do
|
24
25
|
@section = double('section')
|
25
|
-
@template.should_receive(:template).
|
26
|
-
with(@section).and_return(@section)
|
27
26
|
end
|
28
27
|
|
29
28
|
describe 'if the template exists' do
|
30
29
|
it 'should return true' do
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
Tempfile.open('file') do |file|
|
31
|
+
@template.should_receive(:template).with(@section).and_return(file.path)
|
32
|
+
result = @template.send(:template_exists?,@section)
|
33
|
+
result.should be_true
|
34
|
+
end
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
38
|
describe 'if the template does not exist' do
|
38
39
|
it 'should return false' do
|
39
|
-
|
40
|
-
|
40
|
+
path = 'path'
|
41
|
+
@template.should_receive(:template).with(@section).and_return(path)
|
42
|
+
result = @template.send(:template_exists?,@section)
|
41
43
|
result.should be_false
|
42
44
|
end
|
43
45
|
end
|
@@ -6,49 +6,49 @@ describe CaneGenerator do
|
|
6
6
|
it "should execute cane command" do
|
7
7
|
options = {}
|
8
8
|
@cane = MetricFu::CaneGenerator.new(options)
|
9
|
-
@cane.should_receive(
|
9
|
+
@cane.should_receive(:run!).with("")
|
10
10
|
output = @cane.emit
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should use abc max option" do
|
14
14
|
options = {abc_max: 20}
|
15
15
|
@cane = MetricFu::CaneGenerator.new(options)
|
16
|
-
@cane.should_receive(
|
16
|
+
@cane.should_receive(:run!).with(" --abc-max 20")
|
17
17
|
output = @cane.emit
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should use style max line length option" do
|
21
21
|
options = {line_length: 100}
|
22
22
|
@cane = MetricFu::CaneGenerator.new(options)
|
23
|
-
@cane.should_receive(
|
23
|
+
@cane.should_receive(:run!).with(" --style-measure 100")
|
24
24
|
output = @cane.emit
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should use no-doc if specified" do
|
28
28
|
options = {no_doc: 'y'}
|
29
29
|
@cane = MetricFu::CaneGenerator.new(options)
|
30
|
-
@cane.should_receive(
|
30
|
+
@cane.should_receive(:run!).with(" --no-doc")
|
31
31
|
output = @cane.emit
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should include doc violations if no_doc != 'y'" do
|
35
35
|
options = {no_doc: 'n'}
|
36
36
|
@cane = MetricFu::CaneGenerator.new(options)
|
37
|
-
@cane.should_receive(
|
37
|
+
@cane.should_receive(:run!).with("")
|
38
38
|
output = @cane.emit
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should use no-readme if specified" do
|
42
42
|
options = {no_readme: 'y'}
|
43
43
|
@cane = MetricFu::CaneGenerator.new(options)
|
44
|
-
@cane.should_receive(
|
44
|
+
@cane.should_receive(:run!).with(" --no-readme")
|
45
45
|
output = @cane.emit
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should include README violations if no_readme != 'y'" do
|
49
49
|
options = {no_readme: 'n'}
|
50
50
|
@cane = MetricFu::CaneGenerator.new(options)
|
51
|
-
@cane.should_receive(
|
51
|
+
@cane.should_receive(:run!).with("")
|
52
52
|
output = @cane.emit
|
53
53
|
end
|
54
54
|
end
|
@@ -2,12 +2,12 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe MetricFu::ChurnGenerator do
|
4
4
|
|
5
|
+
# TODO extract yaml
|
5
6
|
let(:churn_yaml) { "--- \n:churn: \n :changed_files: \n - spec/graphs/flog_grapher_spec.rb\n - spec/base/graph_spec.rb\n - lib/templates/awesome/layout.html.erb\n - lib/graphs/rcov_grapher.rb\n - lib/base/base_template.rb\n - spec/graphs/grapher_spec.rb\n - lib/templates/awesome/flog.html.erb\n - lib/templates/awesome/flay.html.erb\n - lib/graphs/roodi_grapher.rb\n - lib/graphs/reek_grapher.rb\n - HISTORY\n - spec/graphs/roodi_grapher_spec.rb\n - lib/generators/rcov.rb\n - spec/graphs/engines/gchart_spec.rb\n - spec/graphs/rcov_grapher_spec.rb\n - lib/templates/javascripts/excanvas.js\n - lib/templates/javascripts/bluff-min.js\n - spec/graphs/reek_grapher_spec.rb\n" }
|
6
7
|
|
7
8
|
let(:config_setup) {
|
8
9
|
ENV['CC_BUILD_ARTIFACTS'] = nil
|
9
10
|
MetricFu.configure.reset
|
10
|
-
File.stub(:directory?).and_return(true)
|
11
11
|
}
|
12
12
|
|
13
13
|
describe "new method" do
|
@@ -21,7 +21,7 @@ describe FlayGrapher do
|
|
21
21
|
describe "responding to #get_metrics" do
|
22
22
|
context "when metrics were not generated" do
|
23
23
|
before(:each) do
|
24
|
-
@metrics =
|
24
|
+
@metrics = FIXTURE.load_metric("metric_missing.yml")
|
25
25
|
@date = "1/2"
|
26
26
|
end
|
27
27
|
|
@@ -38,7 +38,7 @@ describe FlayGrapher do
|
|
38
38
|
|
39
39
|
context "when metrics have been generated" do
|
40
40
|
before(:each) do
|
41
|
-
@metrics =
|
41
|
+
@metrics = FIXTURE.load_metric("20090630.yml")
|
42
42
|
@date = "1/2"
|
43
43
|
end
|
44
44
|
|
@@ -7,7 +7,7 @@ describe MetricFu::FlayGenerator do
|
|
7
7
|
File.stub(:directory?).and_return(true)
|
8
8
|
@flay = MetricFu::FlayGenerator.new(options)
|
9
9
|
|
10
|
-
@flay.should_receive(
|
10
|
+
@flay.should_receive(:run!).with(" app lib")
|
11
11
|
output = @flay.emit
|
12
12
|
end
|
13
13
|
|
@@ -16,7 +16,7 @@ describe MetricFu::FlayGenerator do
|
|
16
16
|
File.stub(:directory?).and_return(true)
|
17
17
|
@flay = MetricFu::FlayGenerator.new(options)
|
18
18
|
|
19
|
-
@flay.should_receive(
|
19
|
+
@flay.should_receive(:run!).with("--mass 99 ")
|
20
20
|
output = @flay.emit
|
21
21
|
end
|
22
22
|
end
|
@@ -47,7 +47,7 @@ describe MetricFu::FlogGrapher do
|
|
47
47
|
|
48
48
|
context "when metrics were not generated" do
|
49
49
|
before(:each) do
|
50
|
-
@metrics =
|
50
|
+
@metrics = FIXTURE.load_metric('metric_missing.yml')
|
51
51
|
@date = "1/2"
|
52
52
|
end
|
53
53
|
|
@@ -69,7 +69,7 @@ describe MetricFu::FlogGrapher do
|
|
69
69
|
|
70
70
|
context "when metrics have been generated" do
|
71
71
|
before(:each) do
|
72
|
-
@metrics =
|
72
|
+
@metrics = FIXTURE.load_metric('20090630.yml')
|
73
73
|
@date = "1/2"
|
74
74
|
end
|
75
75
|
|
@@ -93,7 +93,7 @@ describe MetricFu::FlogGrapher do
|
|
93
93
|
|
94
94
|
describe "responding to #get_metrics with legacy data" do
|
95
95
|
before(:each) do
|
96
|
-
@metrics =
|
96
|
+
@metrics = FIXTURE.load_metric("20090630.yml")
|
97
97
|
|
98
98
|
@date = "1/2"
|
99
99
|
end
|
@@ -43,25 +43,6 @@ describe MetricFu::Generator do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe '@concrete_class should have hook methods for '\
|
47
|
-
+'[before|after]_[emit|analyze|to_h]' do
|
48
|
-
|
49
|
-
%w[emit analyze].each do |meth|
|
50
|
-
|
51
|
-
it "should respond to #before_#{meth}" do
|
52
|
-
@concrete_class.respond_to?("before_#{meth}".to_sym).should be_true
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should respond to #after_#{meth}" do
|
56
|
-
@concrete_class.respond_to?("after_#{meth}".to_sym).should be_true
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should respond to #before_to_h" do
|
61
|
-
@concrete_class.respond_to?("before_to_h".to_sym).should be_true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
46
|
describe "#generate_result" do
|
66
47
|
it 'should raise an error when calling #emit' do
|
67
48
|
@abstract_class = MetricFu::Generator.new
|
@@ -82,25 +63,10 @@ describe MetricFu::Generator do
|
|
82
63
|
describe "#generate_result (in a concrete class)" do
|
83
64
|
|
84
65
|
%w[emit analyze].each do |meth|
|
85
|
-
it "should call #before_#{meth}" do
|
86
|
-
@concrete_class.should_receive("before_#{meth}")
|
87
|
-
@concrete_class.generate_result
|
88
|
-
end
|
89
|
-
|
90
66
|
it "should call ##{meth}" do
|
91
67
|
@concrete_class.should_receive("#{meth}")
|
92
68
|
@concrete_class.generate_result
|
93
69
|
end
|
94
|
-
|
95
|
-
it "should call #after_#{meth}" do
|
96
|
-
@concrete_class.should_receive("after_#{meth}")
|
97
|
-
@concrete_class.generate_result
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should call #before_to_h" do
|
102
|
-
@concrete_class.should_receive("before_to_h")
|
103
|
-
@concrete_class.generate_result
|
104
70
|
end
|
105
71
|
|
106
72
|
it "should call #to_h" do
|
@@ -128,7 +94,7 @@ describe MetricFu::Generator do
|
|
128
94
|
@paths.each do |path|
|
129
95
|
@container.file(path)
|
130
96
|
end
|
131
|
-
@old_dir =
|
97
|
+
@old_dir = MetricFu.run_dir
|
132
98
|
Dir.chdir(@container)
|
133
99
|
end
|
134
100
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { 'graph' }
|
2
3
|
|
3
4
|
describe MetricFu do
|
4
5
|
|
@@ -15,30 +16,12 @@ describe MetricFu::Graph do
|
|
15
16
|
@graph = MetricFu::Graph.new
|
16
17
|
end
|
17
18
|
|
18
|
-
describe "responding to #add with gchart enabled" do
|
19
|
-
it 'should instantiate a grapher and push it to graphers' do
|
20
|
-
@graph.graphers.should_receive(:push).with(an_instance_of(RcovGchartGrapher))
|
21
|
-
@graph.add("rcov", 'gchart')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "responding to #add with gchart enabled" do
|
26
|
-
it 'should instantiate a grapher and push it to graphers' do
|
27
|
-
@graph.graphers.should_receive(:push).with(an_instance_of(RcovGchartGrapher))
|
28
|
-
@graph.add("rcov", 'gchart')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
19
|
describe "setting the date on the graph" do
|
33
|
-
next if breaks_when?(MetricFu.configuration.rubinius?)
|
34
|
-
before(:each) do
|
35
|
-
@graph.stub(:mf_log)
|
36
|
-
end
|
37
20
|
|
38
21
|
it "should set the date once for one data point" do
|
39
|
-
|
40
|
-
|
41
|
-
|
22
|
+
metric_file = "metric_fu/tmp/_data/20101105.yml"
|
23
|
+
MetricFu::Utility.should_receive(:glob).and_return([metric_file].sort)
|
24
|
+
MetricFu::Utility.should_receive(:load_yaml).with(metric_file).and_return("Metrics")
|
42
25
|
double_grapher = double
|
43
26
|
double_grapher.should_receive(:get_metrics).with("Metrics", "11/5")
|
44
27
|
double_grapher.should_receive(:graph!)
|
@@ -48,9 +31,9 @@ describe MetricFu::Graph do
|
|
48
31
|
end
|
49
32
|
|
50
33
|
it "should set the date when the data directory isn't in the default place" do
|
51
|
-
|
52
|
-
|
53
|
-
|
34
|
+
metric_file = "/some/kind/of/weird/directory/somebody/configured/_data/20101105.yml"
|
35
|
+
MetricFu::Utility.should_receive(:glob).and_return([metric_file].sort)
|
36
|
+
MetricFu::Utility.should_receive(:load_yaml).with(metric_file).and_return("Metrics")
|
54
37
|
double_grapher = double
|
55
38
|
double_grapher.should_receive(:get_metrics).with("Metrics", "11/5")
|
56
39
|
double_grapher.should_receive(:graph!)
|
@@ -26,7 +26,7 @@ describe MetricFu::HotspotAnalyzedProblems do
|
|
26
26
|
context "with several types of data" do
|
27
27
|
|
28
28
|
before do
|
29
|
-
@result_hash =
|
29
|
+
@result_hash = HOTSPOT_DATA["several_metrics.yml"]
|
30
30
|
@analyzed_problems = analyzed_problems(@result_hash)
|
31
31
|
@worst_items = @analyzed_problems.worst_items
|
32
32
|
end
|
@@ -81,7 +81,7 @@ describe MetricFu::HotspotAnalyzedProblems do
|
|
81
81
|
context "with Saikuro data" do
|
82
82
|
|
83
83
|
before do
|
84
|
-
@result_hash =
|
84
|
+
@result_hash = HOTSPOT_DATA["saikuro.yml"]
|
85
85
|
@analyzed_problems = analyzed_problems(@result_hash)
|
86
86
|
@worst_items = @analyzed_problems.worst_items
|
87
87
|
end
|
@@ -25,7 +25,7 @@ describe MetricFu::AnalyzerTables do
|
|
25
25
|
context "with Stats data" do
|
26
26
|
|
27
27
|
before do
|
28
|
-
@result_hash =
|
28
|
+
@result_hash = HOTSPOT_DATA["stats.yml"]
|
29
29
|
@table = analyzer_table(@result_hash).table
|
30
30
|
end
|
31
31
|
|
@@ -49,7 +49,7 @@ describe MetricFu::AnalyzerTables do
|
|
49
49
|
context "with three different path representations of file (from Saikuro, Flog, and Reek)" do
|
50
50
|
|
51
51
|
before do
|
52
|
-
@result_hash =
|
52
|
+
@result_hash = HOTSPOT_DATA["three_metrics_on_same_file.yml"]
|
53
53
|
@table = analyzer_table(@result_hash).table
|
54
54
|
end
|
55
55
|
|
@@ -29,13 +29,13 @@ describe MetricFu::HotspotRankings do
|
|
29
29
|
rankings(result_hash).worst_files.should == expected
|
30
30
|
end
|
31
31
|
def result_hash
|
32
|
-
@result_hash ||=
|
32
|
+
@result_hash ||= HOTSPOT_DATA["several_metrics.yml"]
|
33
33
|
end
|
34
34
|
end
|
35
35
|
context "with Reek data" do
|
36
36
|
|
37
37
|
before do
|
38
|
-
@result_hash =
|
38
|
+
@result_hash = HOTSPOT_DATA["reek.yml"]
|
39
39
|
end
|
40
40
|
|
41
41
|
it "gives worst method" do
|
@@ -54,7 +54,7 @@ describe MetricFu::HotspotRankings do
|
|
54
54
|
context "with Saikuro data" do
|
55
55
|
|
56
56
|
before do
|
57
|
-
@result_hash =
|
57
|
+
@result_hash = HOTSPOT_DATA["saikuro.yml"]
|
58
58
|
end
|
59
59
|
|
60
60
|
it "gives worst method" do
|
@@ -69,7 +69,7 @@ describe MetricFu::HotspotRankings do
|
|
69
69
|
context "with Flog data" do
|
70
70
|
|
71
71
|
before do
|
72
|
-
@result_hash =
|
72
|
+
@result_hash = HOTSPOT_DATA["flog.yml"]
|
73
73
|
end
|
74
74
|
|
75
75
|
it "gives worst method" do
|
@@ -89,7 +89,7 @@ describe MetricFu::HotspotRankings do
|
|
89
89
|
context "with Roodi data" do
|
90
90
|
|
91
91
|
before do
|
92
|
-
@result_hash =
|
92
|
+
@result_hash = HOTSPOT_DATA["roodi.yml"]
|
93
93
|
end
|
94
94
|
|
95
95
|
it "gives worst file" do
|
@@ -1,12 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe MetricFu::HotspotsGenerator do
|
4
|
-
|
5
4
|
describe "analyze method" do
|
6
5
|
before :each do
|
7
6
|
MetricFu::Configuration.run {}
|
8
7
|
File.stub(:directory?).and_return(true)
|
9
|
-
@yaml =
|
8
|
+
@yaml = HOTSPOT_DATA["generator.yml"]
|
10
9
|
end
|
11
10
|
|
12
11
|
it "should be empty on error" do
|
@@ -21,7 +20,7 @@ describe MetricFu::HotspotsGenerator do
|
|
21
20
|
hotspots = MetricFu::HotspotsGenerator.new
|
22
21
|
hotspots.analyze
|
23
22
|
result = hotspots.to_h[:hotspots]
|
24
|
-
expected =
|
23
|
+
expected = HOTSPOT_DATA["generator_analysis.yml"]
|
25
24
|
# ensure expected granularities
|
26
25
|
expect(result.keys).to eq(expected.keys)
|
27
26
|
|
@@ -21,7 +21,7 @@ describe RailsBestPracticesGrapher do
|
|
21
21
|
describe "responding to #get_metrics" do
|
22
22
|
context "when metrics were not generated" do
|
23
23
|
before(:each) do
|
24
|
-
@metrics =
|
24
|
+
@metrics = FIXTURE.load_metric("metric_missing.yml")
|
25
25
|
@date = "01022003"
|
26
26
|
end
|
27
27
|
|
@@ -38,7 +38,7 @@ describe RailsBestPracticesGrapher do
|
|
38
38
|
|
39
39
|
context "when metrics have been generated" do
|
40
40
|
before(:each) do
|
41
|
-
@metrics =
|
41
|
+
@metrics = FIXTURE.load_metric("20090630.yml")
|
42
42
|
@date = "01022003"
|
43
43
|
end
|
44
44
|
|