metric_fu 4.11.4 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 834d485742a2a76cd17281abed4170463309ce5a
4
- data.tar.gz: e8eac12b0defc2efaf922b9a1d9a0d305f8f93e5
3
+ metadata.gz: 17c8fa2540d144f89979c7f5586a71c3889a29f5
4
+ data.tar.gz: 23514588a8ce5ab8ebea208c91874c220db2a1fc
5
5
  SHA512:
6
- metadata.gz: 93253f831c2868e1381702b62eeb22688478fbd800adc9a8193ffecc9a9514e7108c0eb8b9ef4d934b14c061aae9b4a5142780e30887f8cdcf41cbc139251aa9
7
- data.tar.gz: 0fb59ee589b173d597ba2a6254ce8553d365fe65e6c2c3360150b7a1121bfa32d453f674ed02462671809def47224baac67999f079f37f09943849f97866115f
6
+ metadata.gz: 81f84088449c69e96c1e3830e3d938e0cef39d6e81b68c69699924f71d6e012d3b4ef055d19df66ba067a59c202f2fd5f33bfafefae1b4817f678596f79ac232
7
+ data.tar.gz: 3da37a9252de3c65890b68c5593b9cab45fdaf86a1b36f995c2a3f609787c22382810ab7d5eb3210c1275823eceeef937e2b6111baa52afb0925b823d059f485
data/HISTORY.md CHANGED
@@ -4,13 +4,22 @@ Each change should fall into categories that would affect whether the release is
4
4
 
5
5
  As such, a _Feature_ would map to either major (breaking change) or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
6
6
 
7
- ### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.11.4...master)
7
+ ### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.12.0...master)
8
8
 
9
9
  * Breaking Changes
10
10
  * Features
11
11
  * Fixes
12
12
  * Misc
13
13
 
14
+ ### [4.12.0](https://github.com/metricfu/metric_fu/compare/v4.11.4...v4.12.0)
15
+
16
+ * Features
17
+ * Add line numbers to reek output. (ggallen, #255)
18
+ * Use reek directly. (Martin Gotink, #258)
19
+ * Add support for reek 2. (Martin Gotink, #258)
20
+ * Fixes
21
+ * Use same styling for covered as ignored lines. (Martin Gotink, #254)
22
+
14
23
  ### [4.11.4](https://github.com/metricfu/metric_fu/compare/v4.11.3...v4.11.4)
15
24
 
16
25
  * Fixes
@@ -0,0 +1 @@
1
+ 9a74861bf6d89f703786e562cdff96eea727aac874e0d9615d4ac8af57b2c97d15e2121de8d978b7097b56bd72b40744c9a27be9d3d12f9ecf75b66ac565e3ef
@@ -40,9 +40,9 @@ module MetricFu
40
40
  end
41
41
 
42
42
  def css_class
43
- return "" if ignored?
43
+ return "rcov_not_run" if missed?
44
44
 
45
- missed? ? "rcov_not_run" : "rcov_run"
45
+ "rcov_run"
46
46
  end
47
47
  end
48
48
  end
@@ -1,7 +1,5 @@
1
1
  module MetricFu
2
2
  class ReekGenerator < Generator
3
- REEK_REGEX = /^(\S+) (.*) \((.*)\)$/
4
-
5
3
  def self.metric
6
4
  :reek
7
5
  end
@@ -10,36 +8,20 @@ module MetricFu
10
8
  files = files_to_analyze
11
9
  if files.empty?
12
10
  mf_log "Skipping Reek, no files found to analyze"
13
- @output = ""
11
+ @output = run!([], config_files)
14
12
  else
15
- args = cli_options(files)
16
- @output = run!(args)
17
- @output = massage_for_reek_12 if reek_12?
13
+ @output = run!(files, config_files)
18
14
  end
19
15
  end
20
16
 
21
- def run!(args)
22
- require "reek/cli/application"
23
-
24
- MetricFu::Utility.capture_output do
25
- Reek::Cli::Application.new(args).execute
26
- end
17
+ def run!(files, config_files)
18
+ examiner.new(files, config_files)
27
19
  end
28
20
 
29
21
  def analyze
30
- @matches = @output.chomp.split("\n\n").map { |m| m.split("\n") }
31
- @matches = @matches.map do |match|
32
- break {} if zero_warnings?(match)
33
- file_path = match.shift.split(" -- ").first
34
- file_path = file_path.gsub('"', " ").strip
35
- code_smells = match.map do |smell|
36
- match_object = smell.match(REEK_REGEX)
37
- next unless match_object
38
- { method: match_object[1].strip,
39
- message: match_object[2].strip,
40
- type: match_object[3].strip }
41
- end.compact
42
- { file_path: file_path, code_smells: code_smells }
22
+ @matches = @output.smells.group_by(&:source).collect do |file_path, smells|
23
+ { file_path: file_path,
24
+ code_smells: analyze_smells(smells) }
43
25
  end
44
26
  end
45
27
 
@@ -67,31 +49,6 @@ module MetricFu
67
49
  end
68
50
  end
69
51
 
70
- def reek_12?
71
- return false if @output.length == 0
72
- (@output =~ /^"/) != 0
73
- end
74
-
75
- def massage_for_reek_12
76
- section_break = ""
77
- @output.split("\n").map do |line|
78
- case line
79
- when /^ /
80
- "#{line.gsub(/^ /, '')}\n"
81
- else
82
- parts = line.split(" -- ")
83
- if parts[1].nil?
84
- "#{line}\n"
85
- else
86
- warnings = parts[1].gsub(/ \(.*\):/, ":")
87
- result = "#{section_break}\"#{parts[0]}\" -- #{warnings}\n"
88
- section_break = "\n"
89
- result
90
- end
91
- end
92
- end.join
93
- end
94
-
95
52
  private
96
53
 
97
54
  def files_to_analyze
@@ -100,47 +57,36 @@ module MetricFu
100
57
  remove_excluded_files(files_to_reek)
101
58
  end
102
59
 
103
- def cli_options(files)
104
- [
105
- disable_line_number_option,
106
- turn_off_color,
107
- *config_option,
108
- *files
109
- ].reject(&:empty?)
110
- end
111
-
112
60
  # TODO: Check that specified line config file exists
113
- def config_option
114
- config_file_pattern = options[:config_file_pattern]
115
- if config_file_pattern.to_s.empty?
116
- [""]
117
- else
118
- ["--config", config_file_pattern]
119
- end
61
+ def config_files
62
+ Array(options[:config_file_pattern])
120
63
  end
121
64
 
122
- # Work around "Error: invalid option: --no-color" in reek < 1.3.7
123
- def turn_off_color
124
- if reek_version >= "1.3.7"
125
- "--no-color"
126
- else
127
- ""
128
- end
65
+ def analyze_smells(smells)
66
+ smells.collect(&method(:smell_data))
129
67
  end
130
68
 
131
- def reek_version
132
- @reek_version ||= `reek --version`.chomp.sub(/\s*reek\s*/, "")
133
- # use the above, as the below may activate a version not available in
134
- # a Bundler context
135
- # MetricFu::GemVersion.activated_version('reek').to_s
69
+ def smell_data(smell)
70
+ { method: smell.context,
71
+ message: smell.message,
72
+ type: smell_type(smell),
73
+ lines: smell.lines }
136
74
  end
137
75
 
138
- def disable_line_number_option
139
- "--no-line-numbers"
76
+ def smell_type(smell)
77
+ return smell.subclass if smell.respond_to?(:subclass)
78
+
79
+ smell.smell_type
140
80
  end
141
81
 
142
- def zero_warnings?(match)
143
- match.last == "0 total warnings"
82
+ def examiner
83
+ require "reek"
84
+ # To load any changing dependencies such as "reek/configuration/app_configuration"
85
+ # Added in 1.6.0 https://github.com/troessner/reek/commit/7f4ed2be442ca926e08ccc41945e909e8f710947
86
+ # But not always loaded
87
+ require "reek/cli/application"
88
+
89
+ Reek.const_defined?(:Examiner) ? Reek.const_get(:Examiner) : Reek.const_get(:Core).const_get(:Examiner)
144
90
  end
145
91
  end
146
92
  end
@@ -1,3 +1,9 @@
1
1
  module MetricFu
2
- VERSION = "4.11.4"
2
+ class Version
3
+ MAJOR = "4"
4
+ MINOR = "12"
5
+ PATCH = "0"
6
+ PRE = ""
7
+ end
8
+ VERSION = [Version::MAJOR, Version::MINOR, Version::PATCH].join(".")
3
9
  end
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
45
45
  s.add_runtime_dependency "flay", [">= 2.0.1", "~> 2.1"]
46
46
  s.add_runtime_dependency "churn", ["~> 0.0.35"]
47
47
  s.add_runtime_dependency "flog", [">= 4.1.1", "~> 4.1"]
48
- s.add_runtime_dependency "reek", [">= 1.3.4", "~> 1.3"]
48
+ s.add_runtime_dependency "reek", [">= 1.3.4", "< 3.0"]
49
49
  s.add_runtime_dependency "cane", [">= 2.5.2", "~> 2.5"]
50
50
  s.add_runtime_dependency "rails_best_practices", [">= 1.14.3", "~> 1.14"]
51
51
  s.add_runtime_dependency "metric_fu-Saikuro", [">= 1.1.3", "~> 1.1"]
@@ -7,10 +7,10 @@ require "tempfile"
7
7
  require "fileutils"
8
8
 
9
9
  stderr_file = Tempfile.new("app.stderr")
10
- app_dir = File.expand_path("../..", __FILE__)
11
- output_dir = File.join(app_dir, "tmp")
10
+ app_root ||= Dir.pwd
11
+ output_dir = File.join(app_root, "tmp")
12
12
  FileUtils.mkdir_p(output_dir)
13
- bundle_dir = File.join(app_dir, "bundle")
13
+ bundle_dir = File.join(app_root, "bundle")
14
14
 
15
15
  RSpec.configure do |config|
16
16
  config.before(:suite) do
@@ -25,9 +25,9 @@ RSpec.configure do |config|
25
25
 
26
26
  $stderr.reopen(STDERR)
27
27
 
28
- app_warnings, other_warnings = lines.partition do |line|
29
- line.include?(app_dir) && !line.include?(bundle_dir)
30
- end
28
+ app_warnings, other_warnings = lines.partition { |line|
29
+ line.include?(app_root) && !line.include?(bundle_dir)
30
+ }
31
31
 
32
32
  if app_warnings.any?
33
33
  puts <<-WARNINGS
@@ -40,13 +40,16 @@ RSpec.configure do |config|
40
40
  end
41
41
 
42
42
  if other_warnings.any?
43
- File.write(File.join(output_dir, "warnings.txt"), other_warnings.join("\n") << "\n")
43
+ output_file = File.join(output_dir, "warnings.txt")
44
+ File.write(output_file, other_warnings.join("\n") << "\n")
44
45
  puts
45
46
  puts "Non-app warnings written to tmp/warnings.txt"
46
47
  puts
47
48
  end
48
49
 
49
50
  # fail the build...
50
- abort "Failing build due to app warnings: #{app_warnings.inspect}" if app_warnings.any?
51
+ if app_warnings.any?
52
+ abort "Failing build due to app warnings: #{app_warnings.inspect}"
53
+ end
51
54
  end
52
55
  end
@@ -71,9 +71,9 @@ describe MetricFu::RCovLine do
71
71
  end
72
72
 
73
73
  describe "#css_class" do
74
- it "returns '' for an ignored line" do
74
+ it "returns 'rcov_run' for an ignored line" do
75
75
  rcov_line = RCovLine.new("", nil)
76
- expect(rcov_line.css_class).to eq("")
76
+ expect(rcov_line.css_class).to eq("rcov_run")
77
77
  end
78
78
 
79
79
  it "returns 'rcov_not_run' for a missed line" do
@@ -13,80 +13,102 @@ describe MetricFu::ReekGenerator do
13
13
 
14
14
  it "includes config file pattern into reek parameters when specified" do
15
15
  options.merge!(config_file_pattern: "lib/config/*.reek")
16
- expect(reek).to receive(:run!) do |args|
17
- expect(args).to include("--config", "lib/config/*.reek")
18
- end.and_return("")
19
- reek.emit
20
- end
21
16
 
22
- it "doesn't add an empty parameter when no config file pattern is specified" do
23
- expect(reek).to receive(:run!) do |args|
24
- expect(args).not_to include("")
17
+ expect(reek).to receive(:run!) do |_files, config_files|
18
+ expect(config_files).to eq(["lib/config/*.reek"])
25
19
  end.and_return("")
26
- reek.emit
27
- end
28
20
 
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")
31
- expect(reek).to receive(:run!) do |args|
32
- expect(args).to include("--no-color")
33
- end.and_return("")
34
21
  reek.emit
35
22
  end
36
23
 
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")
39
- expect(reek).to receive(:run!) do |args|
40
- expect(args).not_to include("--no-color")
24
+ it "passes an empty array when no config file pattern is specified" do
25
+ expect(reek).to receive(:run!) do |_files, config_files|
26
+ expect(config_files).to eq([])
41
27
  end.and_return("")
42
- reek.emit
43
- end
44
28
 
45
- it "disables lines numbers from reek output" do
46
- expect(reek).to receive(:run!) do |args|
47
- expect(args).to include("--no-line-numbers")
48
- end.and_return("")
49
29
  reek.emit
50
30
  end
51
31
 
52
32
  it "includes files to analyze into reek parameters" do
53
- expect(reek).to receive(:run!) do |args|
54
- expect(args).to include("lib/foo.rb", "lib/bar.rb")
33
+ expect(reek).to receive(:run!) do |files, _config_files|
34
+ expect(files).to eq(["lib/foo.rb", "lib/bar.rb"])
55
35
  end.and_return("")
36
+
56
37
  reek.emit
57
38
  end
58
39
  end
59
40
 
60
- # TODO review tested output
61
41
  describe "analyze method" do
62
42
  before :each do
63
43
  MetricFu::Configuration.run {}
64
44
  allow(File).to receive(:directory?).and_return(true)
65
45
  @reek = MetricFu::ReekGenerator.new
46
+ @examiner = @reek.send(:examiner)
47
+ @smell_warning = Reek.const_defined?(:SmellWarning) ? Reek.const_get(:SmellWarning) : Reek.const_get(:Smells).const_get(:SmellWarning)
48
+ if @smell_warning.instance_methods.include?(:subclass)
49
+ @smell_warning.send(:alias_method, :smell_type, :subclass)
50
+ end
66
51
  end
67
52
 
68
53
  context "with reek warnings" do
69
54
  before :each do
70
- @lines = <<-HERE
71
- "app/controllers/activity_reports_controller.rb" -- 4 warnings:
72
- ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
73
- ActivityReportsController#authorize_user calls params[id] multiple times (Duplication)
74
- ActivityReportsController#authorize_user calls params[primary_site_id] multiple times (Duplication)
75
- ActivityReportsController#authorize_user has approx 6 statements (Long Method)
76
-
77
- "app/controllers/application.rb" -- 1 warnings:
78
- ApplicationController#start_background_task/block/block is nested (Nested Iterators)
79
-
80
- "app/controllers/link_targets_controller.rb" -- 1 warnings:
81
- LinkTargetsController#authorize_user calls current_user.role multiple times (Duplication)
82
-
83
- "app/controllers/newline_controller.rb" -- 1 warnings:
84
- NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
85
- HERE
55
+ @smells = [
56
+ instance_double(@smell_warning,
57
+ source: "app/controllers/activity_reports_controller.rb",
58
+ context: "ActivityReportsController#authorize_user",
59
+ message: "calls current_user.primary_site_ids multiple times",
60
+ smell_type: "Duplication",
61
+ lines: [2, 4]),
62
+ instance_double(@smell_warning,
63
+ source: "app/controllers/activity_reports_controller.rb",
64
+ context: "ActivityReportsController#authorize_user",
65
+ message: "calls params[id] multiple times",
66
+ smell_type: "Duplication",
67
+ lines: [5, 7]),
68
+ instance_double(@smell_warning,
69
+ source: "app/controllers/activity_reports_controller.rb",
70
+ context: "ActivityReportsController#authorize_user",
71
+ message: "calls params[primary_site_id] multiple times",
72
+ smell_type: "Duplication",
73
+ lines: [11, 15]),
74
+ instance_double(@smell_warning,
75
+ source: "app/controllers/activity_reports_controller.rb",
76
+ context: "ActivityReportsController#authorize_user",
77
+ message: "has approx 6 statements",
78
+ smell_type: "Long Method",
79
+ lines: [8]),
80
+
81
+ instance_double(@smell_warning,
82
+ source: "app/controllers/application.rb",
83
+ context: "ApplicationController#start_background_task/block/block",
84
+ message: "is nested",
85
+ smell_type: "Nested Iterators",
86
+ lines: [23]),
87
+
88
+ instance_double(@smell_warning,
89
+ source: "app/controllers/link_targets_controller.rb",
90
+ context: "LinkTargetsController#authorize_user",
91
+ message: "calls current_user.role multiple times",
92
+ smell_type: "Duplication",
93
+ lines: [8]),
94
+
95
+ instance_double(@smell_warning,
96
+ source: "app/controllers/newline_controller.rb",
97
+ context: "NewlineController#some_method",
98
+ message: "calls current_user.<< \"new line\n\" multiple times",
99
+ smell_type: "Duplication",
100
+ lines: [6, 9])
101
+ ]
102
+ @lines = instance_double(@examiner, smells: @smells)
86
103
  @reek.instance_variable_set(:@output, @lines)
87
104
  @matches = @reek.analyze
88
105
  end
89
106
 
107
+ it "should find the code smell's line numbers" do
108
+ smell = @matches.first[:code_smells].first
109
+ expect(smell[:lines]).to eq([2, 4])
110
+ end
111
+
90
112
  it "should find the code smell's method name" do
91
113
  smell = @matches.first[:code_smells].first
92
114
  expect(smell[:method]).to eq("ActivityReportsController#authorize_user")
@@ -109,91 +131,39 @@ NewlineController#some_method calls current_user.<< "new line\n" multiple times
109
131
 
110
132
  it "should NOT insert nil smells into the array when there's a newline in the method call" do
111
133
  expect(@matches.last[:code_smells]).to eq(@matches.last[:code_smells].compact)
112
- expect(@matches.last).to eq(file_path: "app/controllers/newline_controller.rb",
113
- code_smells: [{ type: "Duplication",
114
- method: "\"",
115
- message: "multiple times" }])
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
117
134
  end
118
135
  end
119
136
 
120
- context "without reek warnings" do
137
+ context "with reek 1.3 output" do
121
138
  before :each do
122
- @lines = <<-HERE
123
-
124
- 0 total warnings
125
- HERE
139
+ @smells = [
140
+ double(source: "app/controllers/activity_reports_controller.rb",
141
+ context: "ActivityReportsController#authorize_user",
142
+ message: "calls current_user.primary_site_ids multiple times",
143
+ subclass: "Duplication",
144
+ lines: [2, 4]),
145
+ ]
146
+ @lines = instance_double(@examiner, smells: @smells)
126
147
  @reek.instance_variable_set(:@output, @lines)
127
148
  @matches = @reek.analyze
128
149
  end
129
150
 
130
- it "returns empty analysis" do
131
- expect(@matches).to eq({})
151
+ it "uses the subclass field to find the smell type" do
152
+ smell = @matches.first[:code_smells].first
153
+ expect(smell[:type]).to eq('Duplication')
132
154
  end
133
155
  end
134
- end
135
- end
136
-
137
- describe MetricFu::ReekGenerator do
138
- before :each do
139
- MetricFu::Configuration.run {}
140
- @reek = MetricFu::ReekGenerator.new
141
- @lines11 = <<-HERE
142
- "app/controllers/activity_reports_controller.rb" -- 4 warnings:
143
- ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
144
- ActivityReportsController#authorize_user calls params[id] multiple times (Duplication)
145
- ActivityReportsController#authorize_user calls params[primary_site_id] multiple times (Duplication)
146
- ActivityReportsController#authorize_user has approx 6 statements (Long Method)
147
-
148
- "app/controllers/application.rb" -- 1 warnings:
149
- ApplicationController#start_background_task/block/block is nested (Nested Iterators)
150
-
151
- "app/controllers/link_targets_controller.rb" -- 1 warnings:
152
- LinkTargetsController#authorize_user calls current_user.role multiple times (Duplication)
153
-
154
- "app/controllers/newline_controller.rb" -- 1 warnings:
155
- NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
156
- HERE
157
- @lines12 = <<-HERE
158
- app/controllers/activity_reports_controller.rb -- 4 warnings (+3 masked):
159
- ActivityReportsController#authorize_user calls current_user.primary_site_ids multiple times (Duplication)
160
- ActivityReportsController#authorize_user calls params[id] multiple times (Duplication)
161
- ActivityReportsController#authorize_user calls params[primary_site_id] multiple times (Duplication)
162
- ActivityReportsController#authorize_user has approx 6 statements (Long Method)
163
- app/controllers/application.rb -- 1 warnings:
164
- ApplicationController#start_background_task/block/block is nested (Nested Iterators)
165
- app/controllers/link_targets_controller.rb -- 1 warnings (+1 masked):
166
- LinkTargetsController#authorize_user calls current_user.role multiple times (Duplication)
167
- app/controllers/newline_controller.rb -- 1 warnings:
168
- NewlineController#some_method calls current_user.<< "new line\n" multiple times (Duplication)
169
- HERE
170
- end
171
-
172
- context "with Reek 1.1 output format" do
173
- it "reports 1.1 style when the output is empty" do
174
- @reek.instance_variable_set(:@output, "")
175
- expect(@reek).not_to be_reek_12
176
- end
177
- it "detects 1.1 format output" do
178
- @reek.instance_variable_set(:@output, @lines11)
179
- expect(@reek).not_to be_reek_12
180
- end
181
-
182
- it "massages empty output to be unchanged" do
183
- @reek.instance_variable_set(:@output, "")
184
- expect(@reek.massage_for_reek_12).to be_empty
185
- end
186
- end
187
156
 
188
- context "with Reek 1.2 output format" do
189
- it "detects 1.2 format output" do
190
- @reek.instance_variable_set(:@output, @lines12)
191
- expect(@reek).to be_reek_12
192
- end
157
+ context "without reek warnings" do
158
+ before :each do
159
+ @lines = instance_double(@examiner, smells: [])
160
+ @reek.instance_variable_set(:@output, @lines)
161
+ @matches = @reek.analyze
162
+ end
193
163
 
194
- it "correctly massages 1.2 output" do
195
- @reek.instance_variable_set(:@output, @lines12)
196
- expect(@reek.massage_for_reek_12).to eq(@lines11)
164
+ it "returns empty analysis" do
165
+ expect(@matches).to eq([])
166
+ end
197
167
  end
198
168
  end
199
169
  end
@@ -8,18 +8,39 @@ if defined?(Encoding) && Encoding.default_external != "UTF-8"
8
8
  end
9
9
 
10
10
  RSpec.describe "The library itself" do
11
+ # For some reason RSpec may expect this to be defined
12
+ # and crash really bad without it
13
+ def self.uses_transaction?(*)
14
+ false
15
+ end
16
+
17
+ def encode_utf8!(string)
18
+ string.encode!(Encoding::UTF_8,
19
+ invalid: :replace,
20
+ undef: :replace,
21
+ replace: "<?>".freeze
22
+ )
23
+ end
24
+
25
+ def ignore_whitespace?(filename)
26
+ @whitespace_regex ||=
27
+ /\.gitmodules|fixtures|vendor|LICENSE|etc|db|public|reports/
28
+ !!(filename =~ @whitespace_regex)
29
+ end
30
+
11
31
  def check_for_spec_defs_with_single_quotes(filename)
12
32
  failing_lines = []
13
33
 
14
34
  File.readlines(filename).each_with_index do |line, number|
15
- line.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "<?>")
35
+ encode_utf8!(line)
16
36
  failing_lines << number + 1 if line =~ /^ *(describe|it|context) {1}'{1}/
17
37
  end
18
38
 
19
- unless failing_lines.empty?
39
+ if failing_lines.any?
20
40
  # Prevent rubocop from looping infinitely
21
41
  # rubocop:disable Style/StringLiterals
22
- "#{filename} uses inconsistent single quotes on lines #{failing_lines.join(', ')}"
42
+ "#{filename} uses inconsistent single quotes "\
43
+ "on lines #{failing_lines.join(', ')}"
23
44
  # rubocop:enable Style/StringLiterals
24
45
  end
25
46
  end
@@ -27,7 +48,7 @@ RSpec.describe "The library itself" do
27
48
  def check_for_tab_characters(filename)
28
49
  failing_lines = []
29
50
  File.readlines(filename).each_with_index do |line, number|
30
- line.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "<?>")
51
+ encode_utf8!(line)
31
52
  failing_lines << number + 1 if line =~ /\t/
32
53
  end
33
54
 
@@ -42,7 +63,7 @@ RSpec.describe "The library itself" do
42
63
  def check_for_extra_spaces(filename)
43
64
  failing_lines = []
44
65
  File.readlines(filename).each_with_index do |line, number|
45
- line.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "<?>")
66
+ encode_utf8!(line)
46
67
  next if line =~ /^\s+#.*\s+\n$/
47
68
  failing_lines << number + 1 if line =~ /\s+\n$/
48
69
  end
@@ -63,15 +84,12 @@ RSpec.describe "The library itself" do
63
84
  match(&:empty?)
64
85
  end
65
86
 
66
- WHITESPACE_OK =
67
- /\.gitmodules|\.marshal|fixtures|ssl_certs|vendor|LICENSE|etc|reports/
68
-
69
87
  it "has no malformed whitespace" do
70
88
  error_messages = []
71
89
  Dir.chdir(File.expand_path("../..", __FILE__)) do
72
90
  `git ls-files -z`.split("\x0").each do |filename|
73
91
  next if !File.exist?(filename)
74
- next if filename =~ WHITESPACE_OK
92
+ next if ignore_whitespace?(filename)
75
93
  error_messages << check_for_tab_characters(filename)
76
94
  error_messages << check_for_extra_spaces(filename)
77
95
  end
@@ -83,7 +101,7 @@ RSpec.describe "The library itself" do
83
101
  included = /spec/
84
102
  error_messages = []
85
103
  Dir.chdir(File.expand_path("../", __FILE__)) do
86
- `git ls-files -z`.split("\x0").each do |filename|
104
+ `git ls-files -z spec`.split("\x0").each do |filename|
87
105
  next unless filename =~ included
88
106
  error_messages << check_for_spec_defs_with_single_quotes(filename)
89
107
  end
@@ -18,7 +18,9 @@ Dir[MetricFu.root_dir + "/spec/support/**/*.rb"].each { |f| require f }
18
18
  RSpec.configure do |config|
19
19
  config.filter_run focus: true
20
20
  config.run_all_when_everything_filtered = true
21
+ # Skip specs tagged `:slow` unless SLOW_SPECS is set
21
22
  config.filter_run_excluding :slow unless ENV["SLOW_SPECS"]
23
+ # End specs on first failure if FAIL_FAST is set
22
24
  config.fail_fast = ENV.include?("FAIL_FAST")
23
25
  config.order = :rand
24
26
  config.color = true
@@ -27,6 +29,7 @@ RSpec.configure do |config|
27
29
  end
28
30
  config.mock_with :rspec do |mocks|
29
31
  mocks.syntax = :expect
32
+ mocks.verify_partial_doubles = true
30
33
  end
31
34
 
32
35
  # :suite after/before all specs
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.4
4
+ version: 4.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Scruggs
@@ -19,30 +19,8 @@ authors:
19
19
  autorequire:
20
20
  bindir: bin
21
21
  cert_chain:
22
- - |
23
- -----BEGIN CERTIFICATE-----
24
- MIIDmjCCAoKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBJMQ8wDQYDVQQDDAZnaXRo
25
- dWIxITAfBgoJkiaJk/IsZAEZFhFiZW5qYW1pbmZsZWlzY2hlcjETMBEGCgmSJomT
26
- 8ixkARkWA2NvbTAeFw0xNTAxMjIxMzAyNTNaFw0xNjAxMjIxMzAyNTNaMEkxDzAN
27
- BgNVBAMMBmdpdGh1YjEhMB8GCgmSJomT8ixkARkWEWJlbmphbWluZmxlaXNjaGVy
28
- MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
29
- CgKCAQEA7V1VZBU7Aft01XAoK8I8tdClfv3H/NIauiV0jfyNtXtZEWwaZ6ooZNLk
30
- 8kmIUsO2xI7I/B3es6w7le9q9xdEowlYjiR/X/yazNvufu5kpM4f6Ri1AKN8xvPk
31
- LFlR8aOAd9LptcusYDfE+BjhmAvnLTgMGODcDLJIaJzLJaRywTLUuFv4digpFwCm
32
- Zps9VheJnL4hkgI5BDn6DVjxHSCMRnccQM/kX9L34lbP9KkHXXEtQgkQYpElHbnd
33
- MtR753aPeLfOBxSGzsso+6Lhe+fz8huD05mzgWaEZN40e6M7dA9FRSsEzL32ZOad
34
- 0z13MZWj3Yg5srV/cZvzCDCdVvRphwIDAQABo4GMMIGJMAkGA1UdEwQCMAAwCwYD
35
- VR0PBAQDAgSwMB0GA1UdDgQWBBQvUrPExdvmdz0Vau0dH3hRh1YQfDAnBgNVHREE
36
- IDAegRxnaXRodWJAYmVuamFtaW5mbGVpc2NoZXIuY29tMCcGA1UdEgQgMB6BHGdp
37
- dGh1YkBiZW5qYW1pbmZsZWlzY2hlci5jb20wDQYJKoZIhvcNAQEFBQADggEBAEWo
38
- g1soMaRTT/OfFklTuP+odV0w+2qJSfJhOY5bIebDjqxb9BN7hZJ9L6WXhcXCvl6r
39
- kuXjpcC05TIv1DoWWaSjGK2ADmEBDNVhaFepYidAYuUQN4+ZjVH/gS9V9OkBcE8h
40
- 3ZwRv+9RkXM0uY1FwuGI6jgbgPeR1AkkfJnhOPohkG+VN5bFo9aK/Stw8Nwhuuiz
41
- axCPD3cmaJBguufRXSMC852SDiBT7AtI4Gl2Fyr+0M5TzXHKbQ9xRBxwfE1bWDd6
42
- lEs7ndJ1/vd/Hy0zQ1tIRWyql+ITLhqMi161Pw5flsYpQvPlRLR5pGJ4eD0/JdKE
43
- ZG9WSFH7QcGLY65mEYc=
44
- -----END CERTIFICATE-----
45
- date: 2015-02-27 00:00:00.000000000 Z
22
+ - certs/bf4.pem
23
+ date: 2015-06-18 00:00:00.000000000 Z
46
24
  dependencies:
47
25
  - !ruby/object:Gem::Dependency
48
26
  name: flay
@@ -105,9 +83,9 @@ dependencies:
105
83
  - - ">="
106
84
  - !ruby/object:Gem::Version
107
85
  version: 1.3.4
108
- - - "~>"
86
+ - - "<"
109
87
  - !ruby/object:Gem::Version
110
- version: '1.3'
88
+ version: '3.0'
111
89
  type: :runtime
112
90
  prerelease: false
113
91
  version_requirements: !ruby/object:Gem::Requirement
@@ -115,9 +93,9 @@ dependencies:
115
93
  - - ">="
116
94
  - !ruby/object:Gem::Version
117
95
  version: 1.3.4
118
- - - "~>"
96
+ - - "<"
119
97
  - !ruby/object:Gem::Version
120
- version: '1.3'
98
+ version: '3.0'
121
99
  - !ruby/object:Gem::Dependency
122
100
  name: cane
123
101
  requirement: !ruby/object:Gem::Requirement
@@ -369,6 +347,7 @@ files:
369
347
  - checksum/metric_fu-4.11.1.gem.sha512
370
348
  - checksum/metric_fu-4.11.2.gem.sha512
371
349
  - checksum/metric_fu-4.11.3.gem.sha512
350
+ - checksum/metric_fu-4.11.4.gem.sha512
372
351
  - checksum/metric_fu-4.2.0.gem.sha512
373
352
  - checksum/metric_fu-4.2.1.gem.sha512
374
353
  - checksum/metric_fu-4.3.0.gem.sha512
@@ -648,7 +627,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
648
627
  version: 1.3.6
649
628
  requirements: []
650
629
  rubyforge_project: metric_fu
651
- rubygems_version: 2.4.3
630
+ rubygems_version: 2.4.6
652
631
  signing_key:
653
632
  specification_version: 4
654
633
  summary: A fistful of code metrics, with awesome templates and graphs
@@ -1 +0,0 @@
1
- +˗ �O����8���lz׊�G�t{�b��I�N�yv���ӊ�>y5�ΐ���q�Йd5�z�*뼳�}��I�.��y��bR�"P;N%%=n�O���� ��i3B1���+��t�l��oD������c �M��/���я."?��gK�mH%b<�zw�M��Iɨ���z��遷������ʘdº�#���v �Fh��V!*.��a��hB�wG�7�{��̴����A\ tP�\6u�rM
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- ‡����'@T- d��Ł��*�IZ��Q'�%�ը�-��b��ɵ 8���y��.�z�C/�zޡѢ�eTi��KFD8VC��ؑ�����Kn+�h�>��%��BW���m���AoI�>�V�.��3E�[�In~�rUXK��}�=0ln��<��g;��^C�YƠ�*�̻]B�+�8�*�À�>�e�$U�O��(X�Y�z3�!���
2
- ��%����l{��l
3
- ��5��eJ�&;�@���E��~�yE�Qt