metric_fu 4.11.1 → 4.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +6 -0
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +69 -0
- data/.simplecov +35 -3
- data/.travis.yml +6 -10
- data/CONTRIBUTORS +12 -11
- data/Gemfile +48 -29
- data/Guardfile +9 -9
- data/HISTORY.md +47 -1
- data/README.md +70 -57
- data/Rakefile +1 -15
- data/appveyor.yml +34 -0
- data/certs/bf4.pem +20 -20
- data/checksum/metric_fu-4.11.1.gem.sha512 +1 -0
- data/checksum/metric_fu-4.11.2.gem.sha512 +1 -0
- data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
- data/checksum/metric_fu-4.11.4.gem.sha512 +1 -0
- data/checksum/metric_fu-4.12.0.gem.sha512 +1 -0
- data/checksum/metric_fu-4.13.0.gem.sha512 +1 -0
- data/config/rubocop.yml +269 -0
- data/gem_tasks/build.rake +1 -0
- data/gem_tasks/rubocop.rake +10 -0
- data/gem_tasks/yard.rake +24 -0
- data/lib/metric_fu.rb +20 -9
- data/lib/metric_fu/calculate.rb +0 -1
- data/lib/metric_fu/cli/client.rb +6 -6
- data/lib/metric_fu/cli/helper.rb +22 -13
- data/lib/metric_fu/cli/parser.rb +14 -18
- data/lib/metric_fu/configuration.rb +7 -11
- data/lib/metric_fu/constantize.rb +4 -4
- data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
- data/lib/metric_fu/data_structures/location.rb +12 -14
- data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
- data/lib/metric_fu/environment.rb +29 -31
- data/lib/metric_fu/formatter.rb +4 -6
- data/lib/metric_fu/formatter/html.rb +13 -13
- data/lib/metric_fu/formatter/syntax.rb +5 -7
- data/lib/metric_fu/formatter/yaml.rb +1 -1
- data/lib/metric_fu/gem_run.rb +13 -15
- data/lib/metric_fu/gem_version.rb +10 -12
- data/lib/metric_fu/generator.rb +6 -9
- data/lib/metric_fu/io.rb +13 -15
- data/lib/metric_fu/loader.rb +17 -18
- data/lib/metric_fu/logger.rb +15 -18
- data/lib/metric_fu/logging/mf_debugger.rb +4 -4
- data/lib/metric_fu/metric.rb +11 -12
- data/lib/metric_fu/metrics/cane/generator.rb +10 -9
- data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
- data/lib/metric_fu/metrics/cane/metric.rb +6 -8
- data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
- data/lib/metric_fu/metrics/cane/violations.rb +6 -6
- data/lib/metric_fu/metrics/churn/generator.rb +2 -6
- data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/churn/metric.rb +5 -7
- data/lib/metric_fu/metrics/flay/generator.rb +7 -11
- data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
- data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/flay/metric.rb +5 -7
- data/lib/metric_fu/metrics/flog/generator.rb +35 -24
- data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
- data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
- data/lib/metric_fu/metrics/flog/metric.rb +3 -5
- data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
- data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
- data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
- data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
- data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -17
- data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
- data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
- data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
- data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
- data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
- data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
- data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
- data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
- data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
- data/lib/metric_fu/metrics/rails_best_practices/generator.rb +14 -12
- data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
- data/lib/metric_fu/metrics/rails_best_practices/metric.rb +5 -4
- data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
- data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
- data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
- data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
- data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
- data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
- data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
- data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
- data/lib/metric_fu/metrics/reek/generator.rb +36 -82
- data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
- data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
- data/lib/metric_fu/metrics/reek/metric.rb +2 -4
- data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
- data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
- data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
- data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
- data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
- data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
- data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
- data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
- data/lib/metric_fu/metrics/stats/generator.rb +9 -12
- data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
- data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
- data/lib/metric_fu/metrics/stats/metric.rb +3 -5
- data/lib/metric_fu/reporter.rb +1 -1
- data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
- data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
- data/lib/metric_fu/reporting/result.rb +0 -3
- data/lib/metric_fu/run.rb +12 -3
- data/lib/metric_fu/tasks/metric_fu.rake +8 -8
- data/lib/metric_fu/templates/configuration.rb +2 -5
- data/lib/metric_fu/templates/metrics_template.rb +45 -32
- data/lib/metric_fu/templates/report.rb +5 -8
- data/lib/metric_fu/templates/template.rb +20 -24
- data/lib/metric_fu/utility.rb +15 -8
- data/lib/metric_fu/version.rb +7 -1
- data/metric_fu.gemspec +29 -32
- data/spec/capture_warnings.rb +29 -22
- data/spec/cli/helper_spec.rb +9 -16
- data/spec/dummy/lib/bad_encoding.rb +1 -1
- data/spec/fixtures/coverage-153.rb +2 -2
- data/spec/fixtures/coverage.rb +2 -2
- data/spec/metric_fu/calculate_spec.rb +3 -3
- data/spec/metric_fu/configuration_spec.rb +71 -83
- data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
- data/spec/metric_fu/data_structures/location_spec.rb +13 -31
- data/spec/metric_fu/formatter/configuration_spec.rb +18 -20
- data/spec/metric_fu/formatter/html_spec.rb +21 -28
- data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
- data/spec/metric_fu/formatter_spec.rb +16 -16
- data/spec/metric_fu/gem_version_spec.rb +4 -6
- data/spec/metric_fu/generator_spec.rb +33 -43
- data/spec/metric_fu/loader_spec.rb +5 -4
- data/spec/metric_fu/metric_spec.rb +21 -25
- data/spec/metric_fu/metrics/cane/configuration_spec.rb +14 -14
- data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
- data/spec/metric_fu/metrics/churn/configuration_spec.rb +7 -9
- data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
- data/spec/metric_fu/metrics/flay/configuration_spec.rb +7 -9
- data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
- data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/flog/configuration_spec.rb +12 -14
- data/spec/metric_fu/metrics/flog/generator_spec.rb +31 -32
- data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
- data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
- data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
- data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
- data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
- data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
- data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
- data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
- data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
- data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +25 -17
- data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
- data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
- data/spec/metric_fu/metrics/rcov/configuration_spec.rb +21 -23
- data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
- data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
- data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
- data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
- data/spec/metric_fu/metrics/reek/configuration_spec.rb +7 -7
- data/spec/metric_fu/metrics/reek/generator_spec.rb +131 -111
- data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
- data/spec/metric_fu/metrics/roodi/configuration_spec.rb +8 -10
- data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
- data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
- data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +22 -23
- data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
- data/spec/metric_fu/metrics/stats/generator_spec.rb +10 -10
- data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
- data/spec/metric_fu/reporter_spec.rb +8 -9
- data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
- data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
- data/spec/metric_fu/reporting/result_spec.rb +12 -14
- data/spec/metric_fu/run_spec.rb +19 -33
- data/spec/metric_fu/templates/configuration_spec.rb +34 -40
- data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
- data/spec/metric_fu/templates/report_spec.rb +4 -4
- data/spec/metric_fu/templates/template_spec.rb +78 -64
- data/spec/metric_fu/utility_spec.rb +3 -3
- data/spec/metric_fu_spec.rb +23 -6
- data/spec/quality_spec.rb +43 -15
- data/spec/shared/configured.rb +9 -11
- data/spec/shared/test_coverage.rb +5 -9
- data/spec/spec_helper.rb +13 -31
- data/spec/{dummy → support}/.metrics +0 -0
- data/spec/support/deferred_garbaged_collection.rb +1 -2
- data/spec/support/matcher_create_file.rb +6 -4
- data/spec/support/matcher_create_files.rb +6 -4
- data/spec/support/samples/reek/alfa.rb +1 -0
- data/spec/support/suite.rb +3 -3
- data/spec/support/test_fixtures.rb +5 -7
- data/spec/support/timeout.rb +1 -1
- data/spec/support/usage_test.rb +24 -25
- data/spec/usage_test_spec.rb +30 -32
- metadata +104 -103
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/gemfiles/Gemfile.travis +0 -10
- metadata.gz.sig +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "flay/grapher" }
|
3
3
|
|
4
4
|
describe FlayGrapher do
|
5
5
|
before :each do
|
@@ -49,7 +49,7 @@ describe FlayGrapher do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should update labels with the date" do
|
52
|
-
expect(@flay_grapher.labels).to receive(:update).with(
|
52
|
+
expect(@flay_grapher.labels).to receive(:update).with(0 => "1/2")
|
53
53
|
@flay_grapher.get_metrics(@metrics, @date)
|
54
54
|
end
|
55
55
|
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
describe MetricFu::Configuration, 'for flog' do
|
5
|
-
it_behaves_like 'configured' do
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
6
3
|
|
4
|
+
describe MetricFu::Configuration, "for flog" do
|
5
|
+
it_behaves_like "configured" do
|
7
6
|
if MetricFu.configuration.mri?
|
8
|
-
it
|
9
|
-
load_metric
|
10
|
-
expect(MetricFu::Metric.get_metric(:flog).run_options).to eq(
|
11
|
-
:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
it "should set @flog to {:dirs_to_flog => @code_dirs}" do
|
8
|
+
load_metric "flog"
|
9
|
+
expect(MetricFu::Metric.get_metric(:flog).run_options).to eq(
|
10
|
+
all: true,
|
11
|
+
continue: true,
|
12
|
+
dirs_to_flog: ["lib"],
|
13
|
+
quiet: true
|
14
|
+
)
|
16
15
|
end
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
18
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "flog/generator" }
|
3
3
|
|
4
4
|
describe MetricFu::FlogGenerator do
|
5
|
-
|
6
5
|
break if metric_not_activated?(:flog)
|
7
6
|
|
8
7
|
before :each do
|
@@ -13,9 +12,10 @@ describe MetricFu::FlogGenerator do
|
|
13
12
|
|
14
13
|
describe "emit method" do
|
15
14
|
it "should look for files and flog them" do
|
16
|
-
expect(FlogCLI).to receive(:parse_options).with(["--all","--continue"]).and_return("options")
|
17
|
-
expect(FlogCLI).to receive(:new).with("options").and_return(flogger = double(
|
18
|
-
|
15
|
+
expect(FlogCLI).to receive(:parse_options).with(["--all", "--continue"]).and_return("options")
|
16
|
+
expect(FlogCLI).to receive(:new).with("options").and_return(flogger = double("flogger"))
|
17
|
+
files_to_flog = Dir[File.join('lib', '**/*.{rb,rake}')]
|
18
|
+
expect(flogger).to receive(:flog).with(*files_to_flog)
|
19
19
|
@flog.emit
|
20
20
|
end
|
21
21
|
end
|
@@ -25,34 +25,34 @@ describe MetricFu::FlogGenerator do
|
|
25
25
|
first_full_method_name = "ClassName#first_method_name"
|
26
26
|
second_full_method_name = "ClassName#second_method_name"
|
27
27
|
|
28
|
-
flogger = double(
|
29
|
-
second_full_method_name =>
|
30
|
-
|
31
|
-
second_full_method_name => 22.22})
|
28
|
+
flogger = double("flogger", method_locations: { first_full_method_name => "/file/location.rb:11",
|
29
|
+
second_full_method_name => "/file/location.rb:22" },
|
30
|
+
totals: { first_full_method_name => 11.11,
|
31
|
+
second_full_method_name => 22.22 })
|
32
32
|
expect(flogger).to receive(:calculate)
|
33
33
|
expect(flogger).to receive(:each_by_score).and_yield(
|
34
|
-
first_full_method_name, 11.11,
|
34
|
+
first_full_method_name, 11.11, branch: 11.1, puts: 1.1
|
35
35
|
).and_yield(
|
36
|
-
second_full_method_name, 22.22,
|
36
|
+
second_full_method_name, 22.22, branch: 22.2, puts: 2.2
|
37
37
|
)
|
38
38
|
@flog.instance_variable_set(:@flogger, flogger)
|
39
39
|
@flog.analyze
|
40
40
|
method_containers = @flog.instance_variable_get(:@method_containers)
|
41
41
|
expect(method_containers.size).to eq(1)
|
42
42
|
|
43
|
-
expected={:
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
expected = { methods: { "ClassName#first_method_name" => { path: "/file/location.rb:11",
|
44
|
+
score: 11.11,
|
45
|
+
operators: { branch: 11.1,
|
46
|
+
puts: 1.1 } },
|
47
|
+
"ClassName#second_method_name" => { path: "/file/location.rb:22",
|
48
|
+
score: 22.22,
|
49
|
+
operators: { branch: 22.2,
|
50
|
+
puts: 2.2 } } },
|
51
|
+
path: "/file/location.rb",
|
52
|
+
average_score: ((11.11 + 22.22) / 2.0),
|
53
|
+
total_score: 33.33,
|
54
|
+
highest_score: 22.22,
|
55
|
+
name: "ClassName" }
|
56
56
|
|
57
57
|
expect(method_containers["ClassName"].to_h).to eq(expected)
|
58
58
|
end
|
@@ -60,19 +60,18 @@ describe MetricFu::FlogGenerator do
|
|
60
60
|
|
61
61
|
describe "to_h method" do
|
62
62
|
it "should make-a nice hash" do
|
63
|
-
flogger = double(
|
63
|
+
flogger = double("flogger", total_score: 111.1, average: 7.3)
|
64
64
|
@flog.instance_variable_set(:@flogger, flogger)
|
65
|
-
method_containers = {:
|
66
|
-
|
67
|
-
|
65
|
+
method_containers = { ignore_me_1: double("container_1", highest_score: 11.1, to_h: "container_1"),
|
66
|
+
ignore_me_2: double("container_2", highest_score: 33.3, to_h: "container_2"),
|
67
|
+
ignore_me_3: double("container_3", highest_score: 22.2, to_h: "container_3") }
|
68
68
|
@flog.instance_variable_set(:@method_containers, method_containers)
|
69
69
|
|
70
|
-
expected = {:
|
71
|
-
|
72
|
-
|
70
|
+
expected = { flog: { total: 111.1,
|
71
|
+
average: 7.3,
|
72
|
+
method_containers: ["container_2", "container_3", "container_1"] } }
|
73
73
|
|
74
74
|
expect(@flog.to_h).to eq(expected)
|
75
75
|
end
|
76
|
-
|
77
76
|
end
|
78
77
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "flog/grapher" }
|
3
3
|
|
4
4
|
describe MetricFu::FlogGrapher do
|
5
5
|
before :each do
|
6
6
|
MetricFu.configuration
|
7
7
|
@flog_grapher = MetricFu::FlogGrapher.new
|
8
|
-
|
9
8
|
end
|
10
9
|
|
11
10
|
it "should respond to flog_total, flog_average and labels" do
|
@@ -26,12 +25,12 @@ describe MetricFu::FlogGrapher do
|
|
26
25
|
before(:each) do
|
27
26
|
methods = {}
|
28
27
|
100.times do |i|
|
29
|
-
methods["method_name_#{i}"] = {:
|
28
|
+
methods["method_name_#{i}"] = { score: i.to_f }
|
30
29
|
end
|
31
30
|
|
32
|
-
@metrics = {:
|
33
|
-
|
34
|
-
|
31
|
+
@metrics = { flog: { total: 111.1,
|
32
|
+
average: 7.7,
|
33
|
+
method_containers: [{ methods: methods }] } }
|
35
34
|
@date = "1/2"
|
36
35
|
end
|
37
36
|
|
@@ -48,7 +47,7 @@ describe MetricFu::FlogGrapher do
|
|
48
47
|
|
49
48
|
context "when metrics were not generated" do
|
50
49
|
before(:each) do
|
51
|
-
@metrics = FIXTURE.load_metric(
|
50
|
+
@metrics = FIXTURE.load_metric("metric_missing.yml")
|
52
51
|
@date = "1/2"
|
53
52
|
end
|
54
53
|
|
@@ -70,7 +69,7 @@ describe MetricFu::FlogGrapher do
|
|
70
69
|
|
71
70
|
context "when metrics have been generated" do
|
72
71
|
before(:each) do
|
73
|
-
@metrics = FIXTURE.load_metric(
|
72
|
+
@metrics = FIXTURE.load_metric("20090630.yml")
|
74
73
|
@date = "1/2"
|
75
74
|
end
|
76
75
|
|
@@ -86,7 +85,7 @@ describe MetricFu::FlogGrapher do
|
|
86
85
|
end
|
87
86
|
|
88
87
|
it "should update labels with the date" do
|
89
|
-
expect(@flog_grapher.labels).to receive(:update).with(
|
88
|
+
expect(@flog_grapher.labels).to receive(:update).with(0 => "1/2")
|
90
89
|
@flog_grapher.get_metrics(@metrics, @date)
|
91
90
|
end
|
92
91
|
end
|
@@ -105,5 +104,4 @@ describe MetricFu::FlogGrapher do
|
|
105
104
|
@flog_grapher.get_metrics(@metrics, @date)
|
106
105
|
end
|
107
106
|
end
|
108
|
-
|
109
107
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
2
|
-
MetricFu.metrics_require {
|
1
|
+
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { "hotspots/analysis/analyzed_problems" }
|
3
3
|
|
4
4
|
describe MetricFu::HotspotAnalyzedProblems do
|
5
|
-
|
6
5
|
before do
|
7
6
|
enable_hotspots
|
8
7
|
end
|
@@ -13,7 +12,7 @@ describe MetricFu::HotspotAnalyzedProblems do
|
|
13
12
|
common_columns = %w{metric}
|
14
13
|
granularities = %w{file_path class_name method_name}
|
15
14
|
tool_analyzers = MetricFu::Hotspot.analyzers
|
16
|
-
analyzer_columns = common_columns + granularities + tool_analyzers.map
|
15
|
+
analyzer_columns = common_columns + granularities + tool_analyzers.map(&:columns).flatten
|
17
16
|
|
18
17
|
analyzer_tables = MetricFu::AnalyzerTables.new(analyzer_columns)
|
19
18
|
tool_analyzers.each do |analyzer|
|
@@ -29,7 +28,6 @@ describe MetricFu::HotspotAnalyzedProblems do
|
|
29
28
|
end
|
30
29
|
|
31
30
|
context "with several types of data" do
|
32
|
-
|
33
31
|
before do
|
34
32
|
@result_hash = HOTSPOT_DATA["several_metrics.yml"]
|
35
33
|
@analyzed_problems = analyzed_problems(@result_hash)
|
@@ -38,8 +36,8 @@ describe MetricFu::HotspotAnalyzedProblems do
|
|
38
36
|
|
39
37
|
it "gives all issues for a class" do
|
40
38
|
expected = {
|
41
|
-
:
|
42
|
-
:
|
39
|
+
reek: "found 2 code smells",
|
40
|
+
flog: "complexity is 37.9"
|
43
41
|
}
|
44
42
|
# TODO Unsure if we want to make problems_with and location public or private at this point
|
45
43
|
expect(@worst_items[:classes].first.problems).to eq(expected)
|
@@ -47,44 +45,42 @@ describe MetricFu::HotspotAnalyzedProblems do
|
|
47
45
|
|
48
46
|
it "gives all issues for a method" do
|
49
47
|
expected = {
|
50
|
-
:
|
51
|
-
:
|
48
|
+
reek: "found 1 code smells",
|
49
|
+
flog: "complexity is 37.9" }
|
52
50
|
expect(@worst_items[:methods].first.problems).to eq(expected)
|
53
51
|
end
|
54
52
|
|
55
53
|
it "gives all issues for a file" do
|
56
54
|
expected = {
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
55
|
+
reek: "found 2 code smells",
|
56
|
+
flog: "complexity is 37.9",
|
57
|
+
churn: "detected high level of churn (changed 54 times)" }
|
60
58
|
expect(@worst_items[:files].first.problems).to eq(expected)
|
61
59
|
end
|
62
60
|
|
63
61
|
it "provide location for a method" do
|
64
62
|
expected = MetricFu::Location.new("lib/client/client.rb",
|
65
|
-
|
66
|
-
|
63
|
+
"Client",
|
64
|
+
"Client#client_requested_sync")
|
67
65
|
expect(@worst_items[:methods].first.location).to eq(expected)
|
68
66
|
end
|
69
67
|
|
70
68
|
it "provides location for a class" do
|
71
69
|
expected = MetricFu::Location.new("lib/client/client.rb",
|
72
|
-
|
73
|
-
|
70
|
+
"Client",
|
71
|
+
nil)
|
74
72
|
expect(@worst_items[:classes].first.location).to eq(expected)
|
75
73
|
end
|
76
74
|
|
77
75
|
it "provides location for a file" do
|
78
76
|
expected = MetricFu::Location.new("lib/client/client.rb",
|
79
|
-
|
80
|
-
|
77
|
+
nil,
|
78
|
+
nil)
|
81
79
|
expect(@worst_items[:files].first.location).to eq(expected)
|
82
80
|
end
|
83
|
-
|
84
81
|
end
|
85
82
|
|
86
83
|
context "with Saikuro data" do
|
87
|
-
|
88
84
|
before do
|
89
85
|
@result_hash = HOTSPOT_DATA["saikuro.yml"]
|
90
86
|
@analyzed_problems = analyzed_problems(@result_hash)
|
@@ -93,18 +89,16 @@ describe MetricFu::HotspotAnalyzedProblems do
|
|
93
89
|
|
94
90
|
it "gives complexity for method" do
|
95
91
|
expected = {
|
96
|
-
:
|
92
|
+
saikuro: "complexity is 1.0"
|
97
93
|
}
|
98
94
|
expect(@worst_items[:methods].last.problems).to eq(expected)
|
99
95
|
end
|
100
96
|
|
101
97
|
it "gives average complexity for class" do
|
102
98
|
expected = {
|
103
|
-
:
|
99
|
+
saikuro: "average complexity is 5.0"
|
104
100
|
}
|
105
101
|
expect(@worst_items[:classes].last.problems).to eq(expected)
|
106
102
|
end
|
107
|
-
|
108
103
|
end
|
109
|
-
|
110
104
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
2
|
-
MetricFu.metrics_require {
|
1
|
+
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { "hotspots/analysis/analyzer_tables" }
|
3
3
|
|
4
4
|
describe MetricFu::AnalyzerTables do
|
5
|
-
|
6
5
|
before do
|
7
6
|
enable_hotspots
|
8
7
|
end
|
@@ -13,7 +12,7 @@ describe MetricFu::AnalyzerTables do
|
|
13
12
|
common_columns = %w{metric}
|
14
13
|
granularities = %w{file_path class_name method_name}
|
15
14
|
tool_analyzers = MetricFu::Hotspot.analyzers
|
16
|
-
analyzer_columns = common_columns + granularities + tool_analyzers.map
|
15
|
+
analyzer_columns = common_columns + granularities + tool_analyzers.map(&:columns).flatten
|
17
16
|
|
18
17
|
analyzer_tables = MetricFu::AnalyzerTables.new(analyzer_columns)
|
19
18
|
tool_analyzers.each do |analyzer|
|
@@ -28,31 +27,28 @@ describe MetricFu::AnalyzerTables do
|
|
28
27
|
end
|
29
28
|
|
30
29
|
context "with Stats data" do
|
31
|
-
|
32
30
|
before do
|
33
31
|
@result_hash = HOTSPOT_DATA["stats.yml"]
|
34
32
|
@table = analyzer_table(@result_hash).table
|
35
33
|
end
|
36
34
|
|
37
35
|
it "should have codeLOC" do
|
38
|
-
row = @table.find{|row| row[
|
39
|
-
expect(row[
|
36
|
+
row = @table.find { |row| row["stat_name"] == :codeLOC }
|
37
|
+
expect(row["stat_value"]).to eq(4222)
|
40
38
|
end
|
41
39
|
|
42
40
|
it "should have testLOC" do
|
43
|
-
row = @table.find{|row| row[
|
44
|
-
expect(row[
|
41
|
+
row = @table.find { |row| row["stat_name"] == :testLOC }
|
42
|
+
expect(row["stat_value"]).to eq(2111)
|
45
43
|
end
|
46
44
|
|
47
45
|
it "should have code_to_test_ratio" do
|
48
|
-
row = @table.find{|row| row[
|
49
|
-
expect(row[
|
46
|
+
row = @table.find { |row| row["stat_name"] == :code_to_test_ratio }
|
47
|
+
expect(row["stat_value"]).to eq(2)
|
50
48
|
end
|
51
|
-
|
52
49
|
end
|
53
50
|
|
54
51
|
context "with three different path representations of file (from Saikuro, Flog, and Reek)" do
|
55
|
-
|
56
52
|
before do
|
57
53
|
@result_hash = HOTSPOT_DATA["three_metrics_on_same_file.yml"]
|
58
54
|
@table = analyzer_table(@result_hash).table
|
@@ -60,17 +56,16 @@ describe MetricFu::AnalyzerTables do
|
|
60
56
|
|
61
57
|
specify "all records should have full file_path" do
|
62
58
|
@table.each do |row|
|
63
|
-
expect(row[
|
59
|
+
expect(row["file_path"]).to eq("lib/client/client.rb")
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
67
63
|
specify "all records should have class name" do
|
68
|
-
expect(@table.select{|rows| rows.fetch(:class_name, :no_key) == nil }.size).to eq(0)
|
64
|
+
expect(@table.select { |rows| rows.fetch(:class_name, :no_key) == nil }.size).to eq(0)
|
69
65
|
end
|
70
66
|
|
71
67
|
specify "one record should not have method name" do
|
72
|
-
expect(@table.select{|rows| rows.fetch(:method_name, :no_key) == nil }.size).to eq(0)
|
68
|
+
expect(@table.select { |rows| rows.fetch(:method_name, :no_key) == nil }.size).to eq(0)
|
73
69
|
end
|
74
|
-
|
75
70
|
end
|
76
71
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "hotspots/analysis/ranking" }
|
3
3
|
|
4
4
|
describe MetricFu::Ranking do
|
5
|
-
|
6
5
|
context "with many items" do
|
7
|
-
|
8
6
|
specify "#top" do
|
9
7
|
ranking = Ranking.new
|
10
8
|
ranking[:a] = 10
|
11
9
|
ranking[:b] = 50
|
12
10
|
ranking[:c] = 1
|
13
|
-
expect(ranking.top).to eq([:b
|
11
|
+
expect(ranking.top).to eq([:b, :a, :c])
|
14
12
|
end
|
15
13
|
|
16
14
|
specify "lowest item is at 0 percentile" do
|
@@ -28,7 +26,5 @@ describe MetricFu::Ranking do
|
|
28
26
|
ranking[:d] = 5
|
29
27
|
expect(ranking.percentile(:b)).to eq(0.75)
|
30
28
|
end
|
31
|
-
|
32
29
|
end
|
33
|
-
|
34
30
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
2
|
-
MetricFu.metrics_require {
|
1
|
+
require "spec_helper"
|
2
|
+
MetricFu.metrics_require { "hotspots/analysis/rankings" }
|
3
3
|
|
4
4
|
describe MetricFu::HotspotRankings do
|
5
|
-
|
6
5
|
before do
|
7
6
|
enable_hotspots
|
8
7
|
end
|
@@ -14,7 +13,7 @@ describe MetricFu::HotspotRankings do
|
|
14
13
|
common_columns = %w{metric}
|
15
14
|
granularities = %w{file_path class_name method_name}
|
16
15
|
tool_analyzers = MetricFu::Hotspot.analyzers
|
17
|
-
analyzer_columns = common_columns + granularities + tool_analyzers.map
|
16
|
+
analyzer_columns = common_columns + granularities + tool_analyzers.map(&:columns).flatten
|
18
17
|
|
19
18
|
analyzer_tables = MetricFu::AnalyzerTables.new(analyzer_columns)
|
20
19
|
tool_analyzers.each do |analyzer|
|
@@ -30,8 +29,8 @@ describe MetricFu::HotspotRankings do
|
|
30
29
|
context "with several types of data" do
|
31
30
|
it "gives all files, in order, from worst to best" do
|
32
31
|
expected = [
|
33
|
-
|
34
|
-
|
32
|
+
"lib/client/client.rb",
|
33
|
+
"lib/client/foo.rb"]
|
35
34
|
expect(rankings(result_hash).worst_files).to eq(expected)
|
36
35
|
end
|
37
36
|
def result_hash
|
@@ -39,7 +38,6 @@ describe MetricFu::HotspotRankings do
|
|
39
38
|
end
|
40
39
|
end
|
41
40
|
context "with Reek data" do
|
42
|
-
|
43
41
|
before do
|
44
42
|
@result_hash = HOTSPOT_DATA["reek.yml"]
|
45
43
|
end
|
@@ -55,10 +53,8 @@ describe MetricFu::HotspotRankings do
|
|
55
53
|
it "gives worst file" do
|
56
54
|
expect(rankings(@result_hash).worst_files[0]).to eq("lib/client/client.rb")
|
57
55
|
end
|
58
|
-
|
59
56
|
end
|
60
57
|
context "with Saikuro data" do
|
61
|
-
|
62
58
|
before do
|
63
59
|
@result_hash = HOTSPOT_DATA["saikuro.yml"]
|
64
60
|
end
|
@@ -70,10 +66,8 @@ describe MetricFu::HotspotRankings do
|
|
70
66
|
it "gives worst class" do
|
71
67
|
expect(rankings(@result_hash).worst_classes[0]).to eq("Bitly")
|
72
68
|
end
|
73
|
-
|
74
69
|
end
|
75
70
|
context "with Flog data" do
|
76
|
-
|
77
71
|
before do
|
78
72
|
@result_hash = HOTSPOT_DATA["flog.yml"]
|
79
73
|
end
|
@@ -89,11 +83,9 @@ describe MetricFu::HotspotRankings do
|
|
89
83
|
it "gives worst file" do
|
90
84
|
expect(rankings(@result_hash).worst_files[0]).to eq("lib/generators/rcov.rb:57")
|
91
85
|
end
|
92
|
-
|
93
86
|
end
|
94
87
|
|
95
88
|
context "with Roodi data" do
|
96
|
-
|
97
89
|
before do
|
98
90
|
@result_hash = HOTSPOT_DATA["roodi.yml"]
|
99
91
|
end
|
@@ -101,6 +93,5 @@ describe MetricFu::HotspotRankings do
|
|
101
93
|
it "gives worst file" do
|
102
94
|
expect(rankings(@result_hash).worst_files[0]).to eq("lib/client/client.rb")
|
103
95
|
end
|
104
|
-
|
105
96
|
end
|
106
97
|
end
|