metric_fu 4.11.3 → 4.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +69 -0
- data/.travis.yml +0 -1
- data/CONTRIBUTORS +1 -1
- data/Gemfile +23 -20
- data/Guardfile +9 -9
- data/HISTORY.md +10 -1
- data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
- data/config/rubocop.yml +269 -0
- data/gem_tasks/rubocop.rake +10 -0
- data/lib/metric_fu.rb +11 -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 +9 -11
- data/lib/metric_fu/generator.rb +5 -8
- 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 +22 -23
- 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 -9
- 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 +10 -12
- data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
- data/lib/metric_fu/metrics/rails_best_practices/metric.rb +1 -3
- 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 +22 -23
- 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 +19 -19
- data/lib/metric_fu/templates/report.rb +5 -8
- data/lib/metric_fu/templates/template.rb +20 -24
- data/lib/metric_fu/utility.rb +7 -8
- data/lib/metric_fu/version.rb +1 -1
- data/metric_fu.gemspec +31 -32
- data/spec/cli/helper_spec.rb +7 -14
- 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 +70 -82
- 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 +11 -13
- 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 +6 -6
- data/spec/metric_fu/gem_version_spec.rb +3 -5
- data/spec/metric_fu/generator_spec.rb +28 -38
- data/spec/metric_fu/loader_spec.rb +1 -3
- data/spec/metric_fu/metric_spec.rb +17 -21
- data/spec/metric_fu/metrics/cane/configuration_spec.rb +8 -8
- data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
- data/spec/metric_fu/metrics/churn/configuration_spec.rb +6 -8
- data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
- data/spec/metric_fu/metrics/flay/configuration_spec.rb +6 -8
- 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 +11 -13
- data/spec/metric_fu/metrics/flog/generator_spec.rb +29 -31
- 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 +6 -10
- 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 +20 -22
- 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 +6 -6
- data/spec/metric_fu/metrics/reek/generator_spec.rb +19 -20
- data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
- data/spec/metric_fu/metrics/roodi/configuration_spec.rb +7 -9
- 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 +18 -19
- data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
- data/spec/metric_fu/metrics/stats/generator_spec.rb +9 -9
- data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
- data/spec/metric_fu/reporter_spec.rb +3 -4
- 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 +9 -11
- data/spec/metric_fu/run_spec.rb +18 -32
- data/spec/metric_fu/templates/configuration_spec.rb +28 -34
- 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 +62 -48
- data/spec/metric_fu/utility_spec.rb +2 -2
- data/spec/metric_fu_spec.rb +5 -7
- data/spec/shared/configured.rb +9 -11
- data/spec/shared/test_coverage.rb +5 -9
- data/spec/spec_helper.rb +9 -9
- data/spec/support/deferred_garbaged_collection.rb +1 -2
- data/spec/support/matcher_create_file.rb +2 -4
- data/spec/support/matcher_create_files.rb +2 -4
- 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 +23 -24
- data/spec/usage_test_spec.rb +18 -20
- metadata +12 -2
- metadata.gz.sig +0 -0
@@ -1,15 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
describe MetricFu::Configuration, 'for churn' do
|
5
|
-
it_behaves_like 'configured' do
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
6
3
|
|
4
|
+
describe MetricFu::Configuration, "for churn" do
|
5
|
+
it_behaves_like "configured" do
|
7
6
|
it "should set @churn to {}" do
|
8
|
-
load_metric
|
7
|
+
load_metric "churn"
|
9
8
|
expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
|
10
|
-
|
9
|
+
start_date: '"1 year ago"', minimum_churn_count: 10, ignore_files: [], data_directory: MetricFu::Io::FileSystem.scratch_directory("churn")
|
11
10
|
)
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
13
|
end
|
@@ -1,39 +1,36 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "churn/generator" }
|
3
3
|
|
4
4
|
describe MetricFu::ChurnGenerator do
|
5
|
-
|
6
5
|
# TODO extract yaml
|
7
6
|
let(:churn_hash) { YAML::load("--- \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") }
|
8
7
|
|
9
8
|
let(:config_setup) {
|
10
|
-
ENV[
|
9
|
+
ENV["CC_BUILD_ARTIFACTS"] = nil
|
11
10
|
MetricFu.configure.reset
|
12
11
|
}
|
13
12
|
|
14
13
|
describe "analyze method" do
|
15
14
|
before :each do
|
16
15
|
config_setup
|
17
|
-
@changes = {"lib/generators/flog.rb" => 2, "lib/metric_fu.rb" => 3}
|
16
|
+
@changes = { "lib/generators/flog.rb" => 2, "lib/metric_fu.rb" => 3 }
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should be empty on error no output captured" do
|
21
20
|
churn = MetricFu::ChurnGenerator.new
|
22
21
|
churn.instance_variable_set(:@output, nil)
|
23
22
|
result = churn.analyze
|
24
|
-
expect(result).to eq(
|
23
|
+
expect(result).to eq(churn: {})
|
25
24
|
end
|
26
25
|
|
27
26
|
it "should return yaml results" do
|
28
27
|
churn = MetricFu::ChurnGenerator.new
|
29
28
|
churn.instance_variable_set(:@output, churn_hash)
|
30
29
|
result = churn.analyze
|
31
|
-
expect(result).to eq(
|
30
|
+
expect(result).to eq(churn: { changed_files: ["spec/graphs/flog_grapher_spec.rb", "spec/base/graph_spec.rb", "lib/templates/awesome/layout.html.erb", "lib/graphs/rcov_grapher.rb", "lib/base/base_template.rb", "spec/graphs/grapher_spec.rb", "lib/templates/awesome/flog.html.erb", "lib/templates/awesome/flay.html.erb", "lib/graphs/roodi_grapher.rb", "lib/graphs/reek_grapher.rb", "HISTORY", "spec/graphs/roodi_grapher_spec.rb", "lib/generators/rcov.rb", "spec/graphs/engines/gchart_spec.rb", "spec/graphs/rcov_grapher_spec.rb", "lib/templates/javascripts/excanvas.js", "lib/templates/javascripts/bluff-min.js", "spec/graphs/reek_grapher_spec.rb"] })
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
35
33
|
|
36
|
-
|
37
34
|
describe "to_h method" do
|
38
35
|
before :each do
|
39
36
|
config_setup
|
@@ -41,12 +38,11 @@ describe MetricFu::ChurnGenerator do
|
|
41
38
|
|
42
39
|
it "should put the changes into a hash" do
|
43
40
|
churn = MetricFu::ChurnGenerator.new
|
44
|
-
churn.instance_variable_set(:@churn,
|
41
|
+
churn.instance_variable_set(:@churn, churn: "results")
|
45
42
|
expect(churn.to_h[:churn]).to eq("results")
|
46
43
|
end
|
47
44
|
end
|
48
45
|
|
49
|
-
|
50
46
|
describe "emit method" do
|
51
47
|
before :each do
|
52
48
|
config_setup
|
@@ -66,4 +62,3 @@ describe MetricFu::ChurnGenerator do
|
|
66
62
|
end
|
67
63
|
end
|
68
64
|
end
|
69
|
-
|
@@ -1,15 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
describe MetricFu::Configuration, 'for flay' do
|
5
|
-
it_behaves_like 'configured' do
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
6
3
|
|
4
|
+
describe MetricFu::Configuration, "for flay" do
|
5
|
+
it_behaves_like "configured" do
|
7
6
|
it "should set @flay to {:dirs_to_flay => @code_dirs}" do
|
8
|
-
load_metric
|
7
|
+
load_metric "flay"
|
9
8
|
expect(MetricFu::Metric.get_metric(:flay).run_options).to eq(
|
10
|
-
|
9
|
+
dirs_to_flay: ["lib"], minimum_score: nil
|
11
10
|
)
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
13
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "flay/generator" }
|
3
3
|
|
4
4
|
describe MetricFu::FlayGenerator do
|
5
5
|
describe "emit method" do
|
6
6
|
it "should look at the dirs" do
|
7
|
-
options = { :
|
7
|
+
options = { dirs_to_flay: ["app", "lib"] }
|
8
8
|
allow(File).to receive(:directory?).and_return(true)
|
9
9
|
@flay = MetricFu::FlayGenerator.new(options)
|
10
10
|
|
@@ -13,7 +13,7 @@ describe MetricFu::FlayGenerator do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should limit flay scores by the minimum_score" do
|
16
|
-
options = { :
|
16
|
+
options = { dirs_to_flay: [], minimum_score: 99 }
|
17
17
|
allow(File).to receive(:directory?).and_return(true)
|
18
18
|
@flay = MetricFu::FlayGenerator.new(options)
|
19
19
|
|
@@ -40,57 +40,56 @@ Total score (lower is better) = 246
|
|
40
40
|
HERE
|
41
41
|
MetricFu::Configuration.run {}
|
42
42
|
allow(File).to receive(:directory?).and_return(true)
|
43
|
-
@flay = MetricFu::FlayGenerator.new(
|
43
|
+
@flay = MetricFu::FlayGenerator.new("base_dir")
|
44
44
|
@flay.instance_variable_set(:@output, lines)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should analyze and return matches" do
|
48
|
-
expect(@flay.analyze).to eq([
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
expect(@flay.analyze).to eq([["Total score (lower is better) = 246"],
|
49
|
+
["\n1) IDENTICAL code found in :or (mass*2 = 68)",
|
50
|
+
"app/controllers/link_targets_controller.rb:57",
|
51
|
+
"app/controllers/primary_sites_controller.rb:138"],
|
52
|
+
["2) Similar code found in :if (mass = 64)",
|
53
|
+
"app/controllers/primary_sites_controller.rb:75",
|
54
|
+
"app/controllers/primary_sites_controller.rb:76",
|
55
|
+
"app/controllers/primary_sites_controller.rb:88",
|
56
|
+
"app/controllers/primary_sites_controller.rb:89"]])
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "to_h method" do
|
61
|
-
|
62
61
|
before :each do
|
63
|
-
lines = [
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
62
|
+
lines = [["Total score (lower is better) = 284"],
|
63
|
+
["\n1) IDENTICAL code found in :or (mass*2 = 68)",
|
64
|
+
"app/controllers/link_targets_controller.rb:57",
|
65
|
+
"app/controllers/primary_sites_controller.rb:138"],
|
66
|
+
["2) Similar code found in :if (mass = 64)",
|
67
|
+
"app/controllers/primary_sites_controller.rb:75",
|
68
|
+
"app/controllers/primary_sites_controller.rb:76",
|
69
|
+
"app/controllers/primary_sites_controller.rb:88",
|
70
|
+
"app/controllers/primary_sites_controller.rb:89"],
|
71
|
+
["3) Similar code found in :defn (mass = 40)",
|
72
|
+
"app/controllers/link_targets_controller.rb:40",
|
73
|
+
"app/controllers/primary_sites_controller.rb:98"],
|
74
|
+
["4) Similar code found in :defn (mass = 38)",
|
75
|
+
"app/controllers/link_targets_controller.rb:13",
|
76
|
+
"app/controllers/primary_sites_controller.rb:50"],
|
77
|
+
["5) Similar code found in :defn (mass = 38)",
|
78
|
+
"app/models/primary_site.rb:104",
|
79
|
+
"app/models/primary_site.rb:109"],
|
80
|
+
["6) Similar code found in :call (mass = 36)",
|
81
|
+
"app/controllers/bookmarklet_integration_controller.rb:6",
|
82
|
+
"app/controllers/bookmarklet_integration_controller.rb:17"]]
|
84
83
|
|
85
84
|
MetricFu::Configuration.run {}
|
86
85
|
allow(File).to receive(:directory?).and_return(true)
|
87
|
-
flay = MetricFu::FlayGenerator.new(
|
86
|
+
flay = MetricFu::FlayGenerator.new("base_dir")
|
88
87
|
flay.instance_variable_set(:@matches, lines)
|
89
88
|
@results = flay.to_h
|
90
89
|
end
|
91
90
|
|
92
91
|
it "should find the total_score" do
|
93
|
-
expect(@results[:flay][:total_score]).to eq(
|
92
|
+
expect(@results[:flay][:total_score]).to eq("284")
|
94
93
|
end
|
95
94
|
|
96
95
|
it "should have 6 matches" do
|
@@ -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
7
|
it "should set @flog to {:dirs_to_flog => @code_dirs}" do
|
9
|
-
load_metric
|
10
|
-
expect(MetricFu::Metric.get_metric(:flog).run_options).to eq(
|
11
|
-
:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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,8 +12,8 @@ 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(
|
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"))
|
18
17
|
expect(flogger).to receive(:flog).with("lib")
|
19
18
|
@flog.emit
|
20
19
|
end
|
@@ -25,34 +24,34 @@ describe MetricFu::FlogGenerator do
|
|
25
24
|
first_full_method_name = "ClassName#first_method_name"
|
26
25
|
second_full_method_name = "ClassName#second_method_name"
|
27
26
|
|
28
|
-
flogger = double(
|
29
|
-
second_full_method_name =>
|
30
|
-
|
31
|
-
second_full_method_name => 22.22})
|
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 })
|
32
31
|
expect(flogger).to receive(:calculate)
|
33
32
|
expect(flogger).to receive(:each_by_score).and_yield(
|
34
|
-
first_full_method_name, 11.11,
|
33
|
+
first_full_method_name, 11.11, branch: 11.1, puts: 1.1
|
35
34
|
).and_yield(
|
36
|
-
second_full_method_name, 22.22,
|
35
|
+
second_full_method_name, 22.22, branch: 22.2, puts: 2.2
|
37
36
|
)
|
38
37
|
@flog.instance_variable_set(:@flogger, flogger)
|
39
38
|
@flog.analyze
|
40
39
|
method_containers = @flog.instance_variable_get(:@method_containers)
|
41
40
|
expect(method_containers.size).to eq(1)
|
42
41
|
|
43
|
-
expected={:
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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" }
|
56
55
|
|
57
56
|
expect(method_containers["ClassName"].to_h).to eq(expected)
|
58
57
|
end
|
@@ -60,19 +59,18 @@ describe MetricFu::FlogGenerator do
|
|
60
59
|
|
61
60
|
describe "to_h method" do
|
62
61
|
it "should make-a nice hash" do
|
63
|
-
flogger = double(
|
62
|
+
flogger = double("flogger", total_score: 111.1, average: 7.3)
|
64
63
|
@flog.instance_variable_set(:@flogger, flogger)
|
65
|
-
method_containers = {:
|
66
|
-
|
67
|
-
|
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") }
|
68
67
|
@flog.instance_variable_set(:@method_containers, method_containers)
|
69
68
|
|
70
|
-
expected = {:
|
71
|
-
|
72
|
-
|
69
|
+
expected = { flog: { total: 111.1,
|
70
|
+
average: 7.3,
|
71
|
+
method_containers: ["container_2", "container_3", "container_1"] } }
|
73
72
|
|
74
73
|
expect(@flog.to_h).to eq(expected)
|
75
74
|
end
|
76
|
-
|
77
75
|
end
|
78
76
|
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
|