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.
Files changed (206) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +6 -0
  3. data/.rubocop.yml +15 -0
  4. data/.rubocop_todo.yml +69 -0
  5. data/.simplecov +35 -3
  6. data/.travis.yml +6 -10
  7. data/CONTRIBUTORS +12 -11
  8. data/Gemfile +48 -29
  9. data/Guardfile +9 -9
  10. data/HISTORY.md +47 -1
  11. data/README.md +70 -57
  12. data/Rakefile +1 -15
  13. data/appveyor.yml +34 -0
  14. data/certs/bf4.pem +20 -20
  15. data/checksum/metric_fu-4.11.1.gem.sha512 +1 -0
  16. data/checksum/metric_fu-4.11.2.gem.sha512 +1 -0
  17. data/checksum/metric_fu-4.11.3.gem.sha512 +1 -0
  18. data/checksum/metric_fu-4.11.4.gem.sha512 +1 -0
  19. data/checksum/metric_fu-4.12.0.gem.sha512 +1 -0
  20. data/checksum/metric_fu-4.13.0.gem.sha512 +1 -0
  21. data/config/rubocop.yml +269 -0
  22. data/gem_tasks/build.rake +1 -0
  23. data/gem_tasks/rubocop.rake +10 -0
  24. data/gem_tasks/yard.rake +24 -0
  25. data/lib/metric_fu.rb +20 -9
  26. data/lib/metric_fu/calculate.rb +0 -1
  27. data/lib/metric_fu/cli/client.rb +6 -6
  28. data/lib/metric_fu/cli/helper.rb +22 -13
  29. data/lib/metric_fu/cli/parser.rb +14 -18
  30. data/lib/metric_fu/configuration.rb +7 -11
  31. data/lib/metric_fu/constantize.rb +4 -4
  32. data/lib/metric_fu/data_structures/line_numbers.rb +10 -11
  33. data/lib/metric_fu/data_structures/location.rb +12 -14
  34. data/lib/metric_fu/data_structures/sexp_node.rb +31 -13
  35. data/lib/metric_fu/environment.rb +29 -31
  36. data/lib/metric_fu/formatter.rb +4 -6
  37. data/lib/metric_fu/formatter/html.rb +13 -13
  38. data/lib/metric_fu/formatter/syntax.rb +5 -7
  39. data/lib/metric_fu/formatter/yaml.rb +1 -1
  40. data/lib/metric_fu/gem_run.rb +13 -15
  41. data/lib/metric_fu/gem_version.rb +10 -12
  42. data/lib/metric_fu/generator.rb +6 -9
  43. data/lib/metric_fu/io.rb +13 -15
  44. data/lib/metric_fu/loader.rb +17 -18
  45. data/lib/metric_fu/logger.rb +15 -18
  46. data/lib/metric_fu/logging/mf_debugger.rb +4 -4
  47. data/lib/metric_fu/metric.rb +11 -12
  48. data/lib/metric_fu/metrics/cane/generator.rb +10 -9
  49. data/lib/metric_fu/metrics/cane/grapher.rb +5 -7
  50. data/lib/metric_fu/metrics/cane/metric.rb +6 -8
  51. data/lib/metric_fu/metrics/cane/report.html.erb +3 -3
  52. data/lib/metric_fu/metrics/cane/violations.rb +6 -6
  53. data/lib/metric_fu/metrics/churn/generator.rb +2 -6
  54. data/lib/metric_fu/metrics/churn/hotspot.rb +1 -3
  55. data/lib/metric_fu/metrics/churn/metric.rb +5 -7
  56. data/lib/metric_fu/metrics/flay/generator.rb +7 -11
  57. data/lib/metric_fu/metrics/flay/grapher.rb +5 -6
  58. data/lib/metric_fu/metrics/flay/hotspot.rb +5 -7
  59. data/lib/metric_fu/metrics/flay/metric.rb +5 -7
  60. data/lib/metric_fu/metrics/flog/generator.rb +35 -24
  61. data/lib/metric_fu/metrics/flog/grapher.rb +11 -11
  62. data/lib/metric_fu/metrics/flog/hotspot.rb +3 -5
  63. data/lib/metric_fu/metrics/flog/metric.rb +3 -5
  64. data/lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb +0 -1
  65. data/lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb +19 -18
  66. data/lib/metric_fu/metrics/hotspots/analysis/grouping.rb +0 -2
  67. data/lib/metric_fu/metrics/hotspots/analysis/groupings.rb +1 -3
  68. data/lib/metric_fu/metrics/hotspots/analysis/problems.rb +4 -6
  69. data/lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb +14 -17
  70. data/lib/metric_fu/metrics/hotspots/analysis/ranking.rb +4 -5
  71. data/lib/metric_fu/metrics/hotspots/analysis/rankings.rb +1 -3
  72. data/lib/metric_fu/metrics/hotspots/analysis/record.rb +3 -5
  73. data/lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb +0 -2
  74. data/lib/metric_fu/metrics/hotspots/analysis/table.rb +3 -4
  75. data/lib/metric_fu/metrics/hotspots/generator.rb +3 -6
  76. data/lib/metric_fu/metrics/hotspots/hotspot.rb +13 -13
  77. data/lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb +5 -8
  78. data/lib/metric_fu/metrics/hotspots/metric.rb +1 -3
  79. data/lib/metric_fu/metrics/hotspots/report.html.erb +1 -1
  80. data/lib/metric_fu/metrics/rails_best_practices/generator.rb +14 -12
  81. data/lib/metric_fu/metrics/rails_best_practices/grapher.rb +5 -6
  82. data/lib/metric_fu/metrics/rails_best_practices/metric.rb +5 -4
  83. data/lib/metric_fu/metrics/rcov/external_client.rb +1 -3
  84. data/lib/metric_fu/metrics/rcov/generator.rb +13 -15
  85. data/lib/metric_fu/metrics/rcov/grapher.rb +6 -7
  86. data/lib/metric_fu/metrics/rcov/hotspot.rb +5 -7
  87. data/lib/metric_fu/metrics/rcov/metric.rb +5 -7
  88. data/lib/metric_fu/metrics/rcov/rcov_format_coverage.rb +16 -55
  89. data/lib/metric_fu/metrics/rcov/rcov_line.rb +48 -0
  90. data/lib/metric_fu/metrics/rcov/report.html.erb +2 -2
  91. data/lib/metric_fu/metrics/rcov/simplecov_formatter.rb +10 -11
  92. data/lib/metric_fu/metrics/reek/generator.rb +36 -82
  93. data/lib/metric_fu/metrics/reek/grapher.rb +5 -6
  94. data/lib/metric_fu/metrics/reek/hotspot.rb +5 -7
  95. data/lib/metric_fu/metrics/reek/metric.rb +2 -4
  96. data/lib/metric_fu/metrics/roodi/generator.rb +9 -10
  97. data/lib/metric_fu/metrics/roodi/grapher.rb +5 -6
  98. data/lib/metric_fu/metrics/roodi/hotspot.rb +1 -3
  99. data/lib/metric_fu/metrics/roodi/metric.rb +2 -4
  100. data/lib/metric_fu/metrics/saikuro/generator.rb +23 -27
  101. data/lib/metric_fu/metrics/saikuro/hotspot.rb +1 -3
  102. data/lib/metric_fu/metrics/saikuro/metric.rb +7 -8
  103. data/lib/metric_fu/metrics/saikuro/parsing_element.rb +6 -8
  104. data/lib/metric_fu/metrics/saikuro/report.html.erb +1 -1
  105. data/lib/metric_fu/metrics/saikuro/scratch_file.rb +24 -29
  106. data/lib/metric_fu/metrics/stats/generator.rb +9 -12
  107. data/lib/metric_fu/metrics/stats/grapher.rb +8 -9
  108. data/lib/metric_fu/metrics/stats/hotspot.rb +1 -3
  109. data/lib/metric_fu/metrics/stats/metric.rb +3 -5
  110. data/lib/metric_fu/reporter.rb +1 -1
  111. data/lib/metric_fu/reporting/graphs/graph.rb +8 -12
  112. data/lib/metric_fu/reporting/graphs/grapher.rb +7 -9
  113. data/lib/metric_fu/reporting/result.rb +0 -3
  114. data/lib/metric_fu/run.rb +12 -3
  115. data/lib/metric_fu/tasks/metric_fu.rake +8 -8
  116. data/lib/metric_fu/templates/configuration.rb +2 -5
  117. data/lib/metric_fu/templates/metrics_template.rb +45 -32
  118. data/lib/metric_fu/templates/report.rb +5 -8
  119. data/lib/metric_fu/templates/template.rb +20 -24
  120. data/lib/metric_fu/utility.rb +15 -8
  121. data/lib/metric_fu/version.rb +7 -1
  122. data/metric_fu.gemspec +29 -32
  123. data/spec/capture_warnings.rb +29 -22
  124. data/spec/cli/helper_spec.rb +9 -16
  125. data/spec/dummy/lib/bad_encoding.rb +1 -1
  126. data/spec/fixtures/coverage-153.rb +2 -2
  127. data/spec/fixtures/coverage.rb +2 -2
  128. data/spec/metric_fu/calculate_spec.rb +3 -3
  129. data/spec/metric_fu/configuration_spec.rb +71 -83
  130. data/spec/metric_fu/data_structures/line_numbers_spec.rb +3 -5
  131. data/spec/metric_fu/data_structures/location_spec.rb +13 -31
  132. data/spec/metric_fu/formatter/configuration_spec.rb +18 -20
  133. data/spec/metric_fu/formatter/html_spec.rb +21 -28
  134. data/spec/metric_fu/formatter/yaml_spec.rb +9 -17
  135. data/spec/metric_fu/formatter_spec.rb +16 -16
  136. data/spec/metric_fu/gem_version_spec.rb +4 -6
  137. data/spec/metric_fu/generator_spec.rb +33 -43
  138. data/spec/metric_fu/loader_spec.rb +5 -4
  139. data/spec/metric_fu/metric_spec.rb +21 -25
  140. data/spec/metric_fu/metrics/cane/configuration_spec.rb +14 -14
  141. data/spec/metric_fu/metrics/cane/generator_spec.rb +26 -29
  142. data/spec/metric_fu/metrics/churn/configuration_spec.rb +7 -9
  143. data/spec/metric_fu/metrics/churn/generator_spec.rb +6 -11
  144. data/spec/metric_fu/metrics/flay/configuration_spec.rb +7 -9
  145. data/spec/metric_fu/metrics/flay/generator_spec.rb +36 -37
  146. data/spec/metric_fu/metrics/flay/grapher_spec.rb +2 -2
  147. data/spec/metric_fu/metrics/flog/configuration_spec.rb +12 -14
  148. data/spec/metric_fu/metrics/flog/generator_spec.rb +31 -32
  149. data/spec/metric_fu/metrics/flog/grapher_spec.rb +8 -10
  150. data/spec/metric_fu/metrics/hotspots/analysis/analyzed_problems_spec.rb +18 -24
  151. data/spec/metric_fu/metrics/hotspots/analysis/analyzer_tables_spec.rb +12 -17
  152. data/spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb +2 -6
  153. data/spec/metric_fu/metrics/hotspots/analysis/rankings_spec.rb +5 -14
  154. data/spec/metric_fu/metrics/hotspots/analysis/table_spec.rb +1 -3
  155. data/spec/metric_fu/metrics/hotspots/generator_spec.rb +6 -8
  156. data/spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb +1 -3
  157. data/spec/metric_fu/metrics/hotspots/hotspot_spec.rb +4 -5
  158. data/spec/metric_fu/metrics/rails_best_practices/configuration_spec.rb +25 -17
  159. data/spec/metric_fu/metrics/rails_best_practices/generator_spec.rb +2 -3
  160. data/spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb +3 -3
  161. data/spec/metric_fu/metrics/rcov/configuration_spec.rb +21 -23
  162. data/spec/metric_fu/metrics/rcov/generator_spec.rb +6 -10
  163. data/spec/metric_fu/metrics/rcov/grapher_spec.rb +2 -2
  164. data/spec/metric_fu/metrics/rcov/hotspot_spec.rb +8 -8
  165. data/spec/metric_fu/metrics/rcov/rcov_line_spec.rb +89 -0
  166. data/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb +31 -33
  167. data/spec/metric_fu/metrics/reek/configuration_spec.rb +7 -7
  168. data/spec/metric_fu/metrics/reek/generator_spec.rb +131 -111
  169. data/spec/metric_fu/metrics/reek/grapher_spec.rb +4 -4
  170. data/spec/metric_fu/metrics/roodi/configuration_spec.rb +8 -10
  171. data/spec/metric_fu/metrics/roodi/generator_spec.rb +3 -3
  172. data/spec/metric_fu/metrics/roodi/grapher_spec.rb +2 -2
  173. data/spec/metric_fu/metrics/saikuro/configuration_spec.rb +22 -23
  174. data/spec/metric_fu/metrics/saikuro/generator_spec.rb +7 -7
  175. data/spec/metric_fu/metrics/stats/generator_spec.rb +10 -10
  176. data/spec/metric_fu/metrics/stats/grapher_spec.rb +2 -2
  177. data/spec/metric_fu/reporter_spec.rb +8 -9
  178. data/spec/metric_fu/reporting/graphs/graph_spec.rb +1 -4
  179. data/spec/metric_fu/reporting/graphs/grapher_spec.rb +5 -5
  180. data/spec/metric_fu/reporting/result_spec.rb +12 -14
  181. data/spec/metric_fu/run_spec.rb +19 -33
  182. data/spec/metric_fu/templates/configuration_spec.rb +34 -40
  183. data/spec/metric_fu/templates/metrics_template_spec.rb +11 -0
  184. data/spec/metric_fu/templates/report_spec.rb +4 -4
  185. data/spec/metric_fu/templates/template_spec.rb +78 -64
  186. data/spec/metric_fu/utility_spec.rb +3 -3
  187. data/spec/metric_fu_spec.rb +23 -6
  188. data/spec/quality_spec.rb +43 -15
  189. data/spec/shared/configured.rb +9 -11
  190. data/spec/shared/test_coverage.rb +5 -9
  191. data/spec/spec_helper.rb +13 -31
  192. data/spec/{dummy → support}/.metrics +0 -0
  193. data/spec/support/deferred_garbaged_collection.rb +1 -2
  194. data/spec/support/matcher_create_file.rb +6 -4
  195. data/spec/support/matcher_create_files.rb +6 -4
  196. data/spec/support/samples/reek/alfa.rb +1 -0
  197. data/spec/support/suite.rb +3 -3
  198. data/spec/support/test_fixtures.rb +5 -7
  199. data/spec/support/timeout.rb +1 -1
  200. data/spec/support/usage_test.rb +24 -25
  201. data/spec/usage_test_spec.rb +30 -32
  202. metadata +104 -103
  203. checksums.yaml.gz.sig +0 -0
  204. data.tar.gz.sig +0 -0
  205. data/gemfiles/Gemfile.travis +0 -10
  206. metadata.gz.sig +0 -0
@@ -1,12 +1,13 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe MetricFu do
4
-
5
4
  it "loads the .metrics file" do
6
5
  # Global only for testing that this file gets loaded
7
6
  $metric_file_loaded = false
8
- MetricFu.loader.load_user_configuration
7
+ MetricFu.with_run_dir "spec/support" do
8
+ MetricFu.loader.load_user_configuration
9
+ end
10
+
9
11
  expect($metric_file_loaded).to be_truthy
10
12
  end
11
-
12
13
  end
@@ -1,47 +1,43 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe MetricFu::Metric do
4
4
  before do
5
5
  @metric = MetricFu::Metric.get_metric(:flog)
6
- #@original_options = @metric.run_options.dup
6
+ # @original_options = @metric.run_options.dup
7
7
  end
8
8
 
9
- #it 'can have its run_options over-written' do
10
- #new_options = {:foo => 'bar'}
11
- #@metric.run_options = new_options
12
- #expect(@original_options).to_not eq(new_options)
13
- #expect(@metric.run_options).to eq(new_options)
14
- #end
9
+ # it "can have its run_options over-written" do
10
+ # new_options = {:foo => 'bar'}
11
+ # @metric.run_options = new_options
12
+ # expect(@original_options).to_not eq(new_options)
13
+ # expect(@metric.run_options).to eq(new_options)
14
+ # end
15
15
 
16
- #it 'can have its run_options modified' do
17
- #new_options = {:foo => 'bar'}
18
- #@metric.run_options.merge!(new_options)
19
- #expect(@metric.run_options).to eq(@original_options.merge(new_options))
20
- #end
21
-
22
- context 'given a valid configurable option' do
16
+ # it "can have its run_options modified" do
17
+ # new_options = {:foo => 'bar'}
18
+ # @metric.run_options.merge!(new_options)
19
+ # expect(@metric.run_options).to eq(@original_options.merge(new_options))
20
+ # end
23
21
 
22
+ context "given a valid configurable option" do
24
23
  before do
25
- allow(@metric).to receive(:default_run_options).and_return({:foo => 'baz'})
24
+ allow(@metric).to receive(:default_run_options).and_return(foo: "baz")
26
25
  end
27
26
 
28
- it 'can be configured as an attribute' do
29
- @metric.foo = 'qux'
30
- expect(@metric.run_options[:foo]).to eq('qux')
27
+ it "can be configured as an attribute" do
28
+ @metric.foo = "qux"
29
+ expect(@metric.run_options[:foo]).to eq("qux")
31
30
  end
32
-
33
31
  end
34
32
 
35
- context 'given an invalid configurable option' do
36
-
33
+ context "given an invalid configurable option" do
37
34
  before do
38
35
  allow(@metric).to receive(:default_run_options).and_return({})
39
36
  end
40
37
 
41
- it 'raises an error' do
42
- expect { @metric.foo = 'bar' }.to raise_error(RuntimeError, /not a valid configuration option/)
38
+ it "raises an error" do
39
+ expect { @metric.foo = "bar" }.to raise_error(RuntimeError, /not a valid configuration option/)
43
40
  end
44
-
45
41
  end
46
42
 
47
43
  after do
@@ -1,20 +1,20 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
1
+ require "spec_helper"
2
+ require "shared/configured"
3
3
 
4
- describe MetricFu::Configuration, 'for cane' do
5
- it_behaves_like 'configured' do
4
+ describe MetricFu::Configuration, "for cane" do
5
+ it_behaves_like "configured" do
6
6
  if MetricFu.configuration.mri?
7
- it 'should set @cane to ' +
8
- %q(:dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => 'n', :no_readme => 'y') do
9
- load_metric 'cane'
7
+ it "should set @cane to " +
8
+ ':dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => "n", :no_readme => "y"' do
9
+ load_metric "cane"
10
10
  expect(MetricFu::Metric.get_metric(:cane).run_options).to eq(
11
- {
12
- :dirs_to_cane => directory('code_dirs'),
13
- :filetypes => ["rb"],
14
- :abc_max => 15,
15
- :line_length => 80,
16
- :no_doc => "n",
17
- :no_readme => "n"}
11
+
12
+ dirs_to_cane: directory("code_dirs"),
13
+ filetypes: ["rb"],
14
+ abc_max: 15,
15
+ line_length: 80,
16
+ no_doc: "n",
17
+ no_readme: "n"
18
18
  )
19
19
  end
20
20
  end
@@ -1,9 +1,8 @@
1
- require 'spec_helper'
2
- MetricFu.metrics_require { 'cane/generator' }
1
+ require "spec_helper"
2
+ MetricFu.metrics_require { "cane/generator" }
3
3
 
4
4
  describe CaneGenerator do
5
5
  describe "emit method" do
6
-
7
6
  it "should execute cane command" do
8
7
  options = {}
9
8
  @cane = MetricFu::CaneGenerator.new(options)
@@ -12,42 +11,42 @@ describe CaneGenerator do
12
11
  end
13
12
 
14
13
  it "should use abc max option" do
15
- options = {abc_max: 20}
14
+ options = { abc_max: 20 }
16
15
  @cane = MetricFu::CaneGenerator.new(options)
17
16
  expect(@cane).to receive(:run!).with(" --abc-max 20")
18
17
  output = @cane.emit
19
18
  end
20
19
 
21
20
  it "should use style max line length option" do
22
- options = {line_length: 100}
21
+ options = { line_length: 100 }
23
22
  @cane = MetricFu::CaneGenerator.new(options)
24
23
  expect(@cane).to receive(:run!).with(" --style-measure 100")
25
24
  output = @cane.emit
26
25
  end
27
26
 
28
27
  it "should use no-doc if specified" do
29
- options = {no_doc: 'y'}
28
+ options = { no_doc: "y" }
30
29
  @cane = MetricFu::CaneGenerator.new(options)
31
30
  expect(@cane).to receive(:run!).with(" --no-doc")
32
31
  output = @cane.emit
33
32
  end
34
33
 
35
34
  it "should include doc violations if no_doc != 'y'" do
36
- options = {no_doc: 'n'}
35
+ options = { no_doc: "n" }
37
36
  @cane = MetricFu::CaneGenerator.new(options)
38
37
  expect(@cane).to receive(:run!).with("")
39
38
  output = @cane.emit
40
39
  end
41
40
 
42
41
  it "should use no-readme if specified" do
43
- options = {no_readme: 'y'}
42
+ options = { no_readme: "y" }
44
43
  @cane = MetricFu::CaneGenerator.new(options)
45
44
  expect(@cane).to receive(:run!).with(" --no-readme")
46
45
  output = @cane.emit
47
46
  end
48
47
 
49
48
  it "should include README violations if no_readme != 'y'" do
50
- options = {no_readme: 'n'}
49
+ options = { no_readme: "n" }
51
50
  @cane = MetricFu::CaneGenerator.new(options)
52
51
  expect(@cane).to receive(:run!).with("")
53
52
  output = @cane.emit
@@ -60,11 +59,10 @@ describe CaneGenerator do
60
59
  allow(File).to receive(:directory?).and_return(true)
61
60
  options = {}
62
61
  @cane = MetricFu::CaneGenerator.new(options)
63
- @cane.instance_variable_set(:@output, '')
62
+ @cane.instance_variable_set(:@output, "")
64
63
  end
65
64
 
66
65
  describe "analyze method" do
67
-
68
66
  it "should find total violations" do
69
67
  @cane.analyze
70
68
  expect(@cane.total_violations).to eq(0)
@@ -77,12 +75,11 @@ describe CaneGenerator do
77
75
  lines = sample_cane_output
78
76
  MetricFu::Configuration.run {}
79
77
  allow(File).to receive(:directory?).and_return(true)
80
- @cane = MetricFu::CaneGenerator.new('base_dir')
78
+ @cane = MetricFu::CaneGenerator.new("base_dir")
81
79
  @cane.instance_variable_set(:@output, lines)
82
80
  end
83
81
 
84
82
  describe "analyze method" do
85
-
86
83
  it "should find total violations" do
87
84
  @cane.analyze
88
85
  expect(@cane.total_violations).to eq(6)
@@ -91,39 +88,39 @@ describe CaneGenerator do
91
88
  it "should extract abc complexity violations" do
92
89
  @cane.analyze
93
90
  expect(@cane.violations[:abc_complexity]).to eq([
94
- {file: 'lib/abc/foo.rb', method: 'Abc::Foo#method', complexity: '11'},
95
- {file: 'lib/abc/bar.rb', method: 'Abc::Bar#method', complexity: '22'}
91
+ { file: "lib/abc/foo.rb", method: "Abc::Foo#method", complexity: "11" },
92
+ { file: "lib/abc/bar.rb", method: "Abc::Bar#method", complexity: "22" }
96
93
  ])
97
94
  end
98
95
 
99
96
  it "should extract line style violations" do
100
97
  @cane.analyze
101
98
  expect(@cane.violations[:line_style]).to eq([
102
- {line: 'lib/line/foo.rb:1', description: 'Line is >80 characters (135)'},
103
- {line: 'lib/line/bar.rb:2', description: 'Line contains trailing whitespace'}
99
+ { line: "lib/line/foo.rb:1", description: "Line is >80 characters (135)" },
100
+ { line: "lib/line/bar.rb:2", description: "Line contains trailing whitespace" }
104
101
  ])
105
102
  end
106
103
 
107
104
  it "should extract comment violations" do
108
105
  @cane.analyze
109
106
  expect(@cane.violations[:comment]).to eq([
110
- {line: 'lib/comments/foo.rb:1', class_name: 'Foo'},
111
- {line: 'lib/comments/bar.rb:2', class_name: 'Bar'}
107
+ { line: "lib/comments/foo.rb:1", class_name: "Foo" },
108
+ { line: "lib/comments/bar.rb:2", class_name: "Bar" }
112
109
  ])
113
110
  end
114
111
 
115
112
  it "should extract no readme violations if present" do
116
113
  @cane.analyze
117
114
  expect(@cane.violations[:documentation]).to eq([
118
- {description: 'No README found'},
115
+ { description: "No README found" },
119
116
  ])
120
117
  end
121
118
 
122
119
  it "should extract unknown violations in others category" do
123
120
  @cane.analyze
124
121
  expect(@cane.violations[:others]).to eq([
125
- {description: 'Misc issue 1'},
126
- {description: 'Misc issue 2'}
122
+ { description: "Misc issue 1" },
123
+ { description: "Misc issue 2" }
127
124
  ])
128
125
  end
129
126
  end
@@ -134,19 +131,19 @@ describe CaneGenerator do
134
131
  expect(@cane.to_h[:cane][:total_violations]).to eq(6)
135
132
  end
136
133
 
137
- it "should have violations by category" do
134
+ it "should have violations by category" do
138
135
  @cane.analyze
139
136
  expect(@cane.to_h[:cane][:violations][:abc_complexity]).to eq([
140
- {file: 'lib/abc/foo.rb', method: 'Abc::Foo#method', complexity: '11'},
141
- {file: 'lib/abc/bar.rb', method: 'Abc::Bar#method', complexity: '22'}
137
+ { file: "lib/abc/foo.rb", method: "Abc::Foo#method", complexity: "11" },
138
+ { file: "lib/abc/bar.rb", method: "Abc::Bar#method", complexity: "22" }
142
139
  ])
143
140
  expect(@cane.to_h[:cane][:violations][:line_style]).to eq([
144
- {line: 'lib/line/foo.rb:1', description: 'Line is >80 characters (135)'},
145
- {line: 'lib/line/bar.rb:2', description: 'Line contains trailing whitespace'}
141
+ { line: "lib/line/foo.rb:1", description: "Line is >80 characters (135)" },
142
+ { line: "lib/line/bar.rb:2", description: "Line contains trailing whitespace" }
146
143
  ])
147
144
  expect(@cane.to_h[:cane][:violations][:comment]).to eq([
148
- {line: 'lib/comments/foo.rb:1', class_name: 'Foo'},
149
- {line: 'lib/comments/bar.rb:2', class_name: 'Bar'}
145
+ { line: "lib/comments/foo.rb:1", class_name: "Foo" },
146
+ { line: "lib/comments/bar.rb:2", class_name: "Bar" }
150
147
  ])
151
148
  end
152
149
  end
@@ -1,15 +1,13 @@
1
- require 'spec_helper'
2
- require 'shared/configured'
1
+ require "spec_helper"
2
+ require "shared/configured"
3
3
 
4
- describe MetricFu::Configuration, 'for churn' do
5
- it_behaves_like 'configured' do
6
-
7
- it 'should set @churn to {}' do
8
- load_metric 'churn'
4
+ describe MetricFu::Configuration, "for churn" do
5
+ it_behaves_like "configured" do
6
+ it "should set @churn to {}" do
7
+ load_metric "churn"
9
8
  expect(MetricFu::Metric.get_metric(:churn).run_options).to eq(
10
- { :start_date => %q("1 year ago"), :minimum_churn_count => 10, :ignore_files=>[], :data_directory=> MetricFu::Io::FileSystem.scratch_directory('churn')}
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 { 'churn/generator' }
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['CC_BUILD_ARTIFACTS'] = nil
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({:churn => {}})
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({: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"]}})
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, {:churn => 'results'})
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 'spec_helper'
2
- require 'shared/configured'
1
+ require "spec_helper"
2
+ require "shared/configured"
3
3
 
4
- describe MetricFu::Configuration, 'for flay' do
5
- it_behaves_like 'configured' do
6
-
7
- it 'should set @flay to {:dirs_to_flay => @code_dirs}' do
8
- load_metric 'flay'
4
+ describe MetricFu::Configuration, "for flay" do
5
+ it_behaves_like "configured" do
6
+ it "should set @flay to {:dirs_to_flay => @code_dirs}" do
7
+ load_metric "flay"
9
8
  expect(MetricFu::Metric.get_metric(:flay).run_options).to eq(
10
- {:dirs_to_flay => ['lib'], :minimum_score=>nil}
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 { 'flay/generator' }
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 = { :dirs_to_flay => ['app', 'lib'] }
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 = { :dirs_to_flay => [], :minimum_score => 99 }
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('base_dir')
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([ ["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"] ])
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 = [ ["Total score (lower is better) = 284"],
64
- ["\n1) IDENTICAL code found in :or (mass*2 = 68)",
65
- "app/controllers/link_targets_controller.rb:57",
66
- "app/controllers/primary_sites_controller.rb:138"],
67
- ["2) Similar code found in :if (mass = 64)",
68
- "app/controllers/primary_sites_controller.rb:75",
69
- "app/controllers/primary_sites_controller.rb:76",
70
- "app/controllers/primary_sites_controller.rb:88",
71
- "app/controllers/primary_sites_controller.rb:89"],
72
- ["3) Similar code found in :defn (mass = 40)",
73
- "app/controllers/link_targets_controller.rb:40",
74
- "app/controllers/primary_sites_controller.rb:98"],
75
- ["4) Similar code found in :defn (mass = 38)",
76
- "app/controllers/link_targets_controller.rb:13",
77
- "app/controllers/primary_sites_controller.rb:50"],
78
- ["5) Similar code found in :defn (mass = 38)",
79
- "app/models/primary_site.rb:104",
80
- "app/models/primary_site.rb:109"],
81
- ["6) Similar code found in :call (mass = 36)",
82
- "app/controllers/bookmarklet_integration_controller.rb:6",
83
- "app/controllers/bookmarklet_integration_controller.rb:17"]]
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('base_dir')
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('284')
92
+ expect(@results[:flay][:total_score]).to eq("284")
94
93
  end
95
94
 
96
95
  it "should have 6 matches" do