reek 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/CONTRIBUTING.md +41 -4
  4. data/README.md +15 -3
  5. data/defaults.reek +1 -1
  6. data/docs/Basic-Smell-Options.md +2 -2
  7. data/docs/Code-Smells.md +4 -0
  8. data/docs/How-To-Write-New-Detectors.md +116 -0
  9. data/docs/How-reek-works-internally.md +3 -4
  10. data/docs/Instance-Variable-Assumption.md +134 -0
  11. data/docs/Simulated-Polymorphism.md +1 -1
  12. data/docs/Smell-Suppression.md +6 -6
  13. data/docs/{style-guide.md → Style-Guide.md} +0 -0
  14. data/docs/Unused-Private-Method.md +1 -1
  15. data/docs/YAML-Reports.md +0 -18
  16. data/features/configuration_files/directory_specific_directives.feature +4 -4
  17. data/features/configuration_files/unused_private_method.feature +2 -2
  18. data/features/samples.feature +122 -117
  19. data/features/smells/subclassed_from_core_class.feature +1 -1
  20. data/lib/reek/code_comment.rb +13 -4
  21. data/lib/reek/context/code_context.rb +1 -0
  22. data/lib/reek/examiner.rb +24 -27
  23. data/lib/reek/smells/class_variable.rb +1 -1
  24. data/lib/reek/smells/control_parameter.rb +1 -1
  25. data/lib/reek/smells/data_clump.rb +1 -1
  26. data/lib/reek/smells/duplicate_method_call.rb +1 -1
  27. data/lib/reek/smells/feature_envy.rb +1 -1
  28. data/lib/reek/smells/instance_variable_assumption.rb +1 -1
  29. data/lib/reek/smells/prima_donna_method.rb +1 -1
  30. data/lib/reek/smells/repeated_conditional.rb +1 -1
  31. data/lib/reek/smells/smell_detector.rb +5 -14
  32. data/lib/reek/smells/smell_repository.rb +1 -5
  33. data/lib/reek/smells/smell_warning.rb +6 -8
  34. data/lib/reek/smells/subclassed_from_core_class.rb +1 -1
  35. data/lib/reek/smells/uncommunicative_variable_name.rb +22 -12
  36. data/lib/reek/smells/unused_private_method.rb +1 -1
  37. data/lib/reek/spec.rb +2 -2
  38. data/lib/reek/spec/should_reek_of.rb +12 -8
  39. data/lib/reek/version.rb +1 -1
  40. data/spec/reek/code_comment_spec.rb +13 -5
  41. data/spec/reek/examiner_spec.rb +2 -2
  42. data/spec/reek/smells/attribute_spec.rb +91 -78
  43. data/spec/reek/smells/boolean_parameter_spec.rb +72 -64
  44. data/spec/reek/smells/class_variable_spec.rb +81 -68
  45. data/spec/reek/smells/control_parameter_spec.rb +101 -141
  46. data/spec/reek/smells/data_clump_spec.rb +94 -149
  47. data/spec/reek/smells/duplicate_method_call_spec.rb +98 -85
  48. data/spec/reek/smells/feature_envy_spec.rb +164 -183
  49. data/spec/reek/smells/instance_variable_assumption_spec.rb +51 -147
  50. data/spec/reek/smells/irresponsible_module_spec.rb +153 -170
  51. data/spec/reek/smells/long_parameter_list_spec.rb +44 -88
  52. data/spec/reek/smells/long_yield_list_spec.rb +41 -41
  53. data/spec/reek/smells/manual_dispatch_spec.rb +36 -18
  54. data/spec/reek/smells/module_initialize_spec.rb +31 -33
  55. data/spec/reek/smells/nested_iterators_spec.rb +189 -183
  56. data/spec/reek/smells/nil_check_spec.rb +48 -37
  57. data/spec/reek/smells/prima_donna_method_spec.rb +41 -26
  58. data/spec/reek/smells/repeated_conditional_spec.rb +75 -87
  59. data/spec/reek/smells/smell_warning_spec.rb +7 -0
  60. data/spec/reek/smells/subclassed_from_core_class_spec.rb +37 -112
  61. data/spec/reek/smells/too_many_constants_spec.rb +109 -199
  62. data/spec/reek/smells/too_many_instance_variables_spec.rb +105 -128
  63. data/spec/reek/smells/too_many_methods_spec.rb +38 -62
  64. data/spec/reek/smells/too_many_statements_spec.rb +69 -45
  65. data/spec/reek/smells/uncommunicative_method_name_spec.rb +16 -29
  66. data/spec/reek/smells/uncommunicative_module_name_spec.rb +24 -37
  67. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +55 -60
  68. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +108 -95
  69. data/spec/reek/smells/unused_parameters_spec.rb +73 -49
  70. data/spec/reek/smells/unused_private_method_spec.rb +97 -50
  71. data/spec/reek/smells/utility_function_spec.rb +130 -188
  72. data/spec/reek/spec/should_reek_of_spec.rb +2 -2
  73. metadata +6 -7
  74. data/lib/reek/cli/warning_collector.rb +0 -27
  75. data/spec/reek/cli/warning_collector_spec.rb +0 -25
  76. data/spec/reek/smells/smell_detector_shared.rb +0 -29
@@ -1,88 +1,99 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/context/code_context'
3
2
  require_lib 'reek/smells/nil_check'
4
- require_relative 'smell_detector_shared'
5
3
 
6
4
  RSpec.describe Reek::Smells::NilCheck do
7
- it 'reports correctly the basic use case' do
5
+ it 'reports the right values' do
8
6
  src = <<-EOS
9
- def foo(bar)
10
- bar.nil?
7
+ def alfa(bravo)
8
+ bravo.nil?
11
9
  end
12
10
  EOS
13
- expect(src).to reek_of :NilCheck,
14
- lines: [2],
15
- message: 'performs a nil-check'
16
- end
17
11
 
18
- it 'reports nothing when scope includes no nil checks' do
19
- expect('def no_nils; end').not_to reek_of(:NilCheck)
12
+ expect(src).to reek_of(:NilCheck,
13
+ lines: [2],
14
+ context: 'alfa',
15
+ message: 'performs a nil-check',
16
+ source: 'string')
20
17
  end
21
18
 
22
- it 'reports when scope uses #nil?' do
19
+ it 'does count all occurences' do
23
20
  src = <<-EOS
24
- def foo(bar)
25
- bar.nil?
26
- end
21
+ def alfa(bravo, charlie)
22
+ bravo.nil?
23
+ charlie.nil?
24
+ end
27
25
  EOS
28
- expect(src).to reek_of(:NilCheck)
26
+
27
+ expect(src).to reek_of(:NilCheck,
28
+ lines: [2, 3],
29
+ context: 'alfa')
30
+ end
31
+
32
+ it 'reports nothing when scope includes no nil checks' do
33
+ expect('def alfa; end').not_to reek_of(:NilCheck)
29
34
  end
30
35
 
31
36
  it 'reports when scope uses == nil' do
32
37
  src = <<-EOS
33
- def foo(bar)
34
- bar == nil
35
- end
38
+ def alfa(bravo)
39
+ bravo == nil
40
+ end
36
41
  EOS
42
+
37
43
  expect(src).to reek_of(:NilCheck)
38
44
  end
39
45
 
40
46
  it 'reports when scope uses === nil' do
41
47
  src = <<-EOS
42
- def foo(bar)
43
- bar === nil
44
- end
48
+ def alfa(bravo)
49
+ bravo === nil
50
+ end
45
51
  EOS
52
+
46
53
  expect(src).to reek_of(:NilCheck)
47
54
  end
48
55
 
49
56
  it 'reports when scope uses nil ==' do
50
57
  src = <<-EOS
51
- def foo(bar)
52
- nil == bar
53
- end
58
+ def alfa(bravo)
59
+ nil == bravo
60
+ end
54
61
  EOS
62
+
55
63
  expect(src).to reek_of(:NilCheck)
56
64
  end
57
65
 
58
66
  it 'reports when scope uses a case-clause checking nil' do
59
67
  src = <<-EOS
60
- def case_nil
61
- case @foo
62
- when nil then puts "Nil"
68
+ def alfa(bravo)
69
+ case bravo
70
+ when nil then puts "Nil"
71
+ end
63
72
  end
64
- end
65
73
  EOS
74
+
66
75
  expect(src).to reek_of(:NilCheck)
67
76
  end
68
77
 
69
78
  it 'reports when scope uses &.' do
70
79
  src = <<-EOS
71
- def foo(bar)
72
- bar&.baz
73
- end
80
+ def alfa(bravo)
81
+ bravo&.charlie
82
+ end
74
83
  EOS
84
+
75
85
  expect(src).to reek_of(:NilCheck)
76
86
  end
77
87
 
78
88
  it 'reports all lines when scope uses multiple nilchecks' do
79
89
  src = <<-EOS
80
- def foo(bar)
81
- bar.nil?
82
- bar === nil
83
- bar&.baz
84
- end
90
+ def alfa(bravo)
91
+ bravo.nil?
92
+ @charlie === nil
93
+ delta&.echo
94
+ end
85
95
  EOS
96
+
86
97
  expect(src).to reek_of(:NilCheck, lines: [2, 3, 4])
87
98
  end
88
99
  end
@@ -1,38 +1,53 @@
1
1
  require_relative '../../spec_helper'
2
- require_lib 'reek/context/module_context'
3
- require_relative 'smell_detector_shared'
2
+ require_lib 'reek/smells/prima_donna_method'
4
3
 
5
4
  RSpec.describe Reek::Smells::PrimaDonnaMethod do
6
5
  it 'reports the right values' do
7
- src = 'class C; def m!; end; end'
8
- expect(src).to reek_of :PrimaDonnaMethod,
6
+ src = <<-EOS
7
+ class Alfa
8
+ def bravo!
9
+ end
10
+ end
11
+ EOS
12
+
13
+ expect(src).to reek_of(:PrimaDonnaMethod,
14
+ lines: [1],
15
+ context: 'Alfa',
16
+ message: "has prima donna method 'bravo!'",
17
+ source: 'string',
18
+ name: :bravo!)
19
+ end
20
+
21
+ it 'does count all occurences' do
22
+ src = <<-EOS
23
+ class Alfa
24
+ def bravo!
25
+ end
26
+
27
+ def charlie!
28
+ end
29
+ end
30
+ EOS
31
+
32
+ expect(src).to reek_of(:PrimaDonnaMethod,
33
+ lines: [1],
34
+ name: :bravo!)
35
+ expect(src).to reek_of(:PrimaDonnaMethod,
9
36
  lines: [1],
10
- message: 'has prima donna method `m!`',
11
- name: :m!
37
+ name: :charlie!)
12
38
  end
13
39
 
14
40
  it 'should report nothing when method and bang counterpart exist' do
15
- expect('class C; def m; end; def m!; end; end').not_to reek_of(:PrimaDonnaMethod)
16
- end
41
+ src = <<-EOS
42
+ class Alfa
43
+ def bravo
44
+ end
17
45
 
18
- it 'should report PrimaDonnaMethod when only bang method exists' do
19
- expect('class C; def m!; end; end').to reek_of(:PrimaDonnaMethod)
20
- end
46
+ def bravo!
47
+ end
48
+ end
49
+ EOS
21
50
 
22
- describe 'the right smell' do
23
- let(:detector) { build(:smell_detector, smell_type: :PrimaDonnaMethod) }
24
- let(:src) { 'class C; def m!; end; end' }
25
- let(:ctx) do
26
- Reek::Context::ModuleContext.new(nil,
27
- Reek::Source::SourceCode.from(src).syntax_tree)
28
- end
29
-
30
- it 'should be reported' do
31
- smells = detector.sniff(ctx)
32
- warning = smells[0]
33
-
34
- expect(warning.smell_type).to eq('PrimaDonnaMethod')
35
- expect(warning.lines).to eq([1])
36
- end
51
+ expect(src).not_to reek_of(:PrimaDonnaMethod)
37
52
  end
38
53
  end
@@ -1,112 +1,100 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_lib 'reek/smells/repeated_conditional'
3
- require_lib 'reek/context/code_context'
4
- require_relative 'smell_detector_shared'
5
- require_lib 'reek/source/source_code'
6
3
 
7
4
  RSpec.describe Reek::Smells::RepeatedConditional do
8
- let(:detector) { build(:smell_detector, smell_type: :RepeatedConditional) }
5
+ it 'reports the right values' do
6
+ src = <<-EOS
7
+ class Alfa
8
+ attr_accessor :bravo
9
9
 
10
- it_should_behave_like 'SmellDetector'
10
+ def charlie
11
+ puts "Repeat 1!" if bravo
12
+ end
11
13
 
12
- context 'with no conditionals' do
13
- it 'gathers an empty hash' do
14
- ast = Reek::Source::SourceCode.from('module Stable; end').syntax_tree
15
- ctx = Reek::Context::CodeContext.new(nil, ast)
16
- expect(detector.conditional_counts(ctx).length).to eq(0)
17
- end
18
- end
14
+ def delta
15
+ puts "Repeat 2!" if bravo
16
+ end
19
17
 
20
- context 'with a test of block_given?' do
21
- it 'does not record the condition' do
22
- ast = Reek::Source::SourceCode.from('def fred() yield(3) if block_given?; end').syntax_tree
23
- ctx = Reek::Context::CodeContext.new(nil, ast)
24
- expect(detector.conditional_counts(ctx).length).to eq(0)
25
- end
18
+ def echo
19
+ puts "Repeat 3!" if bravo
20
+ end
21
+ end
22
+ EOS
23
+
24
+ expect(src).to reek_of(:RepeatedConditional,
25
+ lines: [5, 9, 13],
26
+ context: 'Alfa',
27
+ message: "tests 'bravo' at least 3 times",
28
+ source: 'string',
29
+ name: 'bravo',
30
+ count: 3)
26
31
  end
27
32
 
28
- context 'with an empty condition' do
29
- it 'does not record the condition' do
30
- ast = Reek::Source::SourceCode.from('def fred() case; when 3; end; end').syntax_tree
31
- ctx = Reek::Context::CodeContext.new(nil, ast)
32
- expect(detector.conditional_counts(ctx).length).to eq(0)
33
- end
34
- end
33
+ it 'does count all occurences' do
34
+ src = <<-EOS
35
+ class Alfa
36
+ attr_accessor :bravo
35
37
 
36
- context 'with three identical conditionals' do
37
- let(:cond) { '@field == :sym' }
38
- let(:cond_expr) { Reek::Source::SourceCode.from(cond).syntax_tree }
38
+ def charlie
39
+ puts "Repeat 1!" if bravo
40
+ puts "And again!" if bravo
41
+ end
39
42
 
40
- let(:conds) do
41
- src = <<-EOS
42
- class Scrunch
43
- def first
44
- puts "hello" if @debug
45
- return #{cond} ? 0 : 3;
46
- end
47
- def second
48
- if #{cond}
49
- @other += " quarts"
50
- end
51
- end
52
- def third
53
- raise 'flu!' unless #{cond}
54
- end
43
+ def delta
44
+ puts "Repeat 2!" if bravo
55
45
  end
56
- EOS
57
46
 
58
- ast = Reek::Source::SourceCode.from(src).syntax_tree
59
- ctx = Reek::Context::CodeContext.new(nil, ast)
60
- detector.conditional_counts(ctx)
61
- end
47
+ def echo
48
+ puts "Repeat 3!" if bravo
49
+ end
50
+ end
51
+ EOS
62
52
 
63
- it 'finds both conditionals' do
64
- expect(conds.length).to eq(2)
65
- end
53
+ expect(src).to reek_of(:RepeatedConditional,
54
+ lines: [5, 6, 10, 14],
55
+ count: 4)
56
+ end
66
57
 
67
- it 'returns the condition expr' do
68
- expect(conds.keys[1]).to eq(cond_expr)
69
- end
58
+ it 'does not report two repeated conditionals' do
59
+ src = <<-EOS
60
+ class Alfa
61
+ attr_accessor :bravo
70
62
 
71
- it 'knows there are three copies' do
72
- expect(conds.values[1].length).to eq(3)
73
- end
63
+ def charlie
64
+ puts "Repeat 1!" if bravo
65
+ end
66
+
67
+ def delta
68
+ puts "Repeat 2!" if bravo
69
+ end
70
+ end
71
+ EOS
72
+
73
+ expect(src).not_to reek_of(:RepeatedConditional)
74
74
  end
75
75
 
76
- context 'with a matching if and case' do
77
- let(:cond) { '@field == :sym' }
78
- let(:cond_expr) { Reek::Source::SourceCode.from(cond).syntax_tree }
76
+ it 'reports repeated conditionals regardless of `if` or `case` statements' do
77
+ src = <<-EOS
78
+ class Alfa
79
+ attr_accessor :bravo
79
80
 
80
- let(:conds) do
81
- src = <<-EOS
82
- class Scrunch
83
- def alpha
84
- return #{cond} ? 0 : 2;
85
- end
86
- def beta
87
- case #{cond}
88
- when :symbol
89
- @tother += " pints"
90
- end
91
- end
81
+ def charlie
82
+ puts "Repeat 1!" if bravo
92
83
  end
93
- EOS
94
-
95
- ast = Reek::Source::SourceCode.from(src).syntax_tree
96
- ctx = Reek::Context::CodeContext.new(nil, ast)
97
- detector.conditional_counts(ctx)
98
- end
99
84
 
100
- it 'finds exactly one conditional' do
101
- expect(conds.length).to eq(1)
102
- end
85
+ def delta
86
+ case bravo
87
+ when 1 then puts "Repeat 2!"
88
+ else 'nothing'
89
+ end
90
+ end
103
91
 
104
- it 'returns the condition expr' do
105
- expect(conds.keys[0]).to eq(cond_expr)
106
- end
92
+ def echo
93
+ puts "Repeat 3!" if bravo
94
+ end
95
+ end
96
+ EOS
107
97
 
108
- it 'knows there are two copies' do
109
- expect(conds.values[0].length).to eq(2)
110
- end
98
+ expect(src).to reek_of(:RepeatedConditional)
111
99
  end
112
100
  end
@@ -31,6 +31,13 @@ RSpec.describe Reek::Smells::SmellWarning do
31
31
  it_should_behave_like 'first sorts ahead of second'
32
32
  end
33
33
 
34
+ context 'smells differing only by lines' do
35
+ let(:first) { build(:smell_warning, smell_detector: feature_envy_detector, lines: [2]) }
36
+ let(:second) { build(:smell_warning, smell_detector: feature_envy_detector, lines: [3]) }
37
+
38
+ it_should_behave_like 'first sorts ahead of second'
39
+ end
40
+
34
41
  context 'smells differing only by context' do
35
42
  let(:first) { build(:smell_warning, smell_detector: duplication_detector, context: 'first') }
36
43
  let(:second) do
@@ -1,157 +1,82 @@
1
1
  require_relative '../../spec_helper'
2
2
  require_lib 'reek/smells/subclassed_from_core_class'
3
- require_relative 'smell_detector_shared'
4
3
 
5
4
  RSpec.describe Reek::Smells::SubclassedFromCoreClass do
6
- let(:detector) { described_class.new }
7
-
8
- it_should_behave_like 'SmellDetector'
9
-
10
- context 'report' do
11
- context 'smell line' do
12
- context 'single class' do
13
- it 'should report the core class in the message' do
14
- src = <<-EOS
15
- class Dummy < Hash
16
- end
17
- EOS
18
-
19
- expect(src).to reek_of(:SubclassedFromCoreClass, lines: [1])
20
- end
21
- end
22
-
23
- context 'class inside a module' do
24
- it 'should report the core class in the message' do
25
- src = <<-EOS
26
- module Namespace
27
- class Dummy < Hash
28
- end
29
- end
30
- EOS
31
-
32
- expect(src).to reek_of(:SubclassedFromCoreClass, lines: [2])
33
- end
34
- end
35
- end
36
-
37
- context 'smell message' do
38
- context 'Array' do
39
- it 'should report the core class in the message' do
40
- src = <<-EOS
41
- class Dummy < Array
42
- end
43
- EOS
44
-
45
- expect(src).to reek_of(:SubclassedFromCoreClass, message: 'inherits from a core class (Array)')
46
- end
47
- end
48
-
49
- context 'Hash' do
50
- it 'should report the core class in the message' do
51
- src = <<-EOS
52
- class Dummy < Hash
53
- end
54
- EOS
55
-
56
- expect(src).to reek_of(:SubclassedFromCoreClass, message: 'inherits from a core class (Hash)')
57
- end
58
- end
59
- end
60
- end
61
-
62
- it 'does not inherit from a core class' do
5
+ it 'reports the right values' do
63
6
  src = <<-EOS
64
- class Dummy
7
+ class Alfa < Hash
65
8
  end
66
9
  EOS
67
10
 
68
- expect(src).to_not reek_of(:SubclassedFromCoreClass)
11
+ expect(src).to reek_of(:SubclassedFromCoreClass,
12
+ lines: [1],
13
+ context: 'Alfa',
14
+ message: "inherits from core class 'Hash'",
15
+ source: 'string',
16
+ ancestor: 'Hash')
69
17
  end
70
18
 
71
- it 'should report if we inherit from a core class' do
19
+ it 'reports when inheriting from a core class inside a module' do
72
20
  src = <<-EOS
73
- class Dummy < Array
21
+ module Alfa
22
+ class Bravo < Hash
23
+ end
74
24
  end
75
25
  EOS
76
26
 
77
- expect(src).to reek_of(:SubclassedFromCoreClass, ancestor: 'Array', message: 'inherits from a core class (Array)')
27
+ expect(src).to reek_of(:SubclassedFromCoreClass, context: 'Alfa::Bravo')
78
28
  end
79
29
 
80
- it 'should not report on coincidental core class names in other namespaces' do
30
+ it 'does not report when not inheriting from a core class' do
81
31
  src = <<-EOS
82
- class Dummy < My::Array
32
+ class Alfa
83
33
  end
84
34
  EOS
35
+
85
36
  expect(src).to_not reek_of(:SubclassedFromCoreClass)
86
37
  end
87
38
 
88
- it 'should report if we inherit from a core class from within a namespaced class' do
39
+ it 'does not report on coincidental core class names in other namespaces' do
89
40
  src = <<-EOS
90
- module Namespace
91
- class Dummy < Array
92
- end
41
+ class Alfa < Bravo::Array
93
42
  end
94
43
  EOS
95
- expect(src).to reek_of(:SubclassedFromCoreClass, ancestor: 'Array')
44
+
45
+ expect(src).to_not reek_of(:SubclassedFromCoreClass)
96
46
  end
97
47
 
98
- it 'should report if we inherit from a core class using Class#new' do
99
- src = 'Dummy = Class.new(Array)'
100
- expect(src).to reek_of(:SubclassedFromCoreClass, ancestor: 'Array')
48
+ it 'reports if we inherit from a core class using Class#new' do
49
+ src = 'Alfa = Class.new(Array)'
50
+ expect(src).to reek_of(:SubclassedFromCoreClass)
101
51
  end
102
52
 
103
- it 'should report if inner class inherit from a core class' do
53
+ it 'reports if inner class inherit from a core class' do
104
54
  src = <<-EOS
105
- module Namespace
106
- class Dummy
107
- Dummiest = Class.new(Array)
108
- end
55
+ class Alfa
56
+ Bravo = Class.new(Array)
109
57
  end
110
58
  EOS
111
- expect(src).to reek_of(:SubclassedFromCoreClass, ancestor: 'Array')
59
+
60
+ expect(src).to reek_of(:SubclassedFromCoreClass, context: 'Alfa::Bravo')
112
61
  end
113
62
 
114
- it 'should not report on coincidental core class names in other namespaces' do
115
- src = <<-EOS
116
- module Namespace
117
- class Dummy
118
- Dummiest = Class.new(My::Array)
119
- end
120
- end
121
- EOS
122
- expect(src).to_not reek_of(:SubclassedFromCoreClass)
63
+ it 'reports class which inherits from core class via Class.new' do
64
+ src = 'Alfa = Class.new(Array)'
65
+ expect(src).to reek_of(:SubclassedFromCoreClass)
123
66
  end
124
67
 
125
- it 'should not report if inner class inherits from allowed classes' do
126
- src = <<-EOS
127
- module Namespace
128
- class Dummy
129
- Dummiest = Class.new(StandardError)
130
- end
131
- end
132
- EOS
68
+ it 'does not report class which inherits from allowed class via Class.new' do
69
+ src = 'Alfa = Class.new(StandardError)'
133
70
  expect(src).to_not reek_of(:SubclassedFromCoreClass)
134
71
  end
135
72
 
136
- it 'should not report if class is created with Struct.new' do
137
- src = <<-EOS
138
- module Namespace
139
- class Dummy
140
- Dummiest = Struct.new('Array')
141
- end
142
- end
143
- EOS
73
+ it 'does not report classes created with Struct.new' do
74
+ src = "Alfa = Struct.new('Array')"
144
75
  expect(src).to_not reek_of(:SubclassedFromCoreClass)
145
76
  end
146
77
 
147
- it 'should only report classes created with Class.new' do
148
- src = <<-EOS
149
- module Namespace
150
- class Dummy
151
- Dummiest = Foo.new(Array)
152
- end
153
- end
154
- EOS
78
+ it 'does not report class created by another class constructor taking a core class as argument' do
79
+ src = 'Charlie = Delta.new(Array)'
155
80
  expect(src).to_not reek_of(:SubclassedFromCoreClass)
156
81
  end
157
82
  end