reek 4.7.3 → 5.0.0

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 (248) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +17 -12
  3. data/.rubocop.yml +18 -3
  4. data/.simplecov +1 -0
  5. data/.travis.yml +3 -4
  6. data/.yardopts +1 -1
  7. data/CHANGELOG.md +45 -0
  8. data/Gemfile +4 -4
  9. data/README.md +134 -104
  10. data/Rakefile +16 -3
  11. data/bin/reek +1 -3
  12. data/docs/API.md +2 -9
  13. data/docs/Basic-Smell-Options.md +51 -11
  14. data/docs/Code-Smells.md +1 -1
  15. data/docs/Command-Line-Options.md +14 -4
  16. data/docs/Duplicate-Method-Call.md +49 -1
  17. data/docs/Feature-Envy.md +44 -0
  18. data/docs/How-To-Write-New-Detectors.md +2 -3
  19. data/docs/Instance-Variable-Assumption.md +1 -1
  20. data/docs/{Prima-Donna-Method.md → Missing-Safe-Method.md} +11 -9
  21. data/docs/Rake-Task.md +1 -1
  22. data/docs/Reek-4-to-Reek-5-migration.md +193 -0
  23. data/docs/Reek-Driven-Development.md +1 -1
  24. data/docs/Uncommunicative-Method-Name.md +45 -6
  25. data/docs/Uncommunicative-Module-Name.md +49 -7
  26. data/docs/Uncommunicative-Parameter-Name.md +43 -5
  27. data/docs/Uncommunicative-Variable-Name.md +73 -2
  28. data/docs/Unused-Private-Method.md +2 -2
  29. data/docs/defaults.reek.yml +129 -0
  30. data/docs/yard_plugin.rb +1 -0
  31. data/features/command_line_interface/basic_usage.feature +2 -2
  32. data/features/command_line_interface/options.feature +46 -4
  33. data/features/command_line_interface/show_progress.feature +4 -4
  34. data/features/command_line_interface/smell_selection.feature +1 -1
  35. data/features/command_line_interface/smells_count.feature +6 -6
  36. data/features/command_line_interface/stdin.feature +30 -8
  37. data/features/configuration_files/accept_setting.feature +45 -28
  38. data/features/configuration_files/directory_specific_directives.feature +78 -73
  39. data/features/configuration_files/exclude_directives.feature +11 -10
  40. data/features/configuration_files/exclude_paths_directives.feature +4 -4
  41. data/features/configuration_files/masking_smells.feature +38 -9
  42. data/features/configuration_files/mix_accept_reject_setting.feature +31 -28
  43. data/features/configuration_files/reject_setting.feature +52 -41
  44. data/features/configuration_files/schema_validation.feature +59 -0
  45. data/features/configuration_files/unused_private_method.feature +18 -16
  46. data/features/configuration_loading.feature +53 -10
  47. data/features/configuration_via_source_comments/erroneous_source_comments.feature +2 -2
  48. data/features/configuration_via_source_comments/well_formed_source_comments.feature +2 -2
  49. data/features/locales.feature +2 -2
  50. data/features/rake_task/rake_task.feature +15 -15
  51. data/features/reports/json.feature +3 -3
  52. data/features/reports/reports.feature +34 -34
  53. data/features/reports/yaml.feature +3 -3
  54. data/features/rspec_matcher.feature +9 -1
  55. data/features/samples.feature +287 -287
  56. data/features/step_definitions/reek_steps.rb +4 -0
  57. data/features/step_definitions/sample_file_steps.rb +9 -4
  58. data/features/support/env.rb +2 -2
  59. data/features/todo_list.feature +26 -23
  60. data/lib/reek/ast/node.rb +40 -55
  61. data/lib/reek/ast/object_refs.rb +1 -1
  62. data/lib/reek/ast/reference_collector.rb +2 -4
  63. data/lib/reek/ast/sexp_extensions/case.rb +1 -1
  64. data/lib/reek/ast/sexp_extensions/if.rb +8 -1
  65. data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -1
  66. data/lib/reek/ast/sexp_extensions/methods.rb +4 -6
  67. data/lib/reek/cli/application.rb +4 -3
  68. data/lib/reek/cli/command/report_command.rb +1 -2
  69. data/lib/reek/cli/command/todo_list_command.rb +8 -8
  70. data/lib/reek/cli/options.rb +29 -14
  71. data/lib/reek/cli/silencer.rb +14 -3
  72. data/lib/reek/code_comment.rb +14 -16
  73. data/lib/reek/configuration/app_configuration.rb +32 -28
  74. data/lib/reek/configuration/configuration_converter.rb +110 -0
  75. data/lib/reek/configuration/configuration_file_finder.rb +15 -40
  76. data/lib/reek/configuration/configuration_validator.rb +12 -23
  77. data/lib/reek/configuration/default_directive.rb +17 -3
  78. data/lib/reek/configuration/directory_directives.rb +17 -11
  79. data/lib/reek/configuration/excluded_paths.rb +1 -1
  80. data/lib/reek/configuration/rake_task_converter.rb +29 -0
  81. data/lib/reek/configuration/schema.yml +210 -0
  82. data/lib/reek/configuration/schema_validator.rb +38 -0
  83. data/lib/reek/context/attribute_context.rb +1 -1
  84. data/lib/reek/context/code_context.rb +8 -11
  85. data/lib/reek/context/method_context.rb +7 -12
  86. data/lib/reek/context/module_context.rb +4 -4
  87. data/lib/reek/context_builder.rb +11 -11
  88. data/lib/reek/detector_repository.rb +6 -0
  89. data/lib/reek/documentation_link.rb +28 -0
  90. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +13 -12
  91. data/lib/reek/errors/bad_detector_in_comment_error.rb +11 -10
  92. data/lib/reek/errors/base_error.rb +3 -0
  93. data/lib/reek/errors/config_file_error.rb +11 -0
  94. data/lib/reek/errors/encoding_error.rb +16 -11
  95. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +11 -10
  96. data/lib/reek/errors/incomprehensible_source_error.rb +20 -22
  97. data/lib/reek/errors/syntax_error.rb +41 -0
  98. data/lib/reek/examiner.rb +19 -25
  99. data/lib/reek/logging_error_handler.rb +7 -5
  100. data/lib/reek/rake/task.rb +3 -3
  101. data/lib/reek/report/base_report.rb +8 -12
  102. data/lib/reek/report/code_climate/code_climate_configuration.rb +1 -1
  103. data/lib/reek/report/code_climate/code_climate_configuration.yml +6 -10
  104. data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
  105. data/lib/reek/report/heading_formatter.rb +54 -0
  106. data/lib/reek/report/json_report.rb +1 -1
  107. data/lib/reek/report/location_formatter.rb +40 -0
  108. data/lib/reek/report/progress_formatter.rb +79 -0
  109. data/lib/reek/report/simple_warning_formatter.rb +34 -0
  110. data/lib/reek/report/text_report.rb +1 -2
  111. data/lib/reek/report/xml_report.rb +3 -3
  112. data/lib/reek/report/yaml_report.rb +1 -1
  113. data/lib/reek/report.rb +15 -10
  114. data/lib/reek/smell_configuration.rb +2 -2
  115. data/lib/reek/smell_detectors/attribute.rb +0 -1
  116. data/lib/reek/smell_detectors/base_detector.rb +9 -12
  117. data/lib/reek/smell_detectors/boolean_parameter.rb +0 -1
  118. data/lib/reek/smell_detectors/class_variable.rb +3 -11
  119. data/lib/reek/smell_detectors/control_parameter.rb +17 -32
  120. data/lib/reek/smell_detectors/data_clump.rb +3 -4
  121. data/lib/reek/smell_detectors/duplicate_method_call.rb +6 -7
  122. data/lib/reek/smell_detectors/feature_envy.rb +1 -1
  123. data/lib/reek/smell_detectors/instance_variable_assumption.rb +1 -10
  124. data/lib/reek/smell_detectors/irresponsible_module.rb +0 -1
  125. data/lib/reek/smell_detectors/long_parameter_list.rb +1 -2
  126. data/lib/reek/smell_detectors/long_yield_list.rb +2 -3
  127. data/lib/reek/smell_detectors/manual_dispatch.rb +3 -3
  128. data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +6 -7
  129. data/lib/reek/smell_detectors/module_initialize.rb +1 -2
  130. data/lib/reek/smell_detectors/nested_iterators.rb +6 -6
  131. data/lib/reek/smell_detectors/nil_check.rb +0 -1
  132. data/lib/reek/smell_detectors/repeated_conditional.rb +3 -4
  133. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +0 -1
  134. data/lib/reek/smell_detectors/too_many_constants.rb +2 -3
  135. data/lib/reek/smell_detectors/too_many_instance_variables.rb +1 -2
  136. data/lib/reek/smell_detectors/too_many_methods.rb +1 -2
  137. data/lib/reek/smell_detectors/too_many_statements.rb +1 -2
  138. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +2 -3
  139. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +2 -3
  140. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +2 -3
  141. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +6 -7
  142. data/lib/reek/smell_detectors/unused_parameters.rb +0 -1
  143. data/lib/reek/smell_detectors/unused_private_method.rb +0 -1
  144. data/lib/reek/smell_detectors/utility_function.rb +2 -3
  145. data/lib/reek/smell_detectors.rb +1 -2
  146. data/lib/reek/smell_warning.rb +15 -8
  147. data/lib/reek/source/source_code.rb +50 -72
  148. data/lib/reek/source/source_locator.rb +7 -7
  149. data/lib/reek/spec/should_reek.rb +2 -2
  150. data/lib/reek/spec/should_reek_of.rb +9 -16
  151. data/lib/reek/spec/should_reek_only_of.rb +4 -4
  152. data/lib/reek/spec.rb +6 -6
  153. data/lib/reek/tree_dresser.rb +5 -5
  154. data/lib/reek/version.rb +1 -1
  155. data/reek.gemspec +5 -5
  156. data/samples/checkstyle.xml +1 -1
  157. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
  158. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
  159. data/samples/configuration/full_configuration.reek +8 -4
  160. data/samples/configuration/full_mask.reek +5 -4
  161. data/samples/configuration/partial_mask.reek +3 -2
  162. data/samples/configuration/regular_configuration/.reek.yml +4 -0
  163. data/samples/paths.rb +5 -4
  164. data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
  165. data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
  166. data/spec/factories/factories.rb +2 -13
  167. data/spec/reek/ast/node_spec.rb +103 -10
  168. data/spec/reek/ast/reference_collector_spec.rb +1 -1
  169. data/spec/reek/ast/sexp_extensions_spec.rb +2 -2
  170. data/spec/reek/cli/application_spec.rb +50 -38
  171. data/spec/reek/cli/command/todo_list_command_spec.rb +6 -4
  172. data/spec/reek/cli/silencer_spec.rb +28 -0
  173. data/spec/reek/code_comment_spec.rb +31 -38
  174. data/spec/reek/configuration/app_configuration_spec.rb +46 -33
  175. data/spec/reek/configuration/configuration_file_finder_spec.rb +133 -49
  176. data/spec/reek/configuration/default_directive_spec.rb +1 -1
  177. data/spec/reek/configuration/directory_directives_spec.rb +6 -7
  178. data/spec/reek/configuration/excluded_paths_spec.rb +6 -6
  179. data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
  180. data/spec/reek/configuration/schema_validator_spec.rb +165 -0
  181. data/spec/reek/context/code_context_spec.rb +60 -96
  182. data/spec/reek/context/ghost_context_spec.rb +1 -1
  183. data/spec/reek/context/root_context_spec.rb +1 -1
  184. data/spec/reek/documentation_link_spec.rb +20 -0
  185. data/spec/reek/errors/base_error_spec.rb +13 -0
  186. data/spec/reek/examiner_spec.rb +100 -30
  187. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +82 -80
  188. data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +6 -6
  189. data/spec/reek/report/json_report_spec.rb +13 -46
  190. data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
  191. data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
  192. data/spec/reek/report/text_report_spec.rb +4 -4
  193. data/spec/reek/report/xml_report_spec.rb +3 -3
  194. data/spec/reek/report/yaml_report_spec.rb +9 -38
  195. data/spec/reek/report_spec.rb +3 -3
  196. data/spec/reek/smell_detectors/boolean_parameter_spec.rb +2 -2
  197. data/spec/reek/smell_detectors/class_variable_spec.rb +26 -32
  198. data/spec/reek/smell_detectors/control_parameter_spec.rb +34 -4
  199. data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +3 -3
  200. data/spec/reek/smell_detectors/feature_envy_spec.rb +47 -2
  201. data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +9 -9
  202. data/spec/reek/smell_detectors/module_initialize_spec.rb +14 -0
  203. data/spec/reek/smell_detectors/nested_iterators_spec.rb +1 -1
  204. data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
  205. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
  206. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
  207. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
  208. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +6 -4
  209. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +9 -9
  210. data/spec/reek/smell_detectors/unused_parameters_spec.rb +3 -3
  211. data/spec/reek/smell_detectors/unused_private_method_spec.rb +10 -10
  212. data/spec/reek/smell_detectors/utility_function_spec.rb +5 -5
  213. data/spec/reek/smell_warning_spec.rb +12 -8
  214. data/spec/reek/source/source_code_spec.rb +17 -43
  215. data/spec/reek/source/source_locator_spec.rb +17 -17
  216. data/spec/reek/spec/should_reek_of_spec.rb +7 -11
  217. data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
  218. data/spec/reek/spec/should_reek_spec.rb +3 -3
  219. data/spec/reek/spec/smell_matcher_spec.rb +3 -3
  220. data/spec/reek/tree_dresser_spec.rb +12 -17
  221. data/spec/spec_helper.rb +6 -17
  222. data/tasks/configuration.rake +8 -5
  223. metadata +71 -41
  224. data/defaults.reek +0 -131
  225. data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
  226. data/lib/reek/report/formatter/heading_formatter.rb +0 -52
  227. data/lib/reek/report/formatter/location_formatter.rb +0 -42
  228. data/lib/reek/report/formatter/progress_formatter.rb +0 -81
  229. data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
  230. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -36
  231. data/lib/reek/report/formatter.rb +0 -33
  232. data/lib/reek/smell_detectors/syntax.rb +0 -37
  233. data/samples/configuration/non_public_modifiers_mask.reek +0 -3
  234. data/samples/smelly_with_inline_mask.rb +0 -8
  235. data/samples/smelly_with_modifiers.rb +0 -12
  236. data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
  237. data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
  238. data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
  239. /data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
  240. /data/samples/{clean.rb → clean_source/clean.rb} +0 -0
  241. /data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
  242. /data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
  243. /data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
  244. /data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
  245. /data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
  246. /data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
  247. /data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
  248. /data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
@@ -3,7 +3,7 @@ require_lib 'reek/code_comment'
3
3
 
4
4
  RSpec.describe Reek::CodeComment do
5
5
  context 'with an empty comment' do
6
- let(:comment) { FactoryGirl.build(:code_comment, comment: '') }
6
+ let(:comment) { build(:code_comment, comment: '') }
7
7
 
8
8
  it 'is not descriptive' do
9
9
  expect(comment).not_to be_descriptive
@@ -14,33 +14,33 @@ RSpec.describe Reek::CodeComment do
14
14
  end
15
15
  end
16
16
 
17
- context 'comment checks' do
17
+ describe '#descriptive' do
18
18
  it 'rejects an empty comment' do
19
- comment = FactoryGirl.build(:code_comment, comment: '#')
19
+ comment = build(:code_comment, comment: '#')
20
20
  expect(comment).not_to be_descriptive
21
21
  end
22
22
 
23
23
  it 'rejects a 1-word comment' do
24
- comment = FactoryGirl.build(:code_comment, comment: "# alpha\n# ")
24
+ comment = build(:code_comment, comment: "# alpha\n# ")
25
25
  expect(comment).not_to be_descriptive
26
26
  end
27
27
 
28
28
  it 'accepts a 2-word comment' do
29
- comment = FactoryGirl.build(:code_comment, comment: '# alpha bravo ')
29
+ comment = build(:code_comment, comment: '# alpha bravo ')
30
30
  expect(comment).to be_descriptive
31
31
  end
32
32
 
33
33
  it 'accepts a multi-word comment' do
34
- comment = FactoryGirl.build(:code_comment, comment: "# alpha bravo \n# charlie \n # delta ")
34
+ comment = build(:code_comment, comment: "# alpha bravo \n# charlie \n # delta ")
35
35
  expect(comment).to be_descriptive
36
36
  end
37
37
  end
38
38
 
39
- context 'good comment config' do
39
+ describe 'good comment config' do
40
40
  it 'parses hashed options' do
41
41
  comment = '# :reek:DuplicateMethodCall { enabled: false }'
42
- config = FactoryGirl.build(:code_comment,
43
- comment: comment).config
42
+ config = build(:code_comment,
43
+ comment: comment).config
44
44
 
45
45
  expect(config).to include('DuplicateMethodCall')
46
46
  expect(config['DuplicateMethodCall']).to include('enabled')
@@ -49,8 +49,8 @@ RSpec.describe Reek::CodeComment do
49
49
 
50
50
  it "supports hashed options with the legacy separator ':' after the smell detector" do
51
51
  comment = '# :reek:DuplicateMethodCall: { enabled: false }'
52
- config = FactoryGirl.build(:code_comment,
53
- comment: comment).config
52
+ config = build(:code_comment,
53
+ comment: comment).config
54
54
 
55
55
  expect(config).to include('DuplicateMethodCall')
56
56
  expect(config['DuplicateMethodCall']).to include('enabled')
@@ -62,7 +62,7 @@ RSpec.describe Reek::CodeComment do
62
62
  # :reek:DuplicateMethodCall { enabled: false }
63
63
  # :reek:NestedIterators { enabled: true }
64
64
  EOF
65
- config = FactoryGirl.build(:code_comment, comment: comment).config
65
+ config = build(:code_comment, comment: comment).config
66
66
 
67
67
  expect(config).to include('DuplicateMethodCall', 'NestedIterators')
68
68
  expect(config['DuplicateMethodCall']).to include('enabled')
@@ -75,7 +75,7 @@ RSpec.describe Reek::CodeComment do
75
75
  comment = <<-EOF
76
76
  #:reek:DuplicateMethodCall { enabled: false } and :reek:NestedIterators { enabled: true }
77
77
  EOF
78
- config = FactoryGirl.build(:code_comment, comment: comment).config
78
+ config = build(:code_comment, comment: comment).config
79
79
 
80
80
  expect(config).to include('DuplicateMethodCall', 'NestedIterators')
81
81
  expect(config['DuplicateMethodCall']).to include('enabled')
@@ -86,7 +86,7 @@ RSpec.describe Reek::CodeComment do
86
86
 
87
87
  it 'parses multiple unhashed options on the same line' do
88
88
  comment = '# :reek:DuplicateMethodCall and :reek:NestedIterators'
89
- config = FactoryGirl.build(:code_comment, comment: comment).config
89
+ config = build(:code_comment, comment: comment).config
90
90
 
91
91
  expect(config).to include('DuplicateMethodCall', 'NestedIterators')
92
92
  expect(config['DuplicateMethodCall']).to include('enabled')
@@ -97,7 +97,7 @@ RSpec.describe Reek::CodeComment do
97
97
 
98
98
  it 'disables the smell if no options are specifed' do
99
99
  comment = '# :reek:DuplicateMethodCall'
100
- config = FactoryGirl.build(:code_comment, comment: comment).config
100
+ config = build(:code_comment, comment: comment).config
101
101
 
102
102
  expect(config).to include('DuplicateMethodCall')
103
103
  expect(config['DuplicateMethodCall']).to include('enabled')
@@ -105,8 +105,8 @@ RSpec.describe Reek::CodeComment do
105
105
  end
106
106
 
107
107
  it 'ignores smells after a space' do
108
- config = FactoryGirl.build(:code_comment,
109
- comment: '# :reek: DuplicateMethodCall').config
108
+ config = build(:code_comment,
109
+ comment: '# :reek: DuplicateMethodCall').config
110
110
  expect(config).not_to include('DuplicateMethodCall')
111
111
  end
112
112
 
@@ -117,7 +117,7 @@ RSpec.describe Reek::CodeComment do
117
117
  # :reek:NestedIterators { enabled: true }
118
118
  # comment
119
119
  EOF
120
- comment = FactoryGirl.build(:code_comment, comment: original_comment)
120
+ comment = build(:code_comment, comment: original_comment)
121
121
 
122
122
  expect(comment.send(:sanitized_comment)).to eq('Actual comment')
123
123
  end
@@ -125,66 +125,59 @@ RSpec.describe Reek::CodeComment do
125
125
  end
126
126
 
127
127
  RSpec.describe Reek::CodeComment::CodeCommentValidator do
128
- context 'bad detector' do
128
+ context 'when the comment contains an unknown detector name' do
129
129
  it 'raises BadDetectorInCommentError' do
130
130
  expect do
131
- FactoryGirl.build(:code_comment,
132
- comment: '# :reek:DoesNotExist')
131
+ build(:code_comment,
132
+ comment: '# :reek:DoesNotExist')
133
133
  end.to raise_error(Reek::Errors::BadDetectorInCommentError)
134
134
  end
135
135
  end
136
136
 
137
- context 'unparsable detector configuration' do
137
+ context 'when the comment contains an unparsable detector configuration' do
138
138
  it 'raises GarbageDetectorConfigurationInCommentError' do
139
139
  expect do
140
140
  comment = '# :reek:UncommunicativeMethodName { thats: a: bad: config }'
141
- FactoryGirl.build(:code_comment, comment: comment)
141
+ build(:code_comment, comment: comment)
142
142
  end.to raise_error(Reek::Errors::GarbageDetectorConfigurationInCommentError)
143
143
  end
144
144
  end
145
145
 
146
146
  describe 'validating configuration keys' do
147
- context 'basic options mispelled' do
147
+ context 'when basic options are mispelled' do
148
148
  it 'raises BadDetectorConfigurationKeyInCommentError' do
149
149
  expect do
150
150
  # exclude -> exlude and enabled -> nabled
151
151
  comment = '# :reek:UncommunicativeMethodName { exlude: alfa, nabled: true }'
152
- FactoryGirl.build(:code_comment, comment: comment)
152
+ build(:code_comment, comment: comment)
153
153
  end.to raise_error(Reek::Errors::BadDetectorConfigurationKeyInCommentError)
154
154
  end
155
155
  end
156
156
 
157
- context 'basic options not mispelled' do
157
+ context 'when basic options are not mispelled' do
158
158
  it 'does not raise' do
159
159
  expect do
160
160
  comment = '# :reek:UncommunicativeMethodName { exclude: alfa, enabled: true }'
161
- FactoryGirl.build(:code_comment, comment: comment)
162
- end.not_to raise_error
163
- end
164
-
165
- it 'does not raise on regexps' do
166
- expect do
167
- comment = '# :reek:UncommunicativeMethodName { exclude: !ruby/regexp /alfa/ }'
168
- FactoryGirl.build(:code_comment, comment: comment)
161
+ build(:code_comment, comment: comment)
169
162
  end.not_to raise_error
170
163
  end
171
164
  end
172
165
 
173
- context 'unknown custom options' do
166
+ context 'when unknown custom options are specified' do
174
167
  it 'raises BadDetectorConfigurationKeyInCommentError' do
175
168
  expect do
176
169
  # max_copies -> mx_copies and min_clump_size -> mn_clump_size
177
170
  comment = '# :reek:DataClump { mx_copies: 4, mn_clump_size: 3 }'
178
- FactoryGirl.build(:code_comment, comment: comment)
171
+ build(:code_comment, comment: comment)
179
172
  end.to raise_error(Reek::Errors::BadDetectorConfigurationKeyInCommentError)
180
173
  end
181
174
  end
182
175
 
183
- context 'valid custom options' do
176
+ context 'when valid custom options are specified' do
184
177
  it 'does not raise' do
185
178
  expect do
186
179
  comment = '# :reek:DataClump { max_copies: 4, min_clump_size: 3 }'
187
- FactoryGirl.build(:code_comment, comment: comment)
180
+ build(:code_comment, comment: comment)
188
181
  end.not_to raise_error
189
182
  end
190
183
  end
@@ -8,8 +8,8 @@ require_lib 'reek/configuration/excluded_paths'
8
8
  RSpec.describe Reek::Configuration::AppConfiguration do
9
9
  describe 'factory methods' do
10
10
  let(:expected_excluded_paths) do
11
- [SAMPLES_PATH.join('two_smelly_files'),
12
- SAMPLES_PATH.join('source_with_non_ruby_files')]
11
+ [SAMPLES_DIR.join('two_smelly_files'),
12
+ SAMPLES_DIR.join('source_with_non_ruby_files')]
13
13
  end
14
14
 
15
15
  let(:expected_default_directive) do
@@ -17,32 +17,35 @@ RSpec.describe Reek::Configuration::AppConfiguration do
17
17
  end
18
18
 
19
19
  let(:expected_directory_directives) do
20
- { SAMPLES_PATH.join('three_clean_files') =>
20
+ { SAMPLES_DIR.join('three_clean_files') =>
21
21
  { Reek::SmellDetectors::UtilityFunction => { 'enabled' => false } } }
22
22
  end
23
23
 
24
24
  let(:default_directive_value) do
25
- { 'IrresponsibleModule' => { 'enabled' => false } }
25
+ { described_class::DETECTORS_KEY =>
26
+ { 'IrresponsibleModule' => { 'enabled' => false } } }
26
27
  end
27
28
 
28
29
  let(:directory_directives_value) do
29
- { 'samples/three_clean_files' =>
30
- { 'UtilityFunction' => { 'enabled' => false } } }
30
+ { described_class::DIRECTORIES_KEY =>
31
+ { 'samples/three_clean_files' =>
32
+ { 'UtilityFunction' => { 'enabled' => false } } } }
31
33
  end
32
34
 
33
35
  let(:exclude_paths_value) do
34
- ['samples/two_smelly_files',
35
- 'samples/source_with_non_ruby_files']
36
+ { described_class::EXCLUDE_PATHS_KEY =>
37
+ ['samples/two_smelly_files',
38
+ 'samples/source_with_non_ruby_files'] }
36
39
  end
37
40
 
38
41
  let(:combined_value) do
39
42
  directory_directives_value.
40
43
  merge(default_directive_value).
41
- merge('exclude_paths' => exclude_paths_value)
44
+ merge(exclude_paths_value)
42
45
  end
43
46
 
44
47
  describe '#from_path' do
45
- let(:full_configuration_path) { CONFIG_PATH.join('full_configuration.reek') }
48
+ let(:full_configuration_path) { CONFIGURATION_DIR.join('full_configuration.reek') }
46
49
 
47
50
  it 'properly loads configuration and processes it' do
48
51
  config = described_class.from_path full_configuration_path
@@ -75,36 +78,40 @@ RSpec.describe Reek::Configuration::AppConfiguration do
75
78
  end
76
79
 
77
80
  describe '#directive_for' do
78
- context 'multiple directory directives and no default directive present' do
81
+ context 'with multiple directory directives and no default directive present' do
79
82
  let(:source_via) { 'samples/three_clean_files/dummy.rb' }
80
- let(:baz_config) { { Reek::SmellDetectors::IrresponsibleModule => { enabled: false } } }
81
- let(:bang_config) { { Reek::SmellDetectors::Attribute => { enabled: true } } }
83
+ let(:baz_config) { { IrresponsibleModule: { enabled: false } } }
84
+ let(:bang_config) { { Attribute: { enabled: true } } }
85
+ let(:expected_result) { { Reek::SmellDetectors::Attribute => { enabled: true } } }
82
86
 
83
87
  let(:directory_directives) do
84
- {
85
- 'samples/two_smelly_files' => baz_config,
86
- 'samples/three_clean_files' => bang_config
87
- }
88
+ { described_class::DIRECTORIES_KEY =>
89
+ {
90
+ 'samples/two_smelly_files' => baz_config,
91
+ 'samples/three_clean_files' => bang_config
92
+ } }
88
93
  end
89
94
 
90
95
  it 'returns the corresponding directive' do
91
96
  configuration = described_class.from_hash directory_directives
92
- expect(configuration.directive_for(source_via)).to eq(bang_config)
97
+ expect(configuration.directive_for(source_via)).to eq expected_result
93
98
  end
94
99
  end
95
100
 
96
- context 'directory directive and default directive present' do
101
+ context 'with directory directive and default directive present' do
97
102
  let(:directory) { 'spec/samples/two_smelly_files/' }
98
- let(:directory_config) { { Reek::SmellDetectors::TooManyStatements => { max_statements: 8 } } }
99
- let(:directory_directives) { { directory => directory_config } }
100
- let(:default_directive) do
103
+ let(:source_via) { "#{directory}/dummy.rb" }
104
+
105
+ let(:configuration_as_hash) do
101
106
  {
102
- Reek::SmellDetectors::IrresponsibleModule => { enabled: false },
103
- Reek::SmellDetectors::TooManyStatements => { max_statements: 15 }
107
+ described_class::DIRECTORIES_KEY =>
108
+ { directory => { TooManyStatements: { max_statements: 8 } } },
109
+ described_class::DETECTORS_KEY => {
110
+ IrresponsibleModule: { enabled: false },
111
+ TooManyStatements: { max_statements: 15 }
112
+ }
104
113
  }
105
114
  end
106
- let(:source_via) { "#{directory}/dummy.rb" }
107
- let(:configuration_as_hash) { directory_directives.merge(default_directive) }
108
115
 
109
116
  it 'returns the directory directive with the default directive reverse-merged' do
110
117
  configuration = described_class.from_hash configuration_as_hash
@@ -116,18 +123,24 @@ RSpec.describe Reek::Configuration::AppConfiguration do
116
123
  end
117
124
  end
118
125
 
119
- context 'no directory directive but a default directive present' do
126
+ context 'with a path not covered by a directory directive but a default directive present' do
120
127
  let(:source_via) { 'spec/samples/three_clean_files/dummy.rb' }
121
- let(:default_directive) { { Reek::SmellDetectors::IrresponsibleModule => { enabled: false } } }
122
- let(:attribute_config) { { Reek::SmellDetectors::Attribute => { enabled: false } } }
123
- let(:directory_directives) do
124
- { 'spec/samples/two_smelly_files' => attribute_config }
128
+
129
+ let(:configuration_as_hash) do
130
+ {
131
+ described_class::DETECTORS_KEY => {
132
+ IrresponsibleModule: { enabled: false }
133
+ },
134
+ described_class::DIRECTORIES_KEY =>
135
+ { 'spec/samples/two_smelly_files' => { Attribute: { enabled: false } } }
136
+ }
125
137
  end
126
- let(:configuration_as_hash) { directory_directives.merge(default_directive) }
138
+
139
+ let(:expected_result) { { Reek::SmellDetectors::IrresponsibleModule => { enabled: false } } }
127
140
 
128
141
  it 'returns the default directive' do
129
142
  configuration = described_class.from_hash configuration_as_hash
130
- expect(configuration.directive_for(source_via)).to eq(default_directive)
143
+ expect(configuration.directive_for(source_via)).to eq expected_result
131
144
  end
132
145
  end
133
146
  end
@@ -2,9 +2,13 @@ require 'fileutils'
2
2
  require 'pathname'
3
3
  require 'tmpdir'
4
4
  require_relative '../../spec_helper'
5
+ require_lib 'reek/configuration/app_configuration'
5
6
 
6
7
  RSpec.describe Reek::Configuration::ConfigurationFileFinder do
7
8
  describe '.find' do
9
+ let(:regular_configuration_dir) { CONFIGURATION_DIR.join('regular_configuration') }
10
+ let(:regular_configuration_file) { regular_configuration_dir.join('.reek.yml') }
11
+
8
12
  it 'returns any explicitely passed path' do
9
13
  path = Pathname.new 'foo/bar'
10
14
  found = described_class.find(path: path)
@@ -13,42 +17,44 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
13
17
 
14
18
  it 'prefers an explicitely passed path over a file in current dir' do
15
19
  path = Pathname.new 'foo/bar'
16
- found = described_class.find(path: path, current: SAMPLES_PATH)
20
+ found = described_class.find(path: path, current: regular_configuration_dir)
17
21
  expect(found).to eq(path)
18
22
  end
19
23
 
20
24
  it 'returns the file in current dir if path is not set' do
21
- found = described_class.find(current: SAMPLES_PATH)
22
- expect(found).to eq(SAMPLES_PATH.join('exceptions.reek'))
25
+ found = described_class.find(current: regular_configuration_dir)
26
+ expect(found).to eq(regular_configuration_file)
23
27
  end
24
28
 
25
29
  it 'returns the file in a parent dir if none in current dir' do
26
- Dir.mktmpdir(nil, SAMPLES_PATH) do |tempdir|
27
- found = described_class.find(current: Pathname.new(tempdir))
28
- expect(found).to eq(SAMPLES_PATH.join('exceptions.reek'))
29
- end
30
+ empty_sub_directory = CONFIGURATION_DIR.join('regular_configuration').join('empty_sub_directory')
31
+ found = described_class.find(current: empty_sub_directory)
32
+ expect(found).to eq(regular_configuration_file)
30
33
  end
31
34
 
32
- it 'returns the file even if it’s just ‘.reek’' do
33
- single_configuration_file_dir = CONFIG_PATH.join('single_configuration_file')
34
- found = described_class.find(current: single_configuration_file_dir)
35
- expect(found).to eq(single_configuration_file_dir.join('.reek'))
35
+ it 'skips files ending in .reek.yml in current dir' do
36
+ Dir.mktmpdir(nil, regular_configuration_dir) do |tempdir|
37
+ current = Pathname.new(tempdir)
38
+ bad_config = current.join('ignoreme.reek.yml')
39
+ FileUtils.touch bad_config
40
+ found = described_class.find(current: Pathname.new(tempdir))
41
+ expect(found).to eq(regular_configuration_file)
42
+ end
36
43
  end
37
44
 
38
45
  it 'returns the file in home if traversing from the current dir fails' do
39
46
  skip_if_a_config_in_tempdir
40
47
 
41
- Dir.mktmpdir(nil, SAMPLES_PATH) do |tempdir|
42
- found = described_class.find(current: Pathname.new(tempdir))
43
- expect(found).to eq(SAMPLES_PATH.join('exceptions.reek'))
48
+ Dir.mktmpdir do |tempdir|
49
+ found = described_class.find(current: Pathname.new(tempdir), home: regular_configuration_dir)
50
+ expect(found).to eq(regular_configuration_file)
44
51
  end
45
52
  end
46
53
 
47
54
  it 'prefers the file in :current over one in :home' do
48
- found = described_class.find(current: SAMPLES_PATH, home: CONFIG_PATH)
49
- file_in_current = SAMPLES_PATH.join('exceptions.reek')
50
-
51
- expect(found).to eq(file_in_current)
55
+ home_dir = CONFIGURATION_DIR.join('home')
56
+ found = described_class.find(current: regular_configuration_dir, home: home_dir)
57
+ expect(found).to eq(regular_configuration_file)
52
58
  end
53
59
 
54
60
  it 'returns nil when there are no files to find' do
@@ -68,12 +74,10 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
68
74
  skip_if_a_config_in_tempdir
69
75
 
70
76
  Dir.mktmpdir do |tempdir|
71
- dir = Pathname.new(tempdir)
72
- subdir = dir.join('subdir')
73
-
74
- FileUtils.mkdir(subdir)
77
+ current = Pathname.new(tempdir)
78
+ home = SAMPLES_DIR.join('no_config_file')
75
79
 
76
- found = described_class.find(current: subdir, home: dir)
80
+ found = described_class.find(current: current, home: home)
77
81
 
78
82
  expect(found).to be_nil
79
83
  end
@@ -81,7 +85,7 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
81
85
 
82
86
  it 'works with paths that need escaping' do
83
87
  Dir.mktmpdir("ma\ngic d*r") do |tempdir|
84
- config = Pathname.new("#{tempdir}/ma\ngic f*le.reek")
88
+ config = Pathname.new("#{tempdir}/.reek.yml")
85
89
  subdir = Pathname.new("#{tempdir}/ma\ngic subd*r")
86
90
  FileUtils.touch config
87
91
  FileUtils.mkdir subdir
@@ -89,42 +93,122 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
89
93
  expect(found).to eq(config)
90
94
  end
91
95
  end
92
-
93
- context 'more than one configuration file' do
94
- let(:path) { CONFIG_PATH.join('more_than_one_configuration_file') }
95
-
96
- it 'prints a message on STDERR' do
97
- expected_message = "Error: Found multiple configuration files 'regular.reek', 'todo.reek'"
98
- expect do
99
- begin
100
- described_class.find(current: path)
101
- rescue SystemExit
102
- end
103
- end.to output(/#{expected_message}/).to_stderr
104
- end
105
-
106
- it 'exits' do
107
- Reek::CLI::Silencer.silently do
108
- expect do
109
- described_class.find(current: path)
110
- end.to raise_error(SystemExit)
111
- end
112
- end
113
- end
114
96
  end
115
97
 
116
98
  describe '.load_from_file' do
117
99
  let(:sample_configuration_loaded) do
118
100
  {
119
- 'UncommunicativeVariableName' => { 'enabled' => false },
120
- 'UncommunicativeMethodName' => { 'enabled' => false }
101
+ Reek::Configuration::AppConfiguration::DETECTORS_KEY => {
102
+ 'UncommunicativeVariableName' => { 'enabled' => false },
103
+ 'UncommunicativeMethodName' => { 'enabled' => false }
104
+ }
121
105
  }
122
106
  end
123
107
 
124
108
  it 'loads the configuration from given file' do
125
- configuration = described_class.load_from_file(CONFIG_PATH.join('full_mask.reek'))
109
+ configuration = described_class.load_from_file(CONFIGURATION_DIR.join('full_mask.reek'))
126
110
  expect(configuration).to eq(sample_configuration_loaded)
127
111
  end
112
+
113
+ context 'with exclude, accept and reject settings' do
114
+ context 'when configuring top level detectors' do
115
+ let(:configuration) do
116
+ described_class.
117
+ load_from_file(CONFIGURATION_DIR.join('accepts_rejects_and_excludes_for_detectors.reek.yml')).
118
+ fetch(Reek::Configuration::AppConfiguration::DETECTORS_KEY)
119
+ end
120
+
121
+ let(:expected) do
122
+ {
123
+ 'UnusedPrivateMethod' => { 'exclude' => [/exclude regexp/] },
124
+ 'UncommunicativeMethodName' => { 'reject' => ['reject name'],
125
+ 'accept' => ['accept name'] },
126
+ 'UncommunicativeModuleName' => { 'reject' => ['reject name 1', 'reject name 2'],
127
+ 'accept' => ['accept name 1', 'accept name 2'] },
128
+ 'UncommunicativeParameterName' => { 'reject' => ['reject name', /reject regexp/],
129
+ 'accept' => ['accept name', /accept regexp/] },
130
+ 'UncommunicativeVariableName' => { 'reject' => [/^reject regexp$/],
131
+ 'accept' => [/accept(.*)regexp/] }
132
+ }
133
+ end
134
+
135
+ it 'converts marked strings to regexes' do
136
+ expect(configuration['UnusedPrivateMethod']).to eq(expected['UnusedPrivateMethod'])
137
+ end
138
+
139
+ it 'leaves regular single strings untouched' do
140
+ expect(configuration['UncommunicativeMethodName']).to eq(expected['UncommunicativeMethodName'])
141
+ end
142
+
143
+ it 'leaves regular multiple strings untouched' do
144
+ expect(configuration['UncommunicativeModuleName']).to eq(expected['UncommunicativeModuleName'])
145
+ end
146
+
147
+ it 'allows mixing of regular strings and marked strings' do
148
+ expect(configuration['UncommunicativeParameterName']).to eq(expected['UncommunicativeParameterName'])
149
+ end
150
+
151
+ it 'converts more complex marked strings correctly to regexes' do
152
+ expect(configuration['UncommunicativeVariableName']).to eq(expected['UncommunicativeVariableName'])
153
+ end
154
+ end
155
+
156
+ context 'when configuring directory directives' do
157
+ let(:directory_name) { 'app/controllers' }
158
+ let(:configuration) do
159
+ described_class.
160
+ load_from_file(CONFIGURATION_DIR.join('accepts_rejects_and_excludes_for_directory_directives.reek.yml')).
161
+ fetch(Reek::Configuration::AppConfiguration::DIRECTORIES_KEY)
162
+ end
163
+
164
+ let(:expected) do
165
+ {
166
+ directory_name => {
167
+ 'UnusedPrivateMethod' => { 'exclude' => [/exclude regexp/] },
168
+ 'UncommunicativeMethodName' => { 'reject' => ['reject name'],
169
+ 'accept' => ['accept name'] },
170
+ 'UncommunicativeModuleName' => { 'reject' => ['reject name 1', 'reject name 2'],
171
+ 'accept' => ['accept name 1', 'accept name 2'] },
172
+ 'UncommunicativeParameterName' => { 'reject' => ['reject name', /reject regexp/],
173
+ 'accept' => ['accept name', /accept regexp/] },
174
+ 'UncommunicativeVariableName' => { 'reject' => [/^reject regexp$/],
175
+ 'accept' => [/accept(.*)regexp/] }
176
+ }
177
+ }
178
+ end
179
+
180
+ it 'converts marked strings to regexes' do
181
+ expect(configuration[directory_name]['UnusedPrivateMethod']).
182
+ to eq(expected[directory_name]['UnusedPrivateMethod'])
183
+ end
184
+
185
+ it 'leaves regular single strings untouched' do
186
+ expect(configuration[directory_name]['UncommunicativeMethodName']).
187
+ to eq(expected[directory_name]['UncommunicativeMethodName'])
188
+ end
189
+
190
+ it 'leaves regular multiple strings untouched' do
191
+ expect(configuration[directory_name]['UncommunicativeModuleName']).
192
+ to eq(expected[directory_name]['UncommunicativeModuleName'])
193
+ end
194
+
195
+ it 'allows mixing of regular strings and marked strings' do
196
+ expect(configuration[directory_name]['UncommunicativeParameterName']).
197
+ to eq(expected[directory_name]['UncommunicativeParameterName'])
198
+ end
199
+
200
+ it 'converts more complex marked strings correctly to regexes' do
201
+ expect(configuration[directory_name]['UncommunicativeVariableName']).
202
+ to eq(expected[directory_name]['UncommunicativeVariableName'])
203
+ end
204
+ end
205
+ end
206
+
207
+ it 'returns blank hash when no file is found' do
208
+ config = described_class.load_from_file(nil)
209
+
210
+ expect(config).to eq({})
211
+ end
128
212
  end
129
213
 
130
214
  private
@@ -6,7 +6,7 @@ RSpec.describe Reek::Configuration::DefaultDirective do
6
6
  let(:directives) { {}.extend(described_class) }
7
7
 
8
8
  it 'adds a smell configuration' do
9
- directives.add :UncommunicativeVariableName, enabled: false
9
+ directives.add(UncommunicativeVariableName: { enabled: false })
10
10
  expect(directives).to eq(Reek::SmellDetectors::UncommunicativeVariableName => { enabled: false })
11
11
  end
12
12
  end
@@ -1,4 +1,5 @@
1
1
  require_relative '../../spec_helper'
2
+ require_lib 'reek/errors/config_file_error'
2
3
  require_lib 'reek/configuration/directory_directives'
3
4
 
4
5
  RSpec.describe Reek::Configuration::DirectoryDirectives do
@@ -13,13 +14,13 @@ RSpec.describe Reek::Configuration::DirectoryDirectives do
13
14
  end
14
15
  let(:source_via) { 'foo/bar/bang/dummy.rb' }
15
16
 
16
- context 'our source is in a directory for which we have a directive' do
17
+ context 'when our source is in a directory for which we have a directive' do
17
18
  it 'returns the corresponding directive' do
18
19
  expect(directives.directive_for(source_via)).to eq(bang_config)
19
20
  end
20
21
  end
21
22
 
22
- context 'our source is not in a directory for which we have a directive' do
23
+ context 'when our source is not in a directory for which we have a directive' do
23
24
  it 'returns nil' do
24
25
  expect(directives.directive_for('does/not/exist')).to eq(nil)
25
26
  end
@@ -31,13 +32,11 @@ RSpec.describe Reek::Configuration::DirectoryDirectives do
31
32
  {}.extend(described_class)
32
33
  end
33
34
 
34
- context 'one of given paths is a file' do
35
- let(:file_as_path) { SAMPLES_PATH.join('inline.rb') }
35
+ context 'when one of given paths is a file' do
36
+ let(:file_as_path) { SAMPLES_DIR.join('smelly_source').join('inline.rb') }
36
37
 
37
38
  it 'raises an error' do
38
- Reek::CLI::Silencer.silently do
39
- expect { directives.add(file_as_path, {}) }.to raise_error(SystemExit)
40
- end
39
+ expect { directives.add(file_as_path => nil) }.to raise_error(Reek::Errors::ConfigFileError)
41
40
  end
42
41
  end
43
42
  end
@@ -1,18 +1,18 @@
1
1
  require_relative '../../spec_helper'
2
+ require_lib 'reek/errors/config_file_error'
2
3
  require_lib 'reek/configuration/excluded_paths'
3
4
 
4
5
  RSpec.describe Reek::Configuration::ExcludedPaths do
5
6
  describe '#add' do
6
7
  let(:exclusions) { [].extend(described_class) }
7
8
 
8
- context 'one of given paths is a file' do
9
- let(:file_as_path) { SAMPLES_PATH.join('inline.rb') }
10
- let(:paths) { [SAMPLES_PATH, file_as_path] }
9
+ context 'when one of given paths is a file' do
10
+ let(:smelly_source_dir) { SAMPLES_DIR.join('smelly_source') }
11
+ let(:file_as_path) { smelly_source_dir.join('inline.rb') }
12
+ let(:paths) { [smelly_source_dir, file_as_path] }
11
13
 
12
14
  it 'raises an error if one of the given paths is a file' do
13
- Reek::CLI::Silencer.silently do
14
- expect { exclusions.add(paths) }.to raise_error(SystemExit)
15
- end
15
+ expect { exclusions.add(paths) }.to raise_error(Reek::Errors::ConfigFileError)
16
16
  end
17
17
  end
18
18
  end