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.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.rubocop.yml +15 -0
  5. data/.rubocop_todo.yml +69 -0
  6. data/.travis.yml +0 -1
  7. data/CONTRIBUTORS +1 -1
  8. data/Gemfile +23 -20
  9. data/Guardfile +9 -9
  10. data/HISTORY.md +10 -1
  11. data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
  12. data/config/rubocop.yml +269 -0
  13. data/gem_tasks/rubocop.rake +10 -0
  14. data/lib/metric_fu.rb +11 -9
  15. data/lib/metric_fu/calculate.rb +0 -1
  16. data/lib/metric_fu/cli/client.rb +6 -6
  17. data/lib/metric_fu/cli/helper.rb +22 -13
  18. data/lib/metric_fu/cli/parser.rb +14 -18
  19. data/lib/metric_fu/configuration.rb +7 -11
  20. data/lib/metric_fu/constantize.rb +4 -4
  21. data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
  22. data/lib/metric_fu/data_structures/location.rb +12 -14
  23. data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
  24. data/lib/metric_fu/environment.rb +29 -31
  25. data/lib/metric_fu/formatter.rb +4 -6
  26. data/lib/metric_fu/formatter/html.rb +13 -13
  27. data/lib/metric_fu/formatter/syntax.rb +5 -7
  28. data/lib/metric_fu/formatter/yaml.rb +1 -1
  29. data/lib/metric_fu/gem_run.rb +13 -15
  30. data/lib/metric_fu/gem_version.rb +9 -11
  31. data/lib/metric_fu/generator.rb +5 -8
  32. data/lib/metric_fu/io.rb +13 -15
  33. data/lib/metric_fu/loader.rb +17 -18
  34. data/lib/metric_fu/logger.rb +15 -18
  35. data/lib/metric_fu/logging/mf_debugger.rb +4 -4
  36. data/lib/metric_fu/metric.rb +11 -12
  37. data/lib/metric_fu/metrics/cane/generator.rb +10 -9
  38. data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
  39. data/lib/metric_fu/metrics/cane/metric.rb +6 -8
  40. data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
  41. data/lib/metric_fu/metrics/cane/violations.rb +6 -6
  42. data/lib/metric_fu/metrics/churn/generator.rb +2 -6
  43. data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
  44. data/lib/metric_fu/metrics/churn/metric.rb +5 -7
  45. data/lib/metric_fu/metrics/flay/generator.rb +7 -11
  46. data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
  47. data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
  48. data/lib/metric_fu/metrics/flay/metric.rb +5 -7
  49. data/lib/metric_fu/metrics/flog/generator.rb +22 -23
  50. data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
  51. data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
  52. data/lib/metric_fu/metrics/flog/metric.rb +3 -5
  53. data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
  54. data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
  55. data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
  56. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
  57. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
  58. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -9
  59. data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
  60. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
  61. data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
  62. data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
  63. data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
  64. data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
  65. data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
  66. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
  67. data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
  68. data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
  69. data/lib/metric_fu/metrics/rails_best_practices/generator.rb +10 -12
  70. data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
  71. data/lib/metric_fu/metrics/rails_best_practices/metric.rb +1 -3
  72. data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
  73. data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
  74. data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
  75. data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
  76. data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
  77. data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
  78. data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
  79. data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
  80. data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
  81. data/lib/metric_fu/metrics/reek/generator.rb +22 -23
  82. data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
  83. data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
  84. data/lib/metric_fu/metrics/reek/metric.rb +2 -4
  85. data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
  86. data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
  87. data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
  88. data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
  89. data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
  90. data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
  91. data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
  92. data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
  93. data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
  94. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
  95. data/lib/metric_fu/metrics/stats/generator.rb +9 -12
  96. data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
  97. data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
  98. data/lib/metric_fu/metrics/stats/metric.rb +3 -5
  99. data/lib/metric_fu/reporter.rb +1 -1
  100. data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
  101. data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
  102. data/lib/metric_fu/reporting/result.rb +0 -3
  103. data/lib/metric_fu/run.rb +12 -3
  104. data/lib/metric_fu/tasks/metric_fu.rake +8 -8
  105. data/lib/metric_fu/templates/configuration.rb +2 -5
  106. data/lib/metric_fu/templates/metrics_template.rb +19 -19
  107. data/lib/metric_fu/templates/report.rb +5 -8
  108. data/lib/metric_fu/templates/template.rb +20 -24
  109. data/lib/metric_fu/utility.rb +7 -8
  110. data/lib/metric_fu/version.rb +1 -1
  111. data/metric_fu.gemspec +31 -32
  112. data/spec/cli/helper_spec.rb +7 -14
  113. data/spec/dummy/lib/bad_encoding.rb +1 -1
  114. data/spec/fixtures/coverage-153.rb +2 -2
  115. data/spec/fixtures/coverage.rb +2 -2
  116. data/spec/metric_fu/calculate_spec.rb +3 -3
  117. data/spec/metric_fu/configuration_spec.rb +70 -82
  118. data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
  119. data/spec/metric_fu/data_structures/location_spec.rb +13 -31
  120. data/spec/metric_fu/formatter/configuration_spec.rb +11 -13
  121. data/spec/metric_fu/formatter/html_spec.rb +21 -28
  122. data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
  123. data/spec/metric_fu/formatter_spec.rb +6 -6
  124. data/spec/metric_fu/gem_version_spec.rb +3 -5
  125. data/spec/metric_fu/generator_spec.rb +28 -38
  126. data/spec/metric_fu/loader_spec.rb +1 -3
  127. data/spec/metric_fu/metric_spec.rb +17 -21
  128. data/spec/metric_fu/metrics/cane/configuration_spec.rb +8 -8
  129. data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
  130. data/spec/metric_fu/metrics/churn/configuration_spec.rb +6 -8
  131. data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
  132. data/spec/metric_fu/metrics/flay/configuration_spec.rb +6 -8
  133. data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
  134. data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
  135. data/spec/metric_fu/metrics/flog/configuration_spec.rb +11 -13
  136. data/spec/metric_fu/metrics/flog/generator_spec.rb +29 -31
  137. data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
  138. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
  139. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
  140. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
  141. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
  142. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
  143. data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
  144. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
  145. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
  146. data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +6 -10
  147. data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
  148. data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
  149. data/spec/metric_fu/metrics/rcov/configuration_spec.rb +20 -22
  150. data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
  151. data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
  152. data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
  153. data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
  154. data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
  155. data/spec/metric_fu/metrics/reek/configuration_spec.rb +6 -6
  156. data/spec/metric_fu/metrics/reek/generator_spec.rb +19 -20
  157. data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
  158. data/spec/metric_fu/metrics/roodi/configuration_spec.rb +7 -9
  159. data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
  160. data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
  161. data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +18 -19
  162. data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
  163. data/spec/metric_fu/metrics/stats/generator_spec.rb +9 -9
  164. data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
  165. data/spec/metric_fu/reporter_spec.rb +3 -4
  166. data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
  167. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
  168. data/spec/metric_fu/reporting/result_spec.rb +9 -11
  169. data/spec/metric_fu/run_spec.rb +18 -32
  170. data/spec/metric_fu/templates/configuration_spec.rb +28 -34
  171. data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
  172. data/spec/metric_fu/templates/report_spec.rb +4 -4
  173. data/spec/metric_fu/templates/template_spec.rb +62 -48
  174. data/spec/metric_fu/utility_spec.rb +2 -2
  175. data/spec/metric_fu_spec.rb +5 -7
  176. data/spec/shared/configured.rb +9 -11
  177. data/spec/shared/test_coverage.rb +5 -9
  178. data/spec/spec_helper.rb +9 -9
  179. data/spec/support/deferred_garbaged_collection.rb +1 -2
  180. data/spec/support/matcher_create_file.rb +2 -4
  181. data/spec/support/matcher_create_files.rb +2 -4
  182. data/spec/support/suite.rb +3 -3
  183. data/spec/support/test_fixtures.rb +5 -7
  184. data/spec/support/timeout.rb +1 -1
  185. data/spec/support/usage_test.rb +23 -24
  186. data/spec/usage_test_spec.rb +18 -20
  187. metadata +12 -2
  188. metadata.gz.sig +0 -0
@@ -1,20 +1,20 @@
1
1
  require "spec_helper"
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' }
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 'spec_helper'
2
- require 'simplecov'
3
- require 'metric_fu/metrics/rcov/simplecov_formatter'
4
- require 'metric_fu/metrics/rcov/generator'
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( @rcov_file ) if File.exists?( @rcov_file )
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( @result )
20
+ SimpleCov::Formatter::MetricFu.new.format(@result)
22
21
 
23
- expect(File.exists?( @rcov_file )).to be_truthy
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
- it "calculates the same coverage from an RCov report as from SimpleCov" do
41
- SimpleCov.start # start coverage
42
- require 'fixtures/coverage-153'
43
- result = SimpleCov.result # end coverage
44
- source_file = result.source_files.first
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
- # formatter ouputs this from simplecov result
48
- rcov_text = SimpleCov::Formatter::MetricFu::FormatLikeRCov.new(result).format
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
- # generator analyzes the rcov text
51
- analyzed_rcov_text = MetricFu::RCovFormatCoverage.new(rcov_text).to_h
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
- line_coverage_from_rcov_text = covered_lines_from_rcov_text.map{|line| line[:was_run] }
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
- expect(source_file.covered_percent).to eq(MetricFu::RCovFormatCoverage::TestCoverage.percent_run(covered_lines_from_rcov_text))
61
-
62
- source_file.lines.each_with_index do |line, index|
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 'spec_helper'
2
- require 'shared/configured'
1
+ require "spec_helper"
2
+ require "shared/configured"
3
3
 
4
- describe MetricFu::Configuration, 'for reek' do
5
- it_behaves_like 'configured' do
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 'reek'
7
+ load_metric "reek"
8
8
  expect(MetricFu::Metric.get_metric(:reek).run_options).to eq(
9
- {:config_file_pattern=>nil, :dirs_to_reek => ['lib']}
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 { 'reek/generator' }
2
+ MetricFu.metrics_require { "reek/generator" }
3
3
 
4
4
  describe MetricFu::ReekGenerator do
5
5
  describe "emit" do
6
- let(:options) { {:dirs_to_reek => []} }
7
- let(:files_to_analyze) { ['lib/foo.rb','lib/bar.rb'] }
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!({:config_file_pattern => 'lib/config/*.reek' })
15
+ options.merge!(config_file_pattern: "lib/config/*.reek")
16
16
  expect(reek).to receive(:run!) do |args|
17
- expect(args).to include('--config', 'lib/config/*.reek')
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('1.3.7')
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('--no-color')
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('1.3.6')
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('--no-color')
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('--no-line-numbers')
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('lib/foo.rb', 'lib/bar.rb')
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({:file_path=>"app/controllers/newline_controller.rb",
114
- :code_smells=>[{:type=>"Duplication",
115
- :method=>"\"",
116
- :message=>"multiple times"}]})
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 { 'reek/grapher' }
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({ 0 => "1/2" })
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 'spec_helper'
2
- require 'shared/configured'
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 'roodi'
7
+ load_metric "roodi"
9
8
  expect(MetricFu::Metric.get_metric(:roodi).run_options).to eq(
10
- { :dirs_to_roodi => directory('code_dirs'),
11
- :roodi_config => "#{directory('root_directory')}/config/roodi_config.yml"}
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 { 'roodi/generator' }
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 = {:roodi_config => 'lib/config/roodi_config.yml', :dirs_to_roodi => []}
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 = {:dirs_to_roodi => []}
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 { 'roodi/grapher' }
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({ 0 => "1/2" })
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
- it "should set @saikuro to { :output_directory => @scratch_directory + '/saikuro',
8
- :input_directory => @code_dirs,
9
- :cyclo => '',
10
- :filter_cyclo => '0',
11
- :warn_cyclo => '5',
12
- :error_cyclo => '7',
13
- :formater => 'text' }" do
14
- load_metric "saikuro"
15
- expect(MetricFu::Metric.get_metric(:saikuro).run_options).to eq(
16
- { :output_directory => "#{scratch_directory}/saikuro",
17
- :input_directory => ["lib"],
18
- :cyclo => "",
19
- :filter_cyclo => "0",
20
- :warn_cyclo => "5",
21
- :error_cyclo => "7",
22
- :formater => "text"}
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