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,53 +1,47 @@
1
1
  require "spec_helper"
2
- MetricFu.formatter_require { 'yaml' }
2
+ MetricFu.formatter_require { "yaml" }
3
3
 
4
4
  describe MetricFu::Formatter::YAML do
5
-
6
5
  before do
7
6
  setup_fs
8
7
 
9
8
  config = MetricFu.configuration
10
9
 
11
10
  if config.mri?
12
- @metric1 = :cane
11
+ @metric1 = :cane
13
12
  else
14
- @metric1 = :stats
15
- config.templates_configuration do |c|
16
- c.syntax_highlighting = false
17
- end
13
+ @metric1 = :stats
14
+ config.templates_configuration do |c|
15
+ c.syntax_highlighting = false
16
+ end
18
17
  end
19
- allow(MetricFu::Metric.get_metric(@metric1)).to receive(:run_external).and_return('')
18
+ allow(MetricFu::Metric.get_metric(@metric1)).to receive(:run_external).and_return("")
20
19
  @metric2 = :hotspots
21
20
  MetricFu.result.add(@metric1)
22
21
  MetricFu.result.add(@metric2)
23
22
  end
24
23
 
25
24
  context "In general" do
26
-
27
25
  it "creates a report yaml file" do
28
26
  expect {
29
- MetricFu::Formatter::YAML.new.finish
27
+ MetricFu::Formatter::YAML.new.finish
30
28
  }.to create_file("#{directory('base_directory')}/report.yml")
31
29
  end
32
-
33
30
  end
34
31
 
35
32
  context "given a custom output file" do
36
-
37
33
  before do
38
34
  @output = "customreport.yml"
39
35
  end
40
36
 
41
37
  it "creates a report yaml file to the custom output path" do
42
38
  expect {
43
- MetricFu::Formatter::YAML.new(output: @output).finish
39
+ MetricFu::Formatter::YAML.new(output: @output).finish
44
40
  }.to create_file("#{directory('base_directory')}/customreport.yml")
45
41
  end
46
-
47
42
  end
48
43
 
49
44
  context "given a custom output stream" do
50
-
51
45
  before do
52
46
  @output = $stdout
53
47
  end
@@ -59,11 +53,9 @@ describe MetricFu::Formatter::YAML do
59
53
  expect(out).to include ":#{@metric1}:"
60
54
  expect(out).to include ":#{@metric2}:"
61
55
  end
62
-
63
56
  end
64
57
 
65
58
  after do
66
59
  cleanup_fs
67
60
  end
68
-
69
61
  end
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  describe MetricFu::Formatter do
4
4
  describe "formatter class loading" do
5
5
  context "given a built-in formatter (string)" do
6
- subject { MetricFu::Formatter.class_for('html') }
6
+ subject { MetricFu::Formatter.class_for("html") }
7
7
 
8
8
  it "returns the formatter class" do
9
9
  expect(subject).to eq(MetricFu::Formatter::HTML)
@@ -22,15 +22,15 @@ describe MetricFu::Formatter do
22
22
  subject { MetricFu::Formatter.class_for(:unknown) }
23
23
 
24
24
  it "raises an error" do
25
- expect{ subject }.to raise_error(NameError)
25
+ expect { subject }.to raise_error(NameError)
26
26
  end
27
27
  end
28
28
 
29
29
  context "given a custom formatter that exists" do
30
- subject { MetricFu::Formatter.class_for('MyCustomFormatter') }
30
+ subject { MetricFu::Formatter.class_for("MyCustomFormatter") }
31
31
 
32
32
  before do
33
- stub_const('MyCustomFormatter', Class.new() { def initialize(*);end })
33
+ stub_const("MyCustomFormatter", Class.new { def initialize(*); end })
34
34
  end
35
35
 
36
36
  it "returns the formatter class" do
@@ -39,10 +39,10 @@ describe MetricFu::Formatter do
39
39
  end
40
40
 
41
41
  context "given a custom formatter that doesnt exist" do
42
- subject { MetricFu::Formatter.class_for('MyNonExistentCustomFormatter') }
42
+ subject { MetricFu::Formatter.class_for("MyNonExistentCustomFormatter") }
43
43
 
44
44
  it "raises an error" do
45
- expect{ subject }.to raise_error(NameError)
45
+ expect { subject }.to raise_error(NameError)
46
46
  end
47
47
  end
48
48
  end
@@ -1,14 +1,12 @@
1
- require 'spec_helper'
2
- MetricFu.lib_require { 'gem_version' }
1
+ require "spec_helper"
2
+ MetricFu.lib_require { "gem_version" }
3
3
 
4
4
  describe MetricFu::GemVersion do
5
-
6
5
  it "has a list of gem deps" do
7
6
  gem_version = MetricFu::GemVersion.new
8
7
  gem_deps = gem_version.gem_runtime_dependencies.map(&:name)
9
- MetricFu::Metric.metrics.reject{|metric| metric.name == :hotspots || metric.name == :stats}.map(&:name).map(&:to_s).each do |metric_name|
8
+ MetricFu::Metric.metrics.reject { |metric| metric.name == :hotspots || metric.name == :stats }.map(&:name).map(&:to_s).each do |metric_name|
10
9
  expect(gem_deps).to include(metric_name)
11
10
  end
12
11
  end
13
-
14
12
  end
@@ -1,10 +1,8 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe MetricFu::Generator do
4
-
5
4
  include TestConstruct::Helpers
6
5
 
7
-
8
6
  class ConcreteClass < MetricFu::Generator
9
7
  def self.metric
10
8
  :concrete
@@ -21,7 +19,7 @@ describe MetricFu::Generator do
21
19
  end
22
20
 
23
21
  before(:each) do
24
- ENV['CC_BUILD_ARTIFACTS'] = nil
22
+ ENV["CC_BUILD_ARTIFACTS"] = nil
25
23
  MetricFu.configuration.reset
26
24
  MetricFu.configure
27
25
  @concrete_class = ConcreteClass.new
@@ -29,39 +27,38 @@ describe MetricFu::Generator do
29
27
 
30
28
  describe "ConcreteClass#metric_directory" do
31
29
  it "should be '{artifact_dir}/scratch/concreteclass'" do
32
- concrete_metric = double('concrete_metric')
30
+ concrete_metric = double("concrete_metric")
33
31
  expect(MetricFu::Metric).to receive(:get_metric).with(:concrete).and_return(concrete_metric)
34
32
  expect(concrete_metric).to receive(:run_options).and_return({})
35
- compare_paths(ConcreteClass.metric_directory, scratch_directory('concrete'))
33
+ compare_paths(ConcreteClass.metric_directory, scratch_directory("concrete"))
36
34
  end
37
35
  end
38
36
 
39
37
  describe "#metric_directory" do
40
38
  it "should return the results of ConcreteClass#metric_directory" do
41
- allow(ConcreteClass).to receive(:metric_directory).and_return('foo')
42
- expect(@concrete_class.metric_directory).to eq('foo')
39
+ allow(ConcreteClass).to receive(:metric_directory).and_return("foo")
40
+ expect(@concrete_class.metric_directory).to eq("foo")
43
41
  end
44
42
  end
45
43
 
46
44
  describe "#generate_result" do
47
45
  it "should raise an error when calling #emit" do
48
46
  @abstract_class = MetricFu::Generator.new
49
- expect { @abstract_class.generate_result }.to raise_error
47
+ expect { @abstract_class.generate_result }.to raise_error
50
48
  end
51
49
 
52
50
  it "should call #analyze" do
53
51
  @abstract_class = MetricFu::Generator.new
54
- expect { @abstract_class.generate_result }.to raise_error
52
+ expect { @abstract_class.generate_result }.to raise_error
55
53
  end
56
54
 
57
55
  it "should call #to_h" do
58
56
  @abstract_class = MetricFu::Generator.new
59
- expect { @abstract_class.generate_result }.to raise_error
57
+ expect { @abstract_class.generate_result }.to raise_error
60
58
  end
61
59
  end
62
60
 
63
61
  describe "#generate_result (in a concrete class)" do
64
-
65
62
  %w[emit analyze].each do |meth|
66
63
  it "should call ##{meth}" do
67
64
  expect(@concrete_class).to receive("#{meth}")
@@ -73,23 +70,20 @@ describe MetricFu::Generator do
73
70
  expect(@concrete_class).to receive(:to_h)
74
71
  @concrete_class.generate_result
75
72
  end
76
-
77
73
  end
78
74
 
79
75
  describe "path filter" do
80
-
81
76
  context "given a list of paths" do
82
-
83
77
  before do
84
78
  @paths = %w(lib/fake/fake.rb
85
- lib/this/dan_file.rb
86
- lib/this/ben_file.rb
87
- lib/this/avdi_file.rb
88
- basic.rb
89
- lib/bad/one.rb
90
- lib/bad/two.rb
91
- lib/bad/three.rb
92
- lib/worse/four.rb)
79
+ lib/this/dan_file.rb
80
+ lib/this/ben_file.rb
81
+ lib/this/avdi_file.rb
82
+ basic.rb
83
+ lib/bad/one.rb
84
+ lib/bad/two.rb
85
+ lib/bad/three.rb
86
+ lib/worse/four.rb)
93
87
  @container = create_construct
94
88
  @paths.each do |path|
95
89
  @container.file(path)
@@ -109,32 +103,28 @@ describe MetricFu::Generator do
109
103
  end
110
104
 
111
105
  it "should filter filename at root level" do
112
- files = @concrete_class.remove_excluded_files(@paths, ['basic.rb'])
113
- expect(files).not_to include('basic.rb')
106
+ files = @concrete_class.remove_excluded_files(@paths, ["basic.rb"])
107
+ expect(files).not_to include("basic.rb")
114
108
  end
115
109
 
116
110
  it "should remove files that are two levels deep" do
117
- files = @concrete_class.remove_excluded_files(@paths, ['**/fake.rb'])
118
- expect(files).not_to include('lib/fake/fake.rb')
111
+ files = @concrete_class.remove_excluded_files(@paths, ["**/fake.rb"])
112
+ expect(files).not_to include("lib/fake/fake.rb")
119
113
  end
120
114
 
121
115
  it "should remove files from an excluded directory" do
122
- files = @concrete_class.remove_excluded_files(@paths, ['lib/bad/**'])
123
- expect(files).not_to include('lib/bad/one.rb')
124
- expect(files).not_to include('lib/bad/two.rb')
125
- expect(files).not_to include('lib/bad/three.rb')
116
+ files = @concrete_class.remove_excluded_files(@paths, ["lib/bad/**"])
117
+ expect(files).not_to include("lib/bad/one.rb")
118
+ expect(files).not_to include("lib/bad/two.rb")
119
+ expect(files).not_to include("lib/bad/three.rb")
126
120
  end
127
121
 
128
122
  it "should support shell alternation globs" do
129
- files = @concrete_class.remove_excluded_files(@paths, ['lib/this/{ben,dan}_file.rb'])
130
- expect(files).not_to include('lib/this/dan_file.rb')
131
- expect(files).not_to include('lib/this/ben_file.rb')
132
- expect(files).to include('lib/this/avdi_file.rb')
123
+ files = @concrete_class.remove_excluded_files(@paths, ["lib/this/{ben,dan}_file.rb"])
124
+ expect(files).not_to include("lib/this/dan_file.rb")
125
+ expect(files).not_to include("lib/this/ben_file.rb")
126
+ expect(files).to include("lib/this/avdi_file.rb")
133
127
  end
134
-
135
128
  end
136
-
137
-
138
129
  end
139
-
140
130
  end
@@ -1,12 +1,10 @@
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
7
  MetricFu.loader.load_user_configuration
9
8
  expect($metric_file_loaded).to be_truthy
10
9
  end
11
-
12
10
  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
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
21
 
22
22
  context "given a valid configurable option" do
23
-
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
27
  it "can be configured as an attribute" do
29
- @metric.foo = 'qux'
30
- expect(@metric.run_options[:foo]).to eq('qux')
28
+ @metric.foo = "qux"
29
+ expect(@metric.run_options[:foo]).to eq("qux")
31
30
  end
32
-
33
31
  end
34
32
 
35
33
  context "given an invalid configurable option" do
36
-
37
34
  before do
38
35
  allow(@metric).to receive(:default_run_options).and_return({})
39
36
  end
40
37
 
41
38
  it "raises an error" do
42
- expect { @metric.foo = 'bar' }.to raise_error(RuntimeError, /not a valid configuration option/)
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
@@ -5,16 +5,16 @@ describe MetricFu::Configuration, "for cane" do
5
5
  it_behaves_like "configured" do
6
6
  if MetricFu.configuration.mri?
7
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
8
+ ':dirs_to_cane => @code_dirs, :abc_max => 15, :line_length => 80, :no_doc => "n", :no_readme => "y"' do
9
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