reek 5.4.1 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +8 -6
  4. data/.rubocop_todo.yml +25 -20
  5. data/.simplecov +1 -0
  6. data/.travis.yml +17 -11
  7. data/CHANGELOG.md +31 -3
  8. data/Dockerfile +1 -0
  9. data/Gemfile +14 -17
  10. data/README.md +15 -11
  11. data/bin/code_climate_reek +12 -2
  12. data/docs/Attribute.md +1 -1
  13. data/docs/Boolean-Parameter.md +1 -1
  14. data/docs/Control-Couple.md +1 -1
  15. data/docs/Nil-Check.md +4 -1
  16. data/features/command_line_interface/options.feature +2 -3
  17. data/features/configuration_files/schema_validation.feature +1 -1
  18. data/features/reports/codeclimate.feature +2 -2
  19. data/features/reports/json.feature +3 -3
  20. data/features/reports/reports.feature +4 -4
  21. data/features/reports/yaml.feature +3 -3
  22. data/features/step_definitions/reek_steps.rb +5 -1
  23. data/features/step_definitions/sample_file_steps.rb +2 -2
  24. data/features/support/env.rb +1 -2
  25. data/lib/reek.rb +1 -0
  26. data/lib/reek/ast/sexp_extensions/arguments.rb +11 -0
  27. data/lib/reek/cli/options.rb +3 -3
  28. data/lib/reek/code_comment.rb +45 -38
  29. data/lib/reek/configuration/app_configuration.rb +4 -3
  30. data/lib/reek/configuration/configuration_converter.rb +2 -2
  31. data/lib/reek/configuration/directory_directives.rb +9 -3
  32. data/lib/reek/context/module_context.rb +3 -1
  33. data/lib/reek/errors/legacy_comment_separator_error.rb +36 -0
  34. data/lib/reek/examiner.rb +3 -3
  35. data/lib/reek/report.rb +5 -7
  36. data/lib/reek/report/code_climate/code_climate_configuration.yml +1 -1
  37. data/lib/reek/report/code_climate/code_climate_report.rb +2 -1
  38. data/lib/reek/report/simple_warning_formatter.rb +0 -7
  39. data/lib/reek/report/text_report.rb +2 -2
  40. data/lib/reek/smell_detectors/base_detector.rb +1 -9
  41. data/lib/reek/smell_detectors/boolean_parameter.rb +3 -1
  42. data/lib/reek/smell_detectors/data_clump.rb +23 -56
  43. data/lib/reek/smell_detectors/nil_check.rb +1 -12
  44. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +3 -7
  45. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +1 -1
  46. data/lib/reek/smell_warning.rb +1 -2
  47. data/lib/reek/source/source_code.rb +3 -2
  48. data/lib/reek/source/source_locator.rb +13 -10
  49. data/lib/reek/spec/smell_matcher.rb +2 -1
  50. data/lib/reek/version.rb +1 -1
  51. data/reek.gemspec +13 -6
  52. data/spec/performance/reek/smell_detectors/runtime_speed_spec.rb +2 -4
  53. data/spec/quality/documentation_spec.rb +2 -1
  54. data/spec/reek/ast/sexp_extensions_spec.rb +15 -33
  55. data/spec/reek/code_comment_spec.rb +41 -42
  56. data/spec/reek/configuration/directory_directives_spec.rb +6 -0
  57. data/spec/reek/context_builder_spec.rb +110 -113
  58. data/spec/reek/report/code_climate/code_climate_configuration_spec.rb +1 -3
  59. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +26 -26
  60. data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +6 -6
  61. data/spec/reek/report/code_climate/code_climate_report_spec.rb +1 -1
  62. data/spec/reek/report/json_report_spec.rb +1 -1
  63. data/spec/reek/report/location_formatter_spec.rb +3 -3
  64. data/spec/reek/report/text_report_spec.rb +1 -7
  65. data/spec/reek/report/yaml_report_spec.rb +1 -1
  66. data/spec/reek/smell_detectors/base_detector_spec.rb +3 -13
  67. data/spec/reek/smell_detectors/data_clump_spec.rb +14 -0
  68. data/spec/reek/smell_detectors/missing_safe_method_spec.rb +8 -2
  69. data/spec/reek/smell_detectors/nil_check_spec.rb +3 -3
  70. data/spec/reek/smell_warning_spec.rb +12 -12
  71. data/spec/reek/source/source_code_spec.rb +13 -0
  72. data/spec/reek/spec/should_reek_of_spec.rb +0 -1
  73. data/spec/reek/spec/should_reek_only_of_spec.rb +6 -6
  74. data/spec/reek/spec/smell_matcher_spec.rb +1 -1
  75. data/spec/spec_helper.rb +20 -6
  76. data/tasks/configuration.rake +1 -2
  77. metadata +15 -25
  78. data/spec/factories/factories.rb +0 -37
@@ -3,9 +3,7 @@ require_lib 'reek/report/code_climate/code_climate_configuration'
3
3
 
4
4
  RSpec.describe Reek::Report::CodeClimateConfiguration do
5
5
  yml = described_class.load
6
- smell_types = Reek::SmellDetectors::BaseDetector.descendants.map do |descendant|
7
- descendant.name.demodulize
8
- end
6
+ smell_types = Reek::SmellDetectors::BaseDetector.descendants.map(&:smell_type)
9
7
 
10
8
  smell_types.each do |name|
11
9
  config = yml.fetch(name)
@@ -8,12 +8,12 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
8
8
  context 'when fingerprinting a warning with no parameters' do
9
9
  let(:expected_fingerprint) { 'e68badd29db51c92363a7c6a2438d722' }
10
10
  let(:warning) do
11
- build(:smell_warning,
12
- smell_type: 'UtilityFunction',
13
- context: 'alfa',
14
- message: "doesn't depend on instance state (maybe move it to another class?)",
15
- lines: lines,
16
- source: 'a/ruby/source/file.rb')
11
+ Reek::SmellWarning.new(
12
+ 'UtilityFunction',
13
+ context: 'alfa',
14
+ message: "doesn't depend on instance state (maybe move it to another class?)",
15
+ lines: lines,
16
+ source: 'a/ruby/source/file.rb')
17
17
  end
18
18
 
19
19
  context 'with code at a specific location' do
@@ -35,12 +35,12 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
35
35
 
36
36
  context 'when the fingerprint should not be computed' do
37
37
  let(:warning) do
38
- build(:smell_warning,
39
- smell_type: 'ManualDispatch',
40
- context: 'Alfa#bravo',
41
- message: 'manually dispatches method call',
42
- lines: [4],
43
- source: 'a/ruby/source/file.rb')
38
+ Reek::SmellWarning.new(
39
+ 'ManualDispatch',
40
+ context: 'Alfa#bravo',
41
+ message: 'manually dispatches method call',
42
+ lines: [4],
43
+ source: 'a/ruby/source/file.rb')
44
44
  end
45
45
 
46
46
  it 'returns nil' do
@@ -50,13 +50,13 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
50
50
 
51
51
  context 'when the smell warning has only identifying parameters' do
52
52
  let(:warning) do
53
- build(:smell_warning,
54
- smell_type: 'ClassVariable',
55
- context: 'Alfa',
56
- message: "declares the class variable '@@#{name}'",
57
- lines: [4],
58
- parameters: { name: "@@#{name}" },
59
- source: 'a/ruby/source/file.rb')
53
+ Reek::SmellWarning.new(
54
+ 'ClassVariable',
55
+ context: 'Alfa',
56
+ message: "declares the class variable '@@#{name}'",
57
+ lines: [4],
58
+ parameters: { name: "@@#{name}" },
59
+ source: 'a/ruby/source/file.rb')
60
60
  end
61
61
 
62
62
  context 'when the name is one thing' do
@@ -80,13 +80,13 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
80
80
 
81
81
  context 'when the smell warning has identifying and non-identifying parameters' do
82
82
  let(:warning) do
83
- build(:smell_warning,
84
- smell_type: 'DuplicateMethodCall',
85
- context: "Alfa##{name}",
86
- message: "calls '#{name}' #{count} times",
87
- lines: lines,
88
- parameters: { name: "@@#{name}", count: count },
89
- source: 'a/ruby/source/file.rb')
83
+ Reek::SmellWarning.new(
84
+ 'DuplicateMethodCall',
85
+ context: "Alfa##{name}",
86
+ message: "calls '#{name}' #{count} times",
87
+ lines: lines,
88
+ parameters: { name: "@@#{name}", count: count },
89
+ source: 'a/ruby/source/file.rb')
90
90
  end
91
91
 
92
92
  context 'when the parameters are provided' do
@@ -4,12 +4,12 @@ require_lib 'reek/report/code_climate/code_climate_formatter'
4
4
  RSpec.describe Reek::Report::CodeClimateFormatter do
5
5
  describe '#render' do
6
6
  let(:warning) do
7
- build(:smell_warning,
8
- smell_type: 'UtilityFunction',
9
- context: 'context foo',
10
- message: 'message bar',
11
- lines: [1, 2],
12
- source: 'a/ruby/source/file.rb')
7
+ Reek::SmellWarning.new(
8
+ 'UtilityFunction',
9
+ context: 'context foo',
10
+ message: 'message bar',
11
+ lines: [1, 2],
12
+ source: 'a/ruby/source/file.rb')
13
13
  end
14
14
  let(:rendered) { described_class.new(warning).render }
15
15
  let(:json) { JSON.parse rendered.chop }
@@ -7,7 +7,7 @@ require 'stringio'
7
7
 
8
8
  RSpec.describe Reek::Report::CodeClimateReport do
9
9
  let(:options) { {} }
10
- let(:instance) { described_class.new(options) }
10
+ let(:instance) { described_class.new(**options) }
11
11
  let(:examiner) { Reek::Examiner.new(source) }
12
12
 
13
13
  before do
@@ -7,7 +7,7 @@ require 'stringio'
7
7
 
8
8
  RSpec.describe Reek::Report::JSONReport do
9
9
  let(:options) { {} }
10
- let(:instance) { described_class.new(options) }
10
+ let(:instance) { described_class.new(**options) }
11
11
  let(:examiner) { Reek::Examiner.new(source) }
12
12
 
13
13
  before do
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
2
2
  require_lib 'reek/report/location_formatter'
3
3
 
4
4
  RSpec.describe Reek::Report::BlankLocationFormatter do
5
- let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
5
+ let(:warning) { build_smell_warning(lines: [11, 9, 250, 100]) }
6
6
 
7
7
  describe '.format' do
8
8
  it 'returns a blank String regardless of the warning' do
@@ -12,7 +12,7 @@ RSpec.describe Reek::Report::BlankLocationFormatter do
12
12
  end
13
13
 
14
14
  RSpec.describe Reek::Report::DefaultLocationFormatter do
15
- let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
15
+ let(:warning) { build_smell_warning(lines: [11, 9, 250, 100]) }
16
16
 
17
17
  describe '.format' do
18
18
  it 'returns a prefix with sorted line numbers' do
@@ -22,7 +22,7 @@ RSpec.describe Reek::Report::DefaultLocationFormatter do
22
22
  end
23
23
 
24
24
  RSpec.describe Reek::Report::SingleLineLocationFormatter do
25
- let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
25
+ let(:warning) { build_smell_warning(lines: [11, 9, 250, 100]) }
26
26
 
27
27
  describe '.format' do
28
28
  it 'returns the first line where the smell was found' do
@@ -6,13 +6,7 @@ require_lib 'reek/report/simple_warning_formatter'
6
6
  require 'rainbow'
7
7
 
8
8
  RSpec.describe Reek::Report::TextReport do
9
- let(:report_options) do
10
- {
11
- warning_formatter: Reek::Report::SimpleWarningFormatter.new,
12
- heading_formatter: Reek::Report::QuietHeadingFormatter
13
- }
14
- end
15
- let(:instance) { described_class.new report_options }
9
+ let(:instance) { described_class.new }
16
10
 
17
11
  context 'with a single empty source' do
18
12
  before do
@@ -7,7 +7,7 @@ require 'stringio'
7
7
 
8
8
  RSpec.describe Reek::Report::YAMLReport do
9
9
  let(:options) { {} }
10
- let(:instance) { described_class.new(options) }
10
+ let(:instance) { described_class.new(**options) }
11
11
  let(:examiner) { Reek::Examiner.new(source) }
12
12
 
13
13
  before do
@@ -5,13 +5,13 @@ require_lib 'reek/smell_detectors/duplicate_method_call'
5
5
  RSpec.describe Reek::SmellDetectors::BaseDetector do
6
6
  describe '.todo_configuration_for' do
7
7
  it 'returns exclusion configuration for the given smells' do
8
- smell = create(:smell_warning, smell_type: 'Foo', context: 'Foo#bar')
8
+ smell = build_smell_warning(smell_type: 'Foo', context: 'Foo#bar')
9
9
  result = described_class.todo_configuration_for([smell])
10
10
  expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
11
11
  end
12
12
 
13
13
  it 'merges identical contexts' do
14
- smell = create(:smell_warning, smell_type: 'Foo', context: 'Foo#bar')
14
+ smell = build_smell_warning(smell_type: 'Foo', context: 'Foo#bar')
15
15
  result = described_class.todo_configuration_for([smell, smell])
16
16
  expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
17
17
  end
@@ -20,7 +20,7 @@ RSpec.describe Reek::SmellDetectors::BaseDetector do
20
20
  let(:subclass) { Reek::SmellDetectors::TooManyStatements }
21
21
 
22
22
  it 'includes default exclusions' do
23
- smell = create(:smell_warning, smell_type: 'TooManyStatements', context: 'Foo#bar')
23
+ smell = build_smell_warning(smell_type: 'TooManyStatements', context: 'Foo#bar')
24
24
  result = subclass.todo_configuration_for([smell])
25
25
 
26
26
  aggregate_failures do
@@ -31,16 +31,6 @@ RSpec.describe Reek::SmellDetectors::BaseDetector do
31
31
  end
32
32
  end
33
33
 
34
- describe '.valid_detector?' do
35
- it 'returns true for a valid detector' do
36
- expect(described_class.valid_detector?('DuplicateMethodCall')).to be true
37
- end
38
-
39
- it 'returns false for an invalid detector' do
40
- expect(described_class.valid_detector?('Unknown')).to be false
41
- end
42
- end
43
-
44
34
  describe '.to_detector' do
45
35
  it 'returns the right detector' do
46
36
  expect(described_class.to_detector('DuplicateMethodCall')).to eq(Reek::SmellDetectors::DuplicateMethodCall)
@@ -76,6 +76,20 @@ RSpec.describe Reek::SmellDetectors::DataClump do
76
76
  parameters: ['echo', 'foxtrot'])
77
77
  end
78
78
 
79
+ it 'reports arguments in alphabetical order even if they are never used that way' do
80
+ src = <<-RUBY
81
+ #{scope} Alfa
82
+ def bravo (foxtrot, echo); end
83
+ def charlie(foxtrot, echo); end
84
+ def delta (foxtrot, echo); end
85
+ end
86
+ RUBY
87
+
88
+ expect(src).to reek_of(:DataClump,
89
+ count: 3,
90
+ parameters: ['echo', 'foxtrot'])
91
+ end
92
+
79
93
  it 'reports parameter sets that are > 2' do
80
94
  src = <<-RUBY
81
95
  #{scope} Alfa
@@ -50,13 +50,19 @@ RSpec.describe Reek::SmellDetectors::MissingSafeMethod do
50
50
 
51
51
  it 'does not report methods we excluded via comment' do
52
52
  source = <<-RUBY
53
- # :reek:MissingSafeMethod: { exclude: [ bravo! ] }
53
+ # :reek:MissingSafeMethod { exclude: [ bravo! ] }
54
54
  class Alfa
55
55
  def bravo!
56
56
  end
57
+
58
+ def charlie!
59
+ end
57
60
  end
58
61
  RUBY
59
62
 
60
- expect(source).not_to reek_of(:MissingSafeMethod)
63
+ aggregate_failures do
64
+ expect(source).not_to reek_of(:MissingSafeMethod, name: 'bravo!')
65
+ expect(source).to reek_of(:MissingSafeMethod, name: 'charlie!')
66
+ end
61
67
  end
62
68
  end
@@ -76,14 +76,14 @@ RSpec.describe Reek::SmellDetectors::NilCheck do
76
76
  expect(src).to reek_of(:NilCheck)
77
77
  end
78
78
 
79
- it 'reports when scope uses &.' do
79
+ it 'does not report when scope uses &.' do
80
80
  src = <<-RUBY
81
81
  def alfa(bravo)
82
82
  bravo&.charlie
83
83
  end
84
84
  RUBY
85
85
 
86
- expect(src).to reek_of(:NilCheck)
86
+ expect(src).not_to reek_of(:NilCheck)
87
87
  end
88
88
 
89
89
  it 'reports all lines when scope uses multiple nilchecks' do
@@ -95,6 +95,6 @@ RSpec.describe Reek::SmellDetectors::NilCheck do
95
95
  end
96
96
  RUBY
97
97
 
98
- expect(src).to reek_of(:NilCheck, lines: [2, 3, 4])
98
+ expect(src).to reek_of(:NilCheck, lines: [2, 3])
99
99
  end
100
100
  end
@@ -24,23 +24,23 @@ RSpec.describe Reek::SmellWarning do
24
24
  end
25
25
 
26
26
  context 'when smells differ only by detector' do
27
- let(:first) { build(:smell_warning, smell_type: 'DuplicateMethodCall') }
28
- let(:second) { build(:smell_warning, smell_type: 'FeatureEnvy') }
27
+ let(:first) { build_smell_warning(smell_type: 'DuplicateMethodCall') }
28
+ let(:second) { build_smell_warning(smell_type: 'FeatureEnvy') }
29
29
 
30
30
  it_behaves_like 'first sorts ahead of second'
31
31
  end
32
32
 
33
33
  context 'when smells differ only by lines' do
34
- let(:first) { build(:smell_warning, smell_type: 'FeatureEnvy', lines: [2]) }
35
- let(:second) { build(:smell_warning, smell_type: 'FeatureEnvy', lines: [3]) }
34
+ let(:first) { build_smell_warning(smell_type: 'FeatureEnvy', lines: [2]) }
35
+ let(:second) { build_smell_warning(smell_type: 'FeatureEnvy', lines: [3]) }
36
36
 
37
37
  it_behaves_like 'first sorts ahead of second'
38
38
  end
39
39
 
40
40
  context 'when smells differ only by context' do
41
- let(:first) { build(:smell_warning, smell_type: 'DuplicateMethodCall', context: 'first') }
41
+ let(:first) { build_smell_warning(smell_type: 'DuplicateMethodCall', context: 'first') }
42
42
  let(:second) do
43
- build(:smell_warning, smell_type: 'DuplicateMethodCall', context: 'second')
43
+ build_smell_warning(smell_type: 'DuplicateMethodCall', context: 'second')
44
44
  end
45
45
 
46
46
  it_behaves_like 'first sorts ahead of second'
@@ -48,11 +48,11 @@ RSpec.describe Reek::SmellWarning do
48
48
 
49
49
  context 'when smells differ only by message' do
50
50
  let(:first) do
51
- build(:smell_warning, smell_type: 'DuplicateMethodCall',
51
+ build_smell_warning(smell_type: 'DuplicateMethodCall',
52
52
  context: 'ctx', message: 'first message')
53
53
  end
54
54
  let(:second) do
55
- build(:smell_warning, smell_type: 'DuplicateMethodCall',
55
+ build_smell_warning(smell_type: 'DuplicateMethodCall',
56
56
  context: 'ctx', message: 'second message')
57
57
  end
58
58
 
@@ -61,10 +61,10 @@ RSpec.describe Reek::SmellWarning do
61
61
 
62
62
  context 'when smells differ by name and message' do
63
63
  let(:first) do
64
- build(:smell_warning, smell_type: 'FeatureEnvy', message: 'second message')
64
+ build_smell_warning(smell_type: 'FeatureEnvy', message: 'second message')
65
65
  end
66
66
  let(:second) do
67
- build(:smell_warning, smell_type: 'UtilityFunction', message: 'first message')
67
+ build_smell_warning(smell_type: 'UtilityFunction', message: 'first message')
68
68
  end
69
69
 
70
70
  it_behaves_like 'first sorts ahead of second'
@@ -72,13 +72,13 @@ RSpec.describe Reek::SmellWarning do
72
72
 
73
73
  context 'when smells differ everywhere' do
74
74
  let(:first) do
75
- build(:smell_warning, smell_type: 'DuplicateMethodCall',
75
+ build_smell_warning(smell_type: 'DuplicateMethodCall',
76
76
  context: 'Dirty#a',
77
77
  message: 'calls @s.title twice')
78
78
  end
79
79
 
80
80
  let(:second) do
81
- build(:smell_warning, smell_type: 'UncommunicativeVariableName',
81
+ build_smell_warning(smell_type: 'UncommunicativeVariableName',
82
82
  context: 'Dirty',
83
83
  message: "has the variable name '@s'")
84
84
  end
@@ -62,5 +62,18 @@ RSpec.describe Reek::Source::SourceCode do
62
62
  expect { src.syntax_tree }.to raise_error error_class, error_message
63
63
  end
64
64
  end
65
+
66
+ if RUBY_VERSION >= '2.7'
67
+ context 'with ruby 2.7 syntax' do
68
+ context 'with forward_args (`...`)' do
69
+ let(:source_code) { described_class.new(source: 'def alpha(...) bravo(...); end') }
70
+
71
+ it 'returns a :forward_args node' do
72
+ result = source_code.syntax_tree
73
+ expect(result.children[1].type).to eq(:forward_args)
74
+ end
75
+ end
76
+ end
77
+ end
65
78
  end
66
79
  end
@@ -1,7 +1,6 @@
1
1
  require 'pathname'
2
2
  require_relative '../../spec_helper'
3
3
  require_lib 'reek/spec'
4
- require 'active_support/core_ext/hash/except'
5
4
 
6
5
  RSpec.describe Reek::Spec::ShouldReekOf do
7
6
  describe 'smell type selection' do
@@ -40,7 +40,7 @@ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
40
40
  end
41
41
 
42
42
  context 'with 1 non-matching smell' do
43
- let(:smells) { [build(:smell_warning, smell_type: 'ControlParameter')] }
43
+ let(:smells) { [build_smell_warning(smell_type: 'ControlParameter')] }
44
44
 
45
45
  it_behaves_like 'no match'
46
46
  end
@@ -48,8 +48,8 @@ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
48
48
  context 'with 2 non-matching smells' do
49
49
  let(:smells) do
50
50
  [
51
- build(:smell_warning, smell_type: 'ControlParameter'),
52
- build(:smell_warning, smell_type: 'FeatureEnvy')
51
+ build_smell_warning(smell_type: 'ControlParameter'),
52
+ build_smell_warning(smell_type: 'FeatureEnvy')
53
53
  ]
54
54
  end
55
55
 
@@ -59,8 +59,8 @@ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
59
59
  context 'with 1 non-matching and 1 matching smell' do
60
60
  let(:smells) do
61
61
  [
62
- build(:smell_warning, smell_type: 'ControlParameter'),
63
- build(:smell_warning, smell_type: expected_smell_type.to_s,
62
+ build_smell_warning(smell_type: 'ControlParameter'),
63
+ build_smell_warning(smell_type: expected_smell_type.to_s,
64
64
  message: "message mentioning #{expected_context_name}")
65
65
  ]
66
66
  end
@@ -70,7 +70,7 @@ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
70
70
 
71
71
  context 'with 1 matching smell' do
72
72
  let(:smells) do
73
- [build(:smell_warning, smell_type: expected_smell_type.to_s,
73
+ [build_smell_warning(smell_type: expected_smell_type.to_s,
74
74
  message: "message mentioning #{expected_context_name}")]
75
75
  end
76
76
 
@@ -3,7 +3,7 @@ require_lib 'reek/spec/smell_matcher'
3
3
 
4
4
  RSpec.describe Reek::Spec::SmellMatcher do
5
5
  let(:smell_warning) do
6
- build(:smell_warning, smell_type: 'UncommunicativeVariableName',
6
+ build_smell_warning(smell_type: 'UncommunicativeVariableName',
7
7
  message: "has the variable name '@s'",
8
8
  parameters: { test: 'something' })
9
9
  end
@@ -1,6 +1,5 @@
1
1
  require 'pathname'
2
2
  require 'timeout'
3
- require 'active_support/core_ext/string/strip'
4
3
  require 'rspec-benchmark'
5
4
  require_relative '../lib/reek'
6
5
  require_relative '../lib/reek/spec'
@@ -11,12 +10,9 @@ require_relative '../samples/paths'
11
10
 
12
11
  begin
13
12
  Reek::CLI::Silencer.without_warnings { require 'pry-byebug' }
14
- rescue LoadError # rubocop:disable Lint/HandleExceptions
13
+ rescue LoadError # rubocop:disable Lint/SuppressedException
15
14
  end
16
15
 
17
- require 'factory_bot'
18
- FactoryBot.find_definitions
19
-
20
16
  # Simple helpers for our specs.
21
17
  module Helpers
22
18
  def test_configuration_for(config)
@@ -70,14 +66,32 @@ module Helpers
70
66
  @klass_map ||= Reek::AST::ASTNodeClassMap.new
71
67
  @klass_map.klass_for(type).new(type, children)
72
68
  end
69
+
70
+ def build_smell_warning(smell_type: 'FeatureEnvy',
71
+ context: 'self',
72
+ lines: [42],
73
+ message: 'smell warning message',
74
+ source: 'dummy_file',
75
+ parameters: {})
76
+ Reek::SmellWarning.new(smell_type,
77
+ context: context,
78
+ lines: lines,
79
+ message: message,
80
+ source: source,
81
+ parameters: parameters)
82
+ end
83
+
84
+ def build_code_comment(comment: '', line: 1, source: 'string')
85
+ Reek::CodeComment.new(comment: comment, line: line, source: source)
86
+ end
73
87
  end
74
88
 
75
89
  RSpec.configure do |config|
76
90
  config.filter_run :focus
77
91
  config.run_all_when_everything_filtered = true
78
- config.include FactoryBot::Syntax::Methods
79
92
  config.include Helpers
80
93
  config.include RSpec::Benchmark::Matchers
94
+ config.example_status_persistence_file_path = 'spec/examples.txt'
81
95
 
82
96
  config.disable_monkey_patching!
83
97