Skip to content

Commit ac54433

Browse files
committed
call actual reek for validation of parsing
1 parent ba15353 commit ac54433

File tree

8 files changed

+48
-12724
lines changed

8 files changed

+48
-12724
lines changed

lib/metric_fu/metrics/reek/reek_examiner.rb

+8-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ def self.get
1919
end
2020

2121
def self.reek_version
22-
Reek.const_defined?(:VERSION) ? Reek::VERSION :
23-
Reek::Version::STRING
22+
Reek::Version::STRING
23+
rescue NameError
24+
Reek::VERSION
2425
end
2526

2627
def self.reek_examinor_klass
27-
Reek.const_defined?(:Examiner) ? Reek.const_get(:Examiner) :
28-
Reek.const_get(:Core).const_get(:Examiner)
28+
Reek::Examiner
29+
rescue NameError
30+
Reek::Core::Examiner
2931
end
3032

3133
class ReekExaminerV1
@@ -38,6 +40,7 @@ def run!(files, config_files)
3840
end
3941

4042
def analyze
43+
return [] if @output.nil?
4144
@output.smells.group_by(&:source).collect do |file_path, smells|
4245
{ file_path: file_path,
4346
code_smells: analyze_smells(smells) }
@@ -72,6 +75,7 @@ def run!(files, config_files)
7275
end
7376

7477
def analyze
78+
return [] if @output.nil?
7579
@output.map(&:smells).flatten.group_by(&:source).collect do |file_path, smells|
7680
{ file_path: file_path,
7781
code_smells: analyze_smells(smells) }

spec/dummy/lib/bad_code.rb

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class BadCode
2+
def nonsense(some_input, options)
3+
x = Array(some_input).map(&:to_s)
4+
BadCode.configure do |config|
5+
config.something.each do |y|
6+
name = y.name.to_s
7+
if x.include?(name)
8+
feature.enabled = true
9+
else
10+
feature.enabled = false
11+
end
12+
end
13+
end
14+
do_it(options)
15+
end
16+
end

spec/fixtures/reek/examiner_1.6.6.yml

-39
This file was deleted.

0 commit comments

Comments
 (0)