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,20 +1,20 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
3
|
-
MetricFu.metrics_require {
|
4
|
-
MetricFu.metrics_require {
|
5
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "hotspots/metric" }
|
3
|
+
MetricFu.metrics_require { "hotspots/hotspot" }
|
4
|
+
MetricFu.metrics_require { "hotspots/analysis/record" }
|
5
|
+
MetricFu.metrics_require { "rcov/hotspot" }
|
6
6
|
|
7
7
|
describe MetricFu::RcovHotspot do
|
8
8
|
describe "map" do
|
9
9
|
let(:zero_row) do
|
10
|
-
MetricFu::Record.new({"percentage_uncovered"=>0.0}, nil)
|
10
|
+
MetricFu::Record.new({ "percentage_uncovered" => 0.0 }, nil)
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:non_zero_row) do
|
14
|
-
MetricFu::Record.new({"percentage_uncovered"=>0.75}, nil)
|
14
|
+
MetricFu::Record.new({ "percentage_uncovered" => 0.75 }, nil)
|
15
15
|
end
|
16
16
|
|
17
|
-
it {expect(subject.map(zero_row)).to eql(0.0)}
|
18
|
-
it {expect(subject.map(non_zero_row)).to eql(0.75)}
|
17
|
+
it { expect(subject.map(zero_row)).to eql(0.0) }
|
18
|
+
it { expect(subject.map(non_zero_row)).to eql(0.75) }
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "metric_fu/metrics/rcov/rcov_line"
|
3
|
+
|
4
|
+
describe MetricFu::RCovLine do
|
5
|
+
describe "#to_h" do
|
6
|
+
it "returns a hash with the content and was_run" do
|
7
|
+
rcov_line = RCovLine.new("some content", 1)
|
8
|
+
|
9
|
+
expect(rcov_line.to_h).to eq(content: "some content", was_run: 1)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#covered?" do
|
14
|
+
it "returns true if was_run is 1" do
|
15
|
+
rcov_line = RCovLine.new("", 1)
|
16
|
+
|
17
|
+
expect(rcov_line.covered?).to eq(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns false if was_run is 0" do
|
21
|
+
rcov_line = RCovLine.new("", 0)
|
22
|
+
|
23
|
+
expect(rcov_line.covered?).to eq(false)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns false if was_run is nil" do
|
27
|
+
rcov_line = RCovLine.new("", nil)
|
28
|
+
|
29
|
+
expect(rcov_line.covered?).to eq(false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#missed?" do
|
34
|
+
it "returns true if was_run is 0" do
|
35
|
+
rcov_line = RCovLine.new("", 0)
|
36
|
+
|
37
|
+
expect(rcov_line.missed?).to eq(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns false if was_run is 1" do
|
41
|
+
rcov_line = RCovLine.new("", 1)
|
42
|
+
|
43
|
+
expect(rcov_line.missed?).to eq(false)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns false if was_run is nil" do
|
47
|
+
rcov_line = RCovLine.new("", nil)
|
48
|
+
|
49
|
+
expect(rcov_line.missed?).to eq(false)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#ignored?" do
|
54
|
+
it "returns true if was_run is nil" do
|
55
|
+
rcov_line = RCovLine.new("", nil)
|
56
|
+
|
57
|
+
expect(rcov_line.ignored?).to eq(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns false if was_run is 1" do
|
61
|
+
rcov_line = RCovLine.new("", 1)
|
62
|
+
|
63
|
+
expect(rcov_line.ignored?).to eq(false)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns false if was_run is 0" do
|
67
|
+
rcov_line = RCovLine.new("", 0)
|
68
|
+
|
69
|
+
expect(rcov_line.ignored?).to eq(false)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#css_class" do
|
74
|
+
it "returns '' for an ignored line" do
|
75
|
+
rcov_line = RCovLine.new("", nil)
|
76
|
+
expect(rcov_line.css_class).to eq("")
|
77
|
+
end
|
78
|
+
|
79
|
+
it "returns 'rcov_not_run' for a missed line" do
|
80
|
+
rcov_line = RCovLine.new("", 0)
|
81
|
+
expect(rcov_line.css_class).to eq("rcov_not_run")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns 'rcov_run' for a covered line" do
|
85
|
+
rcov_line = RCovLine.new("", 1)
|
86
|
+
expect(rcov_line.css_class).to eq("rcov_run")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -1,26 +1,25 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "spec_helper"
|
2
|
+
require "simplecov"
|
3
|
+
require "metric_fu/metrics/rcov/simplecov_formatter"
|
4
|
+
require "metric_fu/metrics/rcov/generator"
|
5
5
|
|
6
6
|
describe SimpleCov::Formatter::MetricFu do
|
7
7
|
before do
|
8
8
|
@rcov_file = subject.coverage_file_path
|
9
|
-
File.delete(
|
9
|
+
File.delete(@rcov_file) if File.exists?(@rcov_file)
|
10
10
|
|
11
11
|
@result = SimpleCov::Result.new(
|
12
|
-
{
|
13
|
-
FIXTURE.fixtures_path.join('coverage.rb').expand_path.to_s =>
|
14
|
-
[1,1,1,1,nil,1,0,1,1,nil,0,1,1]
|
15
|
-
}
|
16
|
-
)
|
17
12
|
|
13
|
+
FIXTURE.fixtures_path.join("coverage.rb").expand_path.to_s =>
|
14
|
+
[1, 1, 1, 1, nil, 1, 0, 1, 1, nil, 0, 1, 1]
|
15
|
+
|
16
|
+
)
|
18
17
|
end
|
19
18
|
|
20
19
|
it "test_format" do
|
21
|
-
SimpleCov::Formatter::MetricFu.new.format(
|
20
|
+
SimpleCov::Formatter::MetricFu.new.format(@result)
|
22
21
|
|
23
|
-
expect(File.exists?(
|
22
|
+
expect(File.exists?(@rcov_file)).to be_truthy
|
24
23
|
end
|
25
24
|
|
26
25
|
if SimpleCov.running
|
@@ -28,7 +27,7 @@ describe SimpleCov::Formatter::MetricFu do
|
|
28
27
|
else
|
29
28
|
it "test_create_content" do
|
30
29
|
content = SimpleCov::Formatter::MetricFu::FormatLikeRCov.new(@result).format
|
31
|
-
test = "\="*80
|
30
|
+
test = "\=" * 80
|
32
31
|
|
33
32
|
expect(content).to match(/#{test}/)
|
34
33
|
expect(content).to match(/!! value \* value/)
|
@@ -37,33 +36,32 @@ describe SimpleCov::Formatter::MetricFu do
|
|
37
36
|
if defined?(JRUBY_VERSION)
|
38
37
|
STDOUT.puts "Skipping spec 'cause JRuby doesn't do Coverage right"
|
39
38
|
else
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
it "calculates the same coverage from an RCov report as from SimpleCov" do
|
40
|
+
SimpleCov.start # start coverage
|
41
|
+
require "fixtures/coverage-153"
|
42
|
+
result = SimpleCov.result # end coverage
|
43
|
+
source_file = result.source_files.first
|
45
44
|
|
45
|
+
# formatter ouputs this from simplecov result
|
46
|
+
rcov_text = SimpleCov::Formatter::MetricFu::FormatLikeRCov.new(result).format
|
46
47
|
|
47
|
-
|
48
|
-
|
48
|
+
# generator analyzes the rcov text
|
49
|
+
analyzed_rcov_text = MetricFu::RCovFormatCoverage.new(rcov_text).to_h
|
50
|
+
# [:lines, :percent_run, :methods]
|
51
|
+
covered_lines_from_rcov_text = analyzed_rcov_text["./spec/fixtures/coverage-153.rb"][:lines]
|
52
|
+
# https://github.com/colszowka/simplecov/blob/master/lib/simplecov/source_file.rb
|
53
|
+
expect(source_file.coverage.count).to eq(covered_lines_from_rcov_text.count)
|
49
54
|
|
50
|
-
|
51
|
-
|
52
|
-
# [:lines, :percent_run, :methods]
|
53
|
-
covered_lines_from_rcov_text = analyzed_rcov_text['./spec/fixtures/coverage-153.rb'][:lines]
|
54
|
-
# https://github.com/colszowka/simplecov/blob/master/lib/simplecov/source_file.rb
|
55
|
-
expect(source_file.coverage.count).to eq(covered_lines_from_rcov_text.count)
|
55
|
+
line_coverage_from_rcov_text = covered_lines_from_rcov_text.map { |line| line[:was_run] }
|
56
|
+
expect(source_file.coverage).to eq(line_coverage_from_rcov_text)
|
56
57
|
|
57
|
-
|
58
|
-
expect(source_file.coverage).to eq(line_coverage_from_rcov_text)
|
58
|
+
expect(source_file.covered_percent).to eq(MetricFu::RCovFormatCoverage::TestCoverage.percent_run(covered_lines_from_rcov_text))
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
expect(line.coverage).to eq(line_coverage_from_rcov_text[index])
|
60
|
+
source_file.lines.each_with_index do |line, index|
|
61
|
+
expect(line.coverage).to eq(line_coverage_from_rcov_text[index])
|
62
|
+
end
|
64
63
|
end
|
65
64
|
end
|
66
|
-
end
|
67
65
|
|
68
66
|
end
|
69
67
|
end
|
@@ -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
|
4
|
+
describe MetricFu::Configuration, "for reek" do
|
5
|
+
it_behaves_like "configured" do
|
6
6
|
it "should set @reek to {:dirs_to_reek => @code_dirs}" do
|
7
|
-
load_metric
|
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,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
MetricFu.metrics_require {
|
2
|
+
MetricFu.metrics_require { "reek/generator" }
|
3
3
|
|
4
4
|
describe MetricFu::ReekGenerator do
|
5
5
|
describe "emit" do
|
6
|
-
let(:options) { {:
|
7
|
-
let(:files_to_analyze) { [
|
6
|
+
let(:options) { { dirs_to_reek: [] } }
|
7
|
+
let(:files_to_analyze) { ["lib/foo.rb", "lib/bar.rb"] }
|
8
8
|
let(:reek) { MetricFu::ReekGenerator.new(options) }
|
9
9
|
|
10
10
|
before :each do
|
@@ -12,54 +12,53 @@ describe MetricFu::ReekGenerator do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "includes config file pattern into reek parameters when specified" do
|
15
|
-
options.merge!(
|
15
|
+
options.merge!(config_file_pattern: "lib/config/*.reek")
|
16
16
|
expect(reek).to receive(:run!) do |args|
|
17
|
-
expect(args).to include(
|
18
|
-
end.and_return(
|
17
|
+
expect(args).to include("--config", "lib/config/*.reek")
|
18
|
+
end.and_return("")
|
19
19
|
reek.emit
|
20
20
|
end
|
21
21
|
|
22
22
|
it "doesn't add an empty parameter when no config file pattern is specified" do
|
23
23
|
expect(reek).to receive(:run!) do |args|
|
24
|
-
expect(args).not_to include(
|
25
|
-
end.and_return(
|
24
|
+
expect(args).not_to include("")
|
25
|
+
end.and_return("")
|
26
26
|
reek.emit
|
27
27
|
end
|
28
28
|
|
29
29
|
it "turns off color output from reek output, for reek 1.3.7 or greater" do
|
30
|
-
allow(reek).to receive(:reek_version).and_return(
|
30
|
+
allow(reek).to receive(:reek_version).and_return("1.3.7")
|
31
31
|
expect(reek).to receive(:run!) do |args|
|
32
|
-
expect(args).to include(
|
32
|
+
expect(args).to include("--no-color")
|
33
33
|
end.and_return("")
|
34
34
|
reek.emit
|
35
35
|
end
|
36
36
|
|
37
37
|
it "does not set an (invalid) --no-color option for reek < 1.3.7" do
|
38
|
-
allow(reek).to receive(:reek_version).and_return(
|
38
|
+
allow(reek).to receive(:reek_version).and_return("1.3.6")
|
39
39
|
expect(reek).to receive(:run!) do |args|
|
40
|
-
expect(args).not_to include(
|
40
|
+
expect(args).not_to include("--no-color")
|
41
41
|
end.and_return("")
|
42
42
|
reek.emit
|
43
43
|
end
|
44
44
|
|
45
45
|
it "disables lines numbers from reek output" do
|
46
46
|
expect(reek).to receive(:run!) do |args|
|
47
|
-
expect(args).to include(
|
47
|
+
expect(args).to include("--no-line-numbers")
|
48
48
|
end.and_return("")
|
49
49
|
reek.emit
|
50
50
|
end
|
51
51
|
|
52
52
|
it "includes files to analyze into reek parameters" do
|
53
53
|
expect(reek).to receive(:run!) do |args|
|
54
|
-
expect(args).to include(
|
54
|
+
expect(args).to include("lib/foo.rb", "lib/bar.rb")
|
55
55
|
end.and_return("")
|
56
56
|
reek.emit
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
#TODO review tested output
|
60
|
+
# TODO review tested output
|
61
61
|
describe "analyze method" do
|
62
|
-
|
63
62
|
before :each do
|
64
63
|
MetricFu::Configuration.run {}
|
65
64
|
allow(File).to receive(:directory?).and_return(true)
|
@@ -110,10 +109,10 @@ NewlineController#some_method calls current_user.<< "new line\n" multiple times
|
|
110
109
|
|
111
110
|
it "should NOT insert nil smells into the array when there's a newline in the method call" do
|
112
111
|
expect(@matches.last[:code_smells]).to eq(@matches.last[:code_smells].compact)
|
113
|
-
expect(@matches.last).to eq(
|
114
|
-
|
115
|
-
:
|
116
|
-
:
|
112
|
+
expect(@matches.last).to eq(file_path: "app/controllers/newline_controller.rb",
|
113
|
+
code_smells: [{ type: "Duplication",
|
114
|
+
method: "\"",
|
115
|
+
message: "multiple times" }])
|
117
116
|
# Note: hopefully a temporary solution until I figure out how to deal with newlines in the method call more effectively -Jake 5/11/2009
|
118
117
|
end
|
119
118
|
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
|
3
|
-
|
4
|
-
describe MetricFu::Configuration, 'for roodi' do
|
5
|
-
it_behaves_like 'configured' do
|
1
|
+
require "spec_helper"
|
2
|
+
require "shared/configured"
|
6
3
|
|
4
|
+
describe MetricFu::Configuration, "for roodi" do
|
5
|
+
it_behaves_like "configured" do
|
7
6
|
it "should set @roodi to {:dirs_to_roodi => @code_dirs}" do
|
8
|
-
load_metric
|
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
|
@@ -3,24 +3,23 @@ require "shared/configured"
|
|
3
3
|
|
4
4
|
describe MetricFu::Configuration, "for saikuro" do
|
5
5
|
it_behaves_like "configured" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
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
|