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,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
3
3
|
|
4
|
-
describe MetricFu::Configuration,
|
5
|
-
it_behaves_like
|
6
|
-
it
|
7
|
-
load_metric
|
4
|
+
describe MetricFu::Configuration, "for reek" do
|
5
|
+
it_behaves_like "configured" do
|
6
|
+
it "should set @reek to {:dirs_to_reek => @code_dirs}" do
|
7
|
+
load_metric "reek"
|
8
8
|
expect(MetricFu::Metric.get_metric(:reek).run_options).to eq(
|
9
|
-
|
9
|
+
config_file_pattern: nil, dirs_to_reek: ["lib"]
|
10
10
|
)
|
11
11
|
end
|
12
12
|
end
|
@@ -1,74 +1,115 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
2
|
+
|
3
|
+
MetricFu.metrics_require { "reek/generator" }
|
3
4
|
|
4
5
|
describe MetricFu::ReekGenerator do
|
5
6
|
describe "emit" do
|
6
|
-
let(:options) { {:
|
7
|
-
let(:files_to_analyze) { [
|
7
|
+
let(:options) { { dirs_to_reek: [] } }
|
8
|
+
let(:files_to_analyze) { ["lib/foo.rb", "lib/bar.rb"] }
|
8
9
|
let(:reek) { MetricFu::ReekGenerator.new(options) }
|
9
10
|
|
10
|
-
before
|
11
|
+
before(:each) do
|
11
12
|
allow(reek).to receive(:files_to_analyze).and_return(files_to_analyze)
|
12
13
|
end
|
13
14
|
|
14
15
|
it "includes config file pattern into reek parameters when specified" do
|
15
|
-
options.merge!(
|
16
|
-
expect(reek).to receive(:run!).with(/--config lib\/config\/\*\.reek /).and_return("")
|
17
|
-
reek.emit
|
18
|
-
end
|
16
|
+
options.merge!(config_file_pattern: "lib/config/*.reek")
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
reek.emit
|
24
|
-
end
|
18
|
+
expect(reek).to receive(:run!) do |_files, config_files|
|
19
|
+
expect(config_files).to eq(["lib/config/*.reek"])
|
20
|
+
end.and_return("")
|
25
21
|
|
26
|
-
it "does not set an (invalid) --no-color option for reek < 1.3.7" do
|
27
|
-
allow(reek).to receive(:reek_version).and_return('1.3.6')
|
28
|
-
expect(reek).to receive(:run!).with(/(?!--no-color)/).and_return("")
|
29
22
|
reek.emit
|
30
23
|
end
|
31
24
|
|
32
|
-
it "
|
33
|
-
expect(reek).to receive(:run!)
|
25
|
+
it "passes an empty array when no config file pattern is specified" do
|
26
|
+
expect(reek).to receive(:run!) do |_files, config_files|
|
27
|
+
expect(config_files).to eq([])
|
28
|
+
end.and_return("")
|
29
|
+
|
34
30
|
reek.emit
|
35
31
|
end
|
36
32
|
|
37
33
|
it "includes files to analyze into reek parameters" do
|
38
|
-
expect(reek).to receive(:run!)
|
34
|
+
expect(reek).to receive(:run!) do |files, _config_files|
|
35
|
+
expect(files).to eq(["lib/foo.rb", "lib/bar.rb"])
|
36
|
+
end.and_return("")
|
37
|
+
|
39
38
|
reek.emit
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
|
-
#TODO review tested output
|
44
42
|
describe "analyze method" do
|
45
|
-
|
46
43
|
before :each do
|
47
44
|
MetricFu::Configuration.run {}
|
48
45
|
allow(File).to receive(:directory?).and_return(true)
|
49
|
-
@
|
46
|
+
@generator = MetricFu::ReekGenerator.new
|
47
|
+
@examiner = @generator.send(:examiner)
|
48
|
+
@smell_warning = Reek.const_defined?(:SmellWarning) ? Reek.const_get(:SmellWarning) : Reek.const_get(:Smells).const_get(:SmellWarning)
|
49
|
+
if @smell_warning.instance_methods.include?(:subclass)
|
50
|
+
@smell_warning.send(:alias_method, :smell_type, :subclass)
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
context "with reek warnings" do
|
53
55
|
before :each do
|
54
|
-
@
|
55
|
-
|
56
|
-
|
57
|
-
ActivityReportsController#authorize_user
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
"
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
56
|
+
@smells = [
|
57
|
+
instance_double(@smell_warning,
|
58
|
+
source: "app/controllers/activity_reports_controller.rb",
|
59
|
+
context: "ActivityReportsController#authorize_user",
|
60
|
+
message: "calls current_user.primary_site_ids multiple times",
|
61
|
+
smell_type: "Duplication",
|
62
|
+
lines: [2, 4]),
|
63
|
+
instance_double(@smell_warning,
|
64
|
+
source: "app/controllers/activity_reports_controller.rb",
|
65
|
+
context: "ActivityReportsController#authorize_user",
|
66
|
+
message: "calls params[id] multiple times",
|
67
|
+
smell_type: "Duplication",
|
68
|
+
lines: [5, 7]),
|
69
|
+
instance_double(@smell_warning,
|
70
|
+
source: "app/controllers/activity_reports_controller.rb",
|
71
|
+
context: "ActivityReportsController#authorize_user",
|
72
|
+
message: "calls params[primary_site_id] multiple times",
|
73
|
+
smell_type: "Duplication",
|
74
|
+
lines: [11, 15]),
|
75
|
+
instance_double(@smell_warning,
|
76
|
+
source: "app/controllers/activity_reports_controller.rb",
|
77
|
+
context: "ActivityReportsController#authorize_user",
|
78
|
+
message: "has approx 6 statements",
|
79
|
+
smell_type: "Long Method",
|
80
|
+
lines: [8]),
|
81
|
+
|
82
|
+
instance_double(@smell_warning,
|
83
|
+
source: "app/controllers/application.rb",
|
84
|
+
context: "ApplicationController#start_background_task/block/block",
|
85
|
+
message: "is nested",
|
86
|
+
smell_type: "Nested Iterators",
|
87
|
+
lines: [23]),
|
88
|
+
|
89
|
+
instance_double(@smell_warning,
|
90
|
+
source: "app/controllers/link_targets_controller.rb",
|
91
|
+
context: "LinkTargetsController#authorize_user",
|
92
|
+
message: "calls current_user.role multiple times",
|
93
|
+
smell_type: "Duplication",
|
94
|
+
lines: [8]),
|
95
|
+
|
96
|
+
instance_double(@smell_warning,
|
97
|
+
source: "app/controllers/newline_controller.rb",
|
98
|
+
context: "NewlineController#some_method",
|
99
|
+
message: "calls current_user.<< \"new line\n\" multiple times",
|
100
|
+
smell_type: "Duplication",
|
101
|
+
lines: [6, 9])
|
102
|
+
]
|
103
|
+
@examiners = [
|
104
|
+
instance_double(Reek::Examiner, smells: @smells)
|
105
|
+
]
|
106
|
+
@generator.instance_variable_set(:@output, @examiners)
|
107
|
+
@matches = @generator.analyze
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should find the code smell's line numbers" do
|
111
|
+
smell = @matches.first[:code_smells].first
|
112
|
+
expect(smell[:lines]).to eq([2, 4])
|
72
113
|
end
|
73
114
|
|
74
115
|
it "should find the code smell's method name" do
|
@@ -93,91 +134,70 @@ NewlineController#some_method calls current_user.<< "new line\n" multiple times
|
|
93
134
|
|
94
135
|
it "should NOT insert nil smells into the array when there's a newline in the method call" do
|
95
136
|
expect(@matches.last[:code_smells]).to eq(@matches.last[:code_smells].compact)
|
96
|
-
expect(@matches.last).to eq({:file_path=>"app/controllers/newline_controller.rb",
|
97
|
-
:code_smells=>[{:type=>"Duplication",
|
98
|
-
:method=>"\"",
|
99
|
-
:message=>"multiple times"}]})
|
100
|
-
# Note: hopefully a temporary solution until I figure out how to deal with newlines in the method call more effectively -Jake 5/11/2009
|
101
137
|
end
|
102
138
|
end
|
103
139
|
|
104
|
-
context "
|
140
|
+
context "with reek 1.3 output" do
|
105
141
|
before :each do
|
106
|
-
@
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
142
|
+
@smells = [
|
143
|
+
double(source: "app/controllers/activity_reports_controller.rb",
|
144
|
+
context: "ActivityReportsController#authorize_user",
|
145
|
+
message: "calls current_user.primary_site_ids multiple times",
|
146
|
+
subclass: "Duplication",
|
147
|
+
lines: [2, 4]),
|
148
|
+
]
|
149
|
+
@examiners = [
|
150
|
+
instance_double(Reek::Examiner, smells: @smells)
|
151
|
+
]
|
152
|
+
@generator.instance_variable_set(:@output, @examiners)
|
153
|
+
@matches = @generator.analyze
|
112
154
|
end
|
113
155
|
|
114
|
-
it "
|
115
|
-
|
156
|
+
it "uses the subclass field to find the smell type" do
|
157
|
+
smell = @matches.first[:code_smells].first
|
158
|
+
expect(smell[:type]).to eq('Duplication')
|
116
159
|
end
|
117
160
|
end
|
118
|
-
end
|
119
|
-
end
|
120
161
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
"app/controllers/link_targets_controller.rb" -- 1 warnings:
|
136
|
-
LinkTargetsController#authorize_user calls current_user.role multiple times (Duplication)
|
137
|
-
|
138
|
-
"app/controllers/newline_controller.rb" -- 1 warnings:
|
139
|
-
NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
|
140
|
-
HERE
|
141
|
-
@lines12 = <<-HERE
|
142
|
-
app/controllers/activity_reports_controller.rb -- 4 warnings (+3 masked):
|
143
|
-
ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
|
144
|
-
ActivityReportsController#authorize_user calls params[id] multiple times (Duplication)
|
145
|
-
ActivityReportsController#authorize_user calls params[primary_site_id] multiple times (Duplication)
|
146
|
-
ActivityReportsController#authorize_user has approx 6 statements (Long Method)
|
147
|
-
app/controllers/application.rb -- 1 warnings:
|
148
|
-
ApplicationController#start_background_task/block/block is nested (Nested Iterators)
|
149
|
-
app/controllers/link_targets_controller.rb -- 1 warnings (+1 masked):
|
150
|
-
LinkTargetsController#authorize_user calls current_user.role multiple times (Duplication)
|
151
|
-
app/controllers/newline_controller.rb -- 1 warnings:
|
152
|
-
NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
|
153
|
-
HERE
|
154
|
-
end
|
162
|
+
context "with real output, not mocked nor doubled" do
|
163
|
+
let(:result) do
|
164
|
+
{
|
165
|
+
file_path: "spec/support/samples/reek/alfa.rb",
|
166
|
+
code_smells: [
|
167
|
+
{
|
168
|
+
lines: [1],
|
169
|
+
message: "has unused parameter 'echo'",
|
170
|
+
method: "foo",
|
171
|
+
type: "UnusedParameters"
|
172
|
+
}
|
173
|
+
]
|
174
|
+
}
|
175
|
+
end
|
155
176
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
end
|
161
|
-
it 'detects 1.1 format output' do
|
162
|
-
@reek.instance_variable_set(:@output, @lines11)
|
163
|
-
expect(@reek).not_to be_reek_12
|
164
|
-
end
|
177
|
+
it "returns real data" do
|
178
|
+
MetricFu.with_run_dir File.expand_path("../../..", __FILE__) do
|
179
|
+
@generator = MetricFu::ReekGenerator.new(dirs_to_reek: ["spec/support/samples"])
|
180
|
+
@generator.emit
|
165
181
|
|
166
|
-
|
167
|
-
@reek.instance_variable_set(:@output, "")
|
168
|
-
expect(@reek.massage_for_reek_12).to be_empty
|
169
|
-
end
|
170
|
-
end
|
182
|
+
@matches = @generator.analyze
|
171
183
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
expect(@reek).to be_reek_12
|
184
|
+
expect(@matches.first).to eq(result)
|
185
|
+
end
|
186
|
+
end
|
176
187
|
end
|
177
188
|
|
178
|
-
|
179
|
-
|
180
|
-
|
189
|
+
context "without reek warnings" do
|
190
|
+
before :each do
|
191
|
+
@examiners = [
|
192
|
+
instance_double(Reek::Examiner, smells: [])
|
193
|
+
]
|
194
|
+
@generator.instance_variable_set(:@output, @examiners)
|
195
|
+
@matches = @generator.analyze
|
196
|
+
end
|
197
|
+
|
198
|
+
it "returns empty analysis" do
|
199
|
+
expect(@matches).to eq([])
|
200
|
+
end
|
181
201
|
end
|
182
202
|
end
|
183
203
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "reek/grapher" }
|
3
3
|
|
4
4
|
describe ReekGrapher do
|
5
5
|
before :each do
|
@@ -45,7 +45,7 @@ describe ReekGrapher do
|
|
45
45
|
|
46
46
|
it "should set a hash of code smells to reek_count" do
|
47
47
|
@reek_grapher.get_metrics(@metrics, @date)
|
48
|
-
expect(@reek_grapher.reek_count).to eq(
|
48
|
+
expect(@reek_grapher.reek_count).to eq(
|
49
49
|
"Uncommunicative Name" => [27],
|
50
50
|
"Feature Envy" => [20],
|
51
51
|
"Utility Function" => [15],
|
@@ -54,11 +54,11 @@ describe ReekGrapher do
|
|
54
54
|
"Control Couple" => [4],
|
55
55
|
"Duplication" => [48],
|
56
56
|
"Large Class" => [1]
|
57
|
-
|
57
|
+
)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should update labels with the date" do
|
61
|
-
expect(@reek_grapher.labels).to receive(:update).with(
|
61
|
+
expect(@reek_grapher.labels).to receive(:update).with(0 => "1/2")
|
62
62
|
@reek_grapher.get_metrics(@metrics, @date)
|
63
63
|
end
|
64
64
|
end
|
@@ -1,16 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
3
3
|
|
4
|
-
describe MetricFu::Configuration,
|
5
|
-
it_behaves_like
|
6
|
-
|
7
|
-
|
8
|
-
load_metric 'roodi'
|
4
|
+
describe MetricFu::Configuration, "for roodi" do
|
5
|
+
it_behaves_like "configured" do
|
6
|
+
it "should set @roodi to {:dirs_to_roodi => @code_dirs}" do
|
7
|
+
load_metric "roodi"
|
9
8
|
expect(MetricFu::Metric.get_metric(:roodi).run_options).to eq(
|
10
|
-
|
11
|
-
|
9
|
+
dirs_to_roodi: directory("code_dirs"),
|
10
|
+
roodi_config: "#{directory('root_directory')}/config/roodi_config.yml"
|
12
11
|
)
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
14
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "roodi/generator" }
|
3
3
|
|
4
4
|
describe MetricFu::RoodiGenerator do
|
5
5
|
describe "emit" do
|
6
6
|
it "should add config options when present" do
|
7
|
-
options = {:
|
7
|
+
options = { roodi_config: "lib/config/roodi_config.yml", dirs_to_roodi: [] }
|
8
8
|
roodi = MetricFu::RoodiGenerator.new(options)
|
9
9
|
expect(roodi).to receive(:run!).with(/-config=lib\/config\/roodi_config\.yml/).and_return("")
|
10
10
|
roodi.emit
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should NOT add config options when NOT present" do
|
14
|
-
options = {:
|
14
|
+
options = { dirs_to_roodi: [] }
|
15
15
|
roodi = MetricFu::RoodiGenerator.new(options)
|
16
16
|
allow(roodi).to receive(:run!)
|
17
17
|
expect(roodi).to receive(:run!).with(/-config/).never
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "roodi/grapher" }
|
3
3
|
|
4
4
|
describe RoodiGrapher do
|
5
5
|
before :each do
|
@@ -49,7 +49,7 @@ describe RoodiGrapher do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should update labels with the date" do
|
52
|
-
expect(@roodi_grapher.labels).to receive(:update).with(
|
52
|
+
expect(@roodi_grapher.labels).to receive(:update).with(0 => "1/2")
|
53
53
|
@roodi_grapher.get_metrics(@metrics, @date)
|
54
54
|
end
|
55
55
|
end
|
@@ -1,26 +1,25 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
3
3
|
|
4
|
-
describe MetricFu::Configuration,
|
5
|
-
it_behaves_like
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
4
|
+
describe MetricFu::Configuration, "for saikuro" do
|
5
|
+
it_behaves_like "configured" do
|
6
|
+
it "should set @saikuro to { :output_directory => @scratch_directory + '/saikuro',
|
7
|
+
:input_directory => @code_dirs,
|
8
|
+
:cyclo => '',
|
9
|
+
:filter_cyclo => '0',
|
10
|
+
:warn_cyclo => '5',
|
11
|
+
:error_cyclo => '7',
|
12
|
+
:formater => 'text' }" do
|
13
|
+
load_metric "saikuro"
|
14
|
+
expect(MetricFu::Metric.get_metric(:saikuro).run_options).to eq(
|
15
|
+
output_directory: "#{scratch_directory}/saikuro",
|
16
|
+
input_directory: ["lib"],
|
17
|
+
cyclo: "",
|
18
|
+
filter_cyclo: "0",
|
19
|
+
warn_cyclo: "5",
|
20
|
+
error_cyclo: "7",
|
21
|
+
formater: "text"
|
22
|
+
)
|
23
|
+
end
|
25
24
|
end
|
26
25
|
end
|