reek 3.5.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/CHANGELOG.md +19 -12
  4. data/CONTRIBUTING.md +7 -7
  5. data/README.md +91 -28
  6. data/ataru_setup.rb +13 -0
  7. data/{config/defaults.reek → defaults.reek} +0 -0
  8. data/docs/API.md +32 -31
  9. data/docs/Attribute.md +1 -1
  10. data/docs/Basic-Smell-Options.md +2 -1
  11. data/docs/Boolean-Parameter.md +1 -1
  12. data/docs/Class-Variable.md +2 -2
  13. data/docs/Command-Line-Options.md +2 -2
  14. data/docs/Control-Couple.md +3 -3
  15. data/docs/Control-Parameter.md +2 -2
  16. data/docs/Data-Clump.md +2 -2
  17. data/docs/Duplicate-Method-Call.md +4 -4
  18. data/docs/Feature-Envy.md +2 -2
  19. data/docs/How-reek-works-internally.md +2 -2
  20. data/docs/Irresponsible-Module.md +2 -2
  21. data/docs/Large-Class.md +2 -2
  22. data/docs/Long-Parameter-List.md +1 -1
  23. data/docs/Long-Yield-List.md +2 -2
  24. data/docs/Module-Initialize.md +3 -3
  25. data/docs/Nested-Iterators.md +1 -1
  26. data/docs/Nil-Check.md +2 -2
  27. data/docs/Prima-Donna-Method.md +4 -4
  28. data/docs/RSpec-matchers.md +7 -7
  29. data/docs/Rake-Task.md +2 -2
  30. data/docs/Reek-Driven-Development.md +4 -4
  31. data/docs/Repeated-Conditional.md +2 -2
  32. data/docs/Simulated-Polymorphism.md +2 -2
  33. data/docs/Smell-Suppression.md +3 -3
  34. data/docs/Too-Many-Instance-Variables.md +4 -4
  35. data/docs/Too-Many-Methods.md +5 -5
  36. data/docs/Too-Many-Statements.md +2 -2
  37. data/docs/Uncommunicative-Method-Name.md +4 -4
  38. data/docs/Uncommunicative-Module-Name.md +4 -4
  39. data/docs/Uncommunicative-Name.md +2 -2
  40. data/docs/Uncommunicative-Parameter-Name.md +4 -4
  41. data/docs/Uncommunicative-Variable-Name.md +3 -3
  42. data/docs/Unused-Parameters.md +2 -2
  43. data/docs/Utility-Function.md +4 -4
  44. data/docs/Versioning-Policy.md +2 -2
  45. data/features/command_line_interface/options.feature +1 -1
  46. data/features/configuration_files/directory_specific_directives.feature +4 -4
  47. data/features/configuration_loading.feature +10 -24
  48. data/features/programmatic_access.feature +3 -3
  49. data/features/reports/json.feature +1 -1
  50. data/features/reports/reports.feature +2 -2
  51. data/features/reports/yaml.feature +1 -1
  52. data/lib/reek/ast/sexp_extensions.rb +17 -498
  53. data/lib/reek/ast/sexp_extensions/arguments.rb +101 -0
  54. data/lib/reek/ast/sexp_extensions/attribute_assignments.rb +12 -0
  55. data/lib/reek/ast/sexp_extensions/block.rb +36 -0
  56. data/lib/reek/ast/sexp_extensions/case.rb +20 -0
  57. data/lib/reek/ast/sexp_extensions/constant.rb +12 -0
  58. data/lib/reek/ast/sexp_extensions/if.rb +16 -0
  59. data/lib/reek/ast/sexp_extensions/literal.rb +12 -0
  60. data/lib/reek/ast/sexp_extensions/logical_operators.rb +26 -0
  61. data/lib/reek/ast/sexp_extensions/methods.rb +114 -0
  62. data/lib/reek/ast/sexp_extensions/module.rb +85 -0
  63. data/lib/reek/ast/sexp_extensions/nested_assignables.rb +23 -0
  64. data/lib/reek/ast/sexp_extensions/send.rb +60 -0
  65. data/lib/reek/ast/sexp_extensions/super.rb +14 -0
  66. data/lib/reek/ast/sexp_extensions/symbols.rb +16 -0
  67. data/lib/reek/ast/sexp_extensions/variables.rb +38 -0
  68. data/lib/reek/ast/sexp_extensions/when.rb +16 -0
  69. data/lib/reek/ast/sexp_extensions/yield.rb +16 -0
  70. data/lib/reek/cli/application.rb +0 -4
  71. data/lib/reek/cli/options.rb +2 -4
  72. data/lib/reek/configuration/app_configuration.rb +37 -9
  73. data/lib/reek/configuration/configuration_file_finder.rb +8 -5
  74. data/lib/reek/configuration/directory_directives.rb +2 -2
  75. data/lib/reek/context/attribute_context.rb +21 -0
  76. data/lib/reek/context/code_context.rb +5 -9
  77. data/lib/reek/rake/task.rb +5 -5
  78. data/lib/reek/smells/nested_iterators.rb +73 -26
  79. data/lib/reek/smells/smell_warning.rb +1 -38
  80. data/lib/reek/source/source_code.rb +1 -1
  81. data/lib/reek/spec.rb +2 -2
  82. data/lib/reek/spec/should_reek_of.rb +8 -3
  83. data/lib/reek/spec/should_reek_only_of.rb +2 -1
  84. data/lib/reek/spec/smell_matcher.rb +59 -0
  85. data/lib/reek/tree_walker.rb +4 -3
  86. data/lib/reek/version.rb +1 -1
  87. data/logo/reek.bw.png +0 -0
  88. data/logo/reek.bw.svg +77 -0
  89. data/logo/reek.png +0 -0
  90. data/logo/reek.svg +621 -0
  91. data/logo/reek.text.png +0 -0
  92. data/logo/reek.text.svg +628 -0
  93. data/reek.gemspec +1 -1
  94. data/spec/factories/factories.rb +0 -1
  95. data/spec/reek/ast/sexp_extensions_spec.rb +0 -7
  96. data/spec/reek/cli/options_spec.rb +1 -2
  97. data/spec/reek/configuration/app_configuration_spec.rb +30 -14
  98. data/spec/reek/configuration/configuration_file_finder_spec.rb +23 -5
  99. data/spec/reek/smells/attribute_spec.rb +11 -2
  100. data/spec/reek/smells/boolean_parameter_spec.rb +14 -12
  101. data/spec/reek/smells/class_variable_spec.rb +18 -15
  102. data/spec/reek/smells/control_parameter_spec.rb +1 -2
  103. data/spec/reek/smells/duplicate_method_call_spec.rb +1 -2
  104. data/spec/reek/smells/feature_envy_spec.rb +8 -29
  105. data/spec/reek/smells/irresponsible_module_spec.rb +1 -2
  106. data/spec/reek/smells/long_parameter_list_spec.rb +1 -2
  107. data/spec/reek/smells/long_yield_list_spec.rb +1 -2
  108. data/spec/reek/smells/nested_iterators_spec.rb +1 -2
  109. data/spec/reek/smells/nil_check_spec.rb +1 -1
  110. data/spec/reek/smells/prima_donna_method_spec.rb +1 -1
  111. data/spec/reek/smells/repeated_conditional_spec.rb +1 -2
  112. data/spec/reek/smells/smell_detector_shared.rb +1 -1
  113. data/spec/reek/smells/smell_warning_spec.rb +2 -4
  114. data/spec/reek/smells/too_many_instance_variables_spec.rb +20 -19
  115. data/spec/reek/smells/too_many_statements_spec.rb +1 -1
  116. data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -4
  117. data/spec/reek/smells/uncommunicative_module_name_spec.rb +1 -4
  118. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +1 -4
  119. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +3 -3
  120. data/spec/reek/smells/utility_function_spec.rb +1 -3
  121. data/spec/reek/spec/should_reek_of_spec.rb +5 -5
  122. data/spec/reek/spec/smell_matcher_spec.rb +92 -0
  123. data/tasks/configuration.rake +15 -0
  124. metadata +37 -5
  125. data/config/cucumber.yml +0 -3
  126. data/tasks/develop.rake +0 -21
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.required_ruby_version = '>= 2.0.0'
23
23
  s.summary = 'Code smell detector for Ruby'
24
24
 
25
- s.add_runtime_dependency 'parser', '~> 2.2.2.5'
25
+ s.add_runtime_dependency 'parser', '~> 2.2', '>= 2.2.2.5'
26
26
  s.add_runtime_dependency 'private_attr', '~> 1.1'
27
27
  s.add_runtime_dependency 'rainbow', '~> 2.0'
28
28
  s.add_runtime_dependency 'unparser', '~> 0.2.2'
@@ -26,7 +26,6 @@ FactoryGirl.define do
26
26
  skip_create
27
27
  transient do
28
28
  smell_type 'FeatureEnvy'
29
- source 'foo'
30
29
  end
31
30
 
32
31
  initialize_with do
@@ -233,13 +233,6 @@ end
233
233
 
234
234
  RSpec.describe Reek::AST::SexpExtensions::LvarNode do
235
235
  let(:node) { sexp(:lvar, :foo) }
236
-
237
- describe '#simple_name' do
238
- it 'returns the lvar’s name' do
239
- expect(node.simple_name).to eq(:foo)
240
- end
241
- end
242
-
243
236
  describe '#var_name' do
244
237
  it 'returns the lvar’s name' do
245
238
  expect(node.var_name).to eq(:foo)
@@ -24,8 +24,7 @@ RSpec.describe Reek::CLI::Options do
24
24
 
25
25
  describe 'parse' do
26
26
  it 'raises on invalid argument in ARGV' do
27
- options = described_class.new
28
- options.argv = ['-z']
27
+ options = described_class.new ['-z']
29
28
  expect { options.parse }.to raise_error(OptionParser::InvalidOption)
30
29
  end
31
30
 
@@ -25,6 +25,26 @@ RSpec.describe Reek::Configuration::AppConfiguration do
25
25
  { Reek::Smells::UtilityFunction => { 'enabled' => false } } }
26
26
  end
27
27
 
28
+ let(:default_directive_value) do
29
+ { 'IrresponsibleModule' => { 'enabled' => false } }
30
+ end
31
+
32
+ let(:directory_directives_value) do
33
+ { 'spec/samples/three_clean_files' =>
34
+ { 'UtilityFunction' => { 'enabled' => false } } }
35
+ end
36
+
37
+ let(:exclude_paths_value) do
38
+ ['spec/samples/two_smelly_files',
39
+ 'spec/samples/source_with_non_ruby_files']
40
+ end
41
+
42
+ let(:combined_value) do
43
+ directory_directives_value.
44
+ merge(default_directive_value).
45
+ merge('exclude_paths' => exclude_paths_value)
46
+ end
47
+
28
48
  describe '#from_path' do
29
49
  let(:full_configuration_path) { SAMPLES_PATH.join('configuration/full_configuration.reek') }
30
50
 
@@ -38,20 +58,6 @@ RSpec.describe Reek::Configuration::AppConfiguration do
38
58
  end
39
59
 
40
60
  describe '#from_map' do
41
- let(:default_directive_value) do
42
- { 'IrresponsibleModule' => { 'enabled' => false } }
43
- end
44
-
45
- let(:directory_directives_value) do
46
- { 'spec/samples/three_clean_files' =>
47
- { 'UtilityFunction' => { 'enabled' => false } } }
48
- end
49
-
50
- let(:exclude_paths_value) do
51
- ['spec/samples/two_smelly_files',
52
- 'spec/samples/source_with_non_ruby_files']
53
- end
54
-
55
61
  it 'properly sets the configuration from simple data structures' do
56
62
  config = described_class.from_map(directory_directives: directory_directives_value,
57
63
  default_directive: default_directive_value,
@@ -72,6 +78,16 @@ RSpec.describe Reek::Configuration::AppConfiguration do
72
78
  expect(config.send(:directory_directives)).to eq(expected_directory_directives)
73
79
  end
74
80
  end
81
+
82
+ describe '#from_hash' do
83
+ it 'sets the configuration a unified simple data structure' do
84
+ config = described_class.from_hash(combined_value)
85
+
86
+ expect(config.send(:excluded_paths)).to eq(expected_excluded_paths)
87
+ expect(config.send(:default_directive)).to eq(expected_default_directive)
88
+ expect(config.send(:directory_directives)).to eq(expected_directory_directives)
89
+ end
90
+ end
75
91
  end
76
92
 
77
93
  describe '#directive_for' do
@@ -7,18 +7,19 @@ require_relative '../../spec_helper'
7
7
 
8
8
  RSpec.describe Reek::Configuration::ConfigurationFileFinder do
9
9
  describe '.find' do
10
- it 'returns the path if it’s set' do
10
+ it 'returns any explicitely passed path' do
11
11
  path = Pathname.new 'foo/bar'
12
12
  found = described_class.find(path: path)
13
13
  expect(found).to eq(path)
14
14
  end
15
15
 
16
- it 'returns the file in current dir if config_file is nil' do
17
- found = described_class.find(current: SAMPLES_PATH)
18
- expect(found).to eq(SAMPLES_PATH.join('exceptions.reek'))
16
+ it 'prefers an explicitely passed path over a file in current dir' do
17
+ path = Pathname.new 'foo/bar'
18
+ found = described_class.find(path: path, current: SAMPLES_PATH)
19
+ expect(found).to eq(path)
19
20
  end
20
21
 
21
- it 'returns the file in current dir if options is nil' do
22
+ it 'returns the file in current dir if path is not set' do
22
23
  found = described_class.find(current: SAMPLES_PATH)
23
24
  expect(found).to eq(SAMPLES_PATH.join('exceptions.reek'))
24
25
  end
@@ -42,6 +43,14 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
42
43
  end
43
44
  end
44
45
 
46
+ it 'prefers the file in :current over one in :home' do
47
+ found = described_class.find(current: SAMPLES_PATH, home: SAMPLES_PATH.join('masked_by_dotfile'))
48
+ file_in_home = SAMPLES_PATH.join('masked_by_dotfile/.reek')
49
+ file_in_current = SAMPLES_PATH.join('exceptions.reek')
50
+ expect(found).not_to eq(file_in_home)
51
+ expect(found).to eq(file_in_current)
52
+ end
53
+
45
54
  it 'returns nil when there are no files to find' do
46
55
  skip_if_a_config_in_tempdir
47
56
  Dir.mktmpdir do |tempdir|
@@ -52,6 +61,15 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
52
61
  end
53
62
  end
54
63
 
64
+ it 'does not traverse up from :home' do
65
+ skip_if_a_config_in_tempdir
66
+ Dir.mktmpdir do |tempdir|
67
+ current = Pathname.new(tempdir)
68
+ found = described_class.find(current: current, home: SAMPLES_PATH.join('no_config_file'))
69
+ expect(found).to be_nil
70
+ end
71
+ end
72
+
55
73
  it 'works with paths that need escaping' do
56
74
  Dir.mktmpdir("ma\ngic d*r") do |tempdir|
57
75
  config = Pathname.new("#{tempdir}/ma\ngic f*le.reek")
@@ -3,8 +3,7 @@ require_lib 'reek/smells/attribute'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
5
  RSpec.describe Reek::Smells::Attribute do
6
- let(:detector) { build(:smell_detector, smell_type: :Attribute, source: source_name) }
7
- let(:source_name) { 'source' }
6
+ let(:detector) { build(:smell_detector, smell_type: :Attribute) }
8
7
 
9
8
  it_should_behave_like 'SmellDetector'
10
9
 
@@ -38,6 +37,16 @@ RSpec.describe Reek::Smells::Attribute do
38
37
  expect(src).to reek_of(:Attribute, name: 'my_attr')
39
38
  end
40
39
 
40
+ it 'does not record writer attribute if suppressed with a preceding code comment' do
41
+ src = <<-EOS
42
+ class Klass
43
+ # :reek:Attribute
44
+ attr_writer :my_attr
45
+ end
46
+ EOS
47
+ expect(src).not_to reek_of(:Attribute)
48
+ end
49
+
41
50
  it 'records attr_writer attribute in a module' do
42
51
  src = <<-EOS
43
52
  module Mod
@@ -66,21 +66,23 @@ RSpec.describe Reek::Smells::BooleanParameter do
66
66
  end
67
67
 
68
68
  context 'when a smell is reported' do
69
- let(:detector) { build(:smell_detector, smell_type: :BooleanParameter, source: source_name) }
70
- let(:source_name) { 'string' }
69
+ let(:detector) { build(:smell_detector, smell_type: :BooleanParameter) }
71
70
 
72
71
  it_should_behave_like 'SmellDetector'
73
72
 
74
- it 'reports the fields correctly' do
75
- src = 'def cc(arga = true) end'
76
- ctx = Reek::Context::MethodContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
77
- smells = detector.examine_context(ctx)
78
- expect(smells.length).to eq(1)
79
- expect(smells[0].smell_category).to eq(described_class.smell_category)
80
- expect(smells[0].parameters[:name]).to eq('arga')
81
- expect(smells[0].source).to eq(source_name)
82
- expect(smells[0].smell_type).to eq(described_class.smell_type)
83
- expect(smells[0].lines).to eq([1])
73
+ context 'when a smell is reported' do
74
+ let(:warning) do
75
+ src = 'def cc(arga = true) end'
76
+ ctx = Reek::Context::MethodContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
77
+ detector.examine_context(ctx).first
78
+ end
79
+
80
+ it_should_behave_like 'common fields set correctly'
81
+
82
+ it 'reports the correct values' do
83
+ expect(warning.parameters[:name]).to eq('arga')
84
+ expect(warning.lines).to eq([1])
85
+ end
84
86
  end
85
87
  end
86
88
  end
@@ -5,8 +5,7 @@ require_relative 'smell_detector_shared'
5
5
 
6
6
  RSpec.describe Reek::Smells::ClassVariable do
7
7
  let(:class_variable) { '@@things' }
8
- let(:detector) { build(:smell_detector, smell_type: :ClassVariable, source: source_name) }
9
- let(:source_name) { 'string' }
8
+ let(:detector) { build(:smell_detector, smell_type: :ClassVariable) }
10
9
 
11
10
  it_should_behave_like 'SmellDetector'
12
11
 
@@ -78,18 +77,22 @@ RSpec.describe Reek::Smells::ClassVariable do
78
77
  end
79
78
  end
80
79
 
81
- it 'reports the correct fields' do
82
- src = <<-EOS
83
- module Fred
84
- #{class_variable} = {}
85
- end
86
- EOS
87
- ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
88
- warning = detector.examine_context(ctx)[0]
89
- expect(warning.source).to eq(source_name)
90
- expect(warning.smell_category).to eq(described_class.smell_category)
91
- expect(warning.smell_type).to eq(described_class.smell_type)
92
- expect(warning.parameters[:name]).to eq(class_variable)
93
- expect(warning.lines).to eq([2])
80
+ context 'when a smell is reported' do
81
+ let(:warning) do
82
+ src = <<-EOS
83
+ module Fred
84
+ #{class_variable} = {}
85
+ end
86
+ EOS
87
+ ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
88
+ detector.examine_context(ctx).first
89
+ end
90
+
91
+ it_should_behave_like 'common fields set correctly'
92
+
93
+ it 'reports the correct values' do
94
+ expect(warning.parameters[:name]).to eq(class_variable)
95
+ expect(warning.lines).to eq([2])
96
+ end
94
97
  end
95
98
  end
@@ -3,8 +3,7 @@ require_lib 'reek/smells/control_parameter'
3
3
  require_relative 'smell_detector_shared'
4
4
 
5
5
  RSpec.describe Reek::Smells::ControlParameter do
6
- let(:detector) { build(:smell_detector, smell_type: :ControlParameter, source: source_name) }
7
- let(:source_name) { 'string' }
6
+ let(:detector) { build(:smell_detector, smell_type: :ControlParameter) }
8
7
 
9
8
  it_should_behave_like 'SmellDetector'
10
9
 
@@ -6,8 +6,7 @@ require_relative 'smell_detector_shared'
6
6
 
7
7
  RSpec.describe Reek::Smells::DuplicateMethodCall do
8
8
  context 'when a smell is reported' do
9
- let(:detector) { build(:smell_detector, smell_type: :DuplicateMethodCall, source: source_name) }
10
- let(:source_name) { 'string' }
9
+ let(:detector) { build(:smell_detector, smell_type: :DuplicateMethodCall) }
11
10
 
12
11
  let(:warning) do
13
12
  src = <<-EOS
@@ -214,15 +214,14 @@ RSpec.describe Reek::Smells::FeatureEnvy do
214
214
  end
215
215
 
216
216
  RSpec.describe Reek::Smells::FeatureEnvy do
217
- let(:detector) { build(:smell_detector, smell_type: :FeatureEnvy, source: source_name) }
218
- let(:source_name) { 'string' }
217
+ let(:detector) { build(:smell_detector, smell_type: :FeatureEnvy) }
219
218
 
220
219
  it_should_behave_like 'SmellDetector'
221
220
 
222
221
  context 'when a smell is reported' do
223
222
  let(:receiver) { 'other' }
224
223
 
225
- let(:smells) do
224
+ let(:warning) do
226
225
  src = <<-EOS
227
226
  def envious(other)
228
227
  #{receiver}.call
@@ -231,35 +230,15 @@ RSpec.describe Reek::Smells::FeatureEnvy do
231
230
  #{receiver}.fred
232
231
  end
233
232
  EOS
234
- Reek::Examiner.new(src, ['FeatureEnvy']).smells
233
+ Reek::Examiner.new(src, ['FeatureEnvy']).smells.first
235
234
  end
236
235
 
237
- it 'reports only that smell' do
238
- expect(smells.length).to eq(1)
239
- end
240
-
241
- it 'reports the source' do
242
- expect(smells[0].source).to eq(source_name)
243
- end
244
-
245
- it 'reports the smell class' do
246
- expect(smells[0].smell_category).to eq(described_class.smell_category)
247
- end
248
-
249
- it 'reports the smell sub class' do
250
- expect(smells[0].smell_type).to eq(described_class.smell_type)
251
- end
252
-
253
- it 'reports the envious receiver' do
254
- expect(smells[0].parameters[:name]).to eq(receiver)
255
- end
256
-
257
- it 'reports the number of references' do
258
- expect(smells[0].parameters[:count]).to eq(3)
259
- end
236
+ it_should_behave_like 'common fields set correctly'
260
237
 
261
- it 'reports the referring lines' do
262
- expect(smells[0].lines).to eq([2, 4, 5])
238
+ it 'reports the correct values' do
239
+ expect(warning.parameters[:name]).to eq(receiver)
240
+ expect(warning.parameters[:count]).to eq(3)
241
+ expect(warning.lines).to eq([2, 4, 5])
263
242
  end
264
243
  end
265
244
  end
@@ -184,8 +184,7 @@ RSpec.describe Reek::Smells::IrresponsibleModule do
184
184
  end
185
185
 
186
186
  context 'when a smell is reported' do
187
- let(:detector) { build(:smell_detector, smell_type: :IrresponsibleModule, source: source_name) }
188
- let(:source_name) { 'string' }
187
+ let(:detector) { build(:smell_detector, smell_type: :IrresponsibleModule) }
189
188
 
190
189
  it_should_behave_like 'SmellDetector'
191
190
  end
@@ -74,8 +74,7 @@ RSpec.describe Reek::Smells::LongParameterList do
74
74
  end
75
75
 
76
76
  RSpec.describe Reek::Smells::LongParameterList do
77
- let(:detector) { build(:smell_detector, smell_type: :LongParameterList, source: source_name) }
78
- let(:source_name) { 'string' }
77
+ let(:detector) { build(:smell_detector, smell_type: :LongParameterList) }
79
78
 
80
79
  it_should_behave_like 'SmellDetector'
81
80
 
@@ -4,8 +4,7 @@ require_lib 'reek/smells/long_yield_list'
4
4
  require_relative 'smell_detector_shared'
5
5
 
6
6
  RSpec.describe Reek::Smells::LongYieldList do
7
- let(:detector) { build(:smell_detector, smell_type: :LongYieldList, source: source_name) }
8
- let(:source_name) { 'string' }
7
+ let(:detector) { build(:smell_detector, smell_type: :LongYieldList) }
9
8
 
10
9
  it_should_behave_like 'SmellDetector'
11
10
 
@@ -259,8 +259,7 @@ RSpec.describe Reek::Smells::NestedIterators do
259
259
  end
260
260
 
261
261
  RSpec.describe Reek::Smells::NestedIterators do
262
- let(:detector) { build(:smell_detector, smell_type: :NestedIterators, source: source_name) }
263
- let(:source_name) { 'string' }
262
+ let(:detector) { build(:smell_detector, smell_type: :NestedIterators) }
264
263
 
265
264
  it_should_behave_like 'SmellDetector'
266
265
 
@@ -12,7 +12,7 @@ RSpec.describe Reek::Smells::NilCheck do
12
12
  end
13
13
  EOS
14
14
  ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
15
- detector = build(:smell_detector, smell_type: :NilCheck, source: 'source_name')
15
+ detector = build(:smell_detector, smell_type: :NilCheck)
16
16
  smells = detector.examine_context(ctx)
17
17
  expect(smells[0].lines).to eq [2]
18
18
  end
@@ -12,7 +12,7 @@ RSpec.describe Reek::Smells::PrimaDonnaMethod do
12
12
  end
13
13
 
14
14
  describe 'the right smell' do
15
- let(:detector) { build(:smell_detector, smell_type: :PrimaDonnaMethod, source: 'source_name') }
15
+ let(:detector) { build(:smell_detector, smell_type: :PrimaDonnaMethod) }
16
16
  let(:src) { 'class C; def m!; end; end' }
17
17
  let(:ctx) do
18
18
  Reek::Context::ModuleContext.new(nil,
@@ -5,8 +5,7 @@ require_relative 'smell_detector_shared'
5
5
  require_lib 'reek/source/source_code'
6
6
 
7
7
  RSpec.describe Reek::Smells::RepeatedConditional do
8
- let(:detector) { build(:smell_detector, smell_type: :RepeatedConditional, source: source_name) }
9
- let(:source_name) { 'string' }
8
+ let(:detector) { build(:smell_detector, smell_type: :RepeatedConditional) }
10
9
 
11
10
  it_should_behave_like 'SmellDetector'
12
11
 
@@ -20,7 +20,7 @@ end
20
20
 
21
21
  RSpec.shared_examples_for 'common fields set correctly' do
22
22
  it 'reports the source' do
23
- expect(warning.source).to eq(source_name)
23
+ expect(warning.source).to eq('string')
24
24
  end
25
25
  it 'reports the smell class' do
26
26
  expect(warning.smell_category).to eq(detector.smell_category)
@@ -66,8 +66,7 @@ RSpec.describe Reek::Smells::SmellWarning do
66
66
  context 'smells differing everywhere' do
67
67
  let(:first) do
68
68
  uncommunicative_name_detector = build(:smell_detector,
69
- smell_type: 'UncommunicativeVariableName',
70
- source: true)
69
+ smell_type: 'UncommunicativeVariableName')
71
70
  build(:smell_warning, smell_detector: uncommunicative_name_detector,
72
71
  context: 'Dirty',
73
72
  message: "has the variable name '@s'")
@@ -75,8 +74,7 @@ RSpec.describe Reek::Smells::SmellWarning do
75
74
 
76
75
  let(:second) do
77
76
  duplication_detector = build(:smell_detector,
78
- smell_type: 'DuplicateMethodCall',
79
- source: false)
77
+ smell_type: 'DuplicateMethodCall')
80
78
  build(:smell_warning, smell_detector: duplication_detector,
81
79
  context: 'Dirty#a',
82
80
  message: 'calls @s.title twice')