reek 4.7.1 → 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 (260) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +17 -12
  3. data/.rubocop.yml +36 -7
  4. data/.simplecov +1 -0
  5. data/.travis.yml +3 -9
  6. data/.yardopts +1 -1
  7. data/CHANGELOG.md +59 -0
  8. data/CONTRIBUTING.md +1 -1
  9. data/Gemfile +5 -5
  10. data/README.md +134 -104
  11. data/Rakefile +16 -3
  12. data/bin/reek +1 -3
  13. data/docs/API.md +2 -9
  14. data/docs/Basic-Smell-Options.md +51 -11
  15. data/docs/Code-Smells.md +1 -1
  16. data/docs/Command-Line-Options.md +14 -4
  17. data/docs/Duplicate-Method-Call.md +49 -1
  18. data/docs/Feature-Envy.md +44 -0
  19. data/docs/How-To-Write-New-Detectors.md +7 -7
  20. data/docs/Instance-Variable-Assumption.md +1 -1
  21. data/docs/{Prima-Donna-Method.md → Missing-Safe-Method.md} +11 -9
  22. data/docs/Rake-Task.md +1 -1
  23. data/docs/Reek-4-to-Reek-5-migration.md +193 -0
  24. data/docs/Reek-Driven-Development.md +1 -1
  25. data/docs/Uncommunicative-Method-Name.md +45 -6
  26. data/docs/Uncommunicative-Module-Name.md +49 -7
  27. data/docs/Uncommunicative-Parameter-Name.md +43 -5
  28. data/docs/Uncommunicative-Variable-Name.md +73 -2
  29. data/docs/Unused-Private-Method.md +3 -3
  30. data/docs/defaults.reek.yml +129 -0
  31. data/docs/yard_plugin.rb +1 -0
  32. data/features/command_line_interface/basic_usage.feature +2 -2
  33. data/features/command_line_interface/options.feature +46 -4
  34. data/features/command_line_interface/show_progress.feature +4 -4
  35. data/features/command_line_interface/smell_selection.feature +1 -1
  36. data/features/command_line_interface/smells_count.feature +6 -6
  37. data/features/command_line_interface/stdin.feature +30 -8
  38. data/features/configuration_files/accept_setting.feature +45 -28
  39. data/features/configuration_files/directory_specific_directives.feature +80 -75
  40. data/features/configuration_files/exclude_directives.feature +11 -10
  41. data/features/configuration_files/exclude_paths_directives.feature +4 -4
  42. data/features/configuration_files/masking_smells.feature +38 -9
  43. data/features/configuration_files/mix_accept_reject_setting.feature +31 -28
  44. data/features/configuration_files/reject_setting.feature +52 -41
  45. data/features/configuration_files/schema_validation.feature +59 -0
  46. data/features/configuration_files/unused_private_method.feature +18 -16
  47. data/features/configuration_loading.feature +53 -10
  48. data/features/configuration_via_source_comments/erroneous_source_comments.feature +3 -3
  49. data/features/configuration_via_source_comments/well_formed_source_comments.feature +2 -2
  50. data/features/locales.feature +32 -0
  51. data/features/rake_task/rake_task.feature +58 -18
  52. data/features/reports/json.feature +3 -3
  53. data/features/reports/reports.feature +34 -34
  54. data/features/reports/yaml.feature +3 -3
  55. data/features/rspec_matcher.feature +40 -0
  56. data/features/samples.feature +287 -287
  57. data/features/step_definitions/reek_steps.rb +2 -2
  58. data/features/step_definitions/sample_file_steps.rb +9 -4
  59. data/features/support/env.rb +2 -11
  60. data/features/todo_list.feature +26 -23
  61. data/lib/reek/ast/builder.rb +1 -1
  62. data/lib/reek/ast/node.rb +40 -58
  63. data/lib/reek/ast/object_refs.rb +1 -1
  64. data/lib/reek/ast/reference_collector.rb +2 -4
  65. data/lib/reek/ast/sexp_extensions/case.rb +1 -1
  66. data/lib/reek/ast/sexp_extensions/if.rb +8 -1
  67. data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -1
  68. data/lib/reek/ast/sexp_extensions/methods.rb +4 -6
  69. data/lib/reek/ast/sexp_extensions/send.rb +0 -4
  70. data/lib/reek/cli/application.rb +4 -3
  71. data/lib/reek/cli/command/report_command.rb +1 -2
  72. data/lib/reek/cli/command/todo_list_command.rb +8 -8
  73. data/lib/reek/cli/options.rb +31 -16
  74. data/lib/reek/cli/silencer.rb +14 -3
  75. data/lib/reek/code_comment.rb +14 -16
  76. data/lib/reek/configuration/app_configuration.rb +32 -27
  77. data/lib/reek/configuration/configuration_converter.rb +110 -0
  78. data/lib/reek/configuration/configuration_file_finder.rb +16 -41
  79. data/lib/reek/configuration/configuration_validator.rb +12 -23
  80. data/lib/reek/configuration/default_directive.rb +17 -3
  81. data/lib/reek/configuration/directory_directives.rb +17 -11
  82. data/lib/reek/configuration/excluded_paths.rb +1 -1
  83. data/lib/reek/configuration/rake_task_converter.rb +29 -0
  84. data/lib/reek/configuration/schema.yml +210 -0
  85. data/lib/reek/configuration/schema_validator.rb +38 -0
  86. data/lib/reek/context/attribute_context.rb +3 -3
  87. data/lib/reek/context/code_context.rb +47 -43
  88. data/lib/reek/context/ghost_context.rb +0 -2
  89. data/lib/reek/context/method_context.rb +22 -15
  90. data/lib/reek/context/module_context.rb +5 -9
  91. data/lib/reek/context/root_context.rb +0 -4
  92. data/lib/reek/context/send_context.rb +2 -2
  93. data/lib/reek/context_builder.rb +43 -44
  94. data/lib/reek/detector_repository.rb +11 -11
  95. data/lib/reek/documentation_link.rb +28 -0
  96. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +14 -13
  97. data/lib/reek/errors/bad_detector_in_comment_error.rb +12 -11
  98. data/lib/reek/errors/base_error.rb +3 -0
  99. data/lib/reek/errors/config_file_error.rb +11 -0
  100. data/lib/reek/errors/encoding_error.rb +43 -0
  101. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +13 -12
  102. data/lib/reek/errors/incomprehensible_source_error.rb +22 -24
  103. data/lib/reek/errors/syntax_error.rb +41 -0
  104. data/lib/reek/examiner.rb +24 -26
  105. data/lib/reek/logging_error_handler.rb +7 -5
  106. data/lib/reek/rake/task.rb +8 -4
  107. data/lib/reek/report/base_report.rb +8 -12
  108. data/lib/reek/report/code_climate/code_climate_configuration.rb +1 -1
  109. data/lib/reek/report/code_climate/code_climate_configuration.yml +6 -10
  110. data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
  111. data/lib/reek/report/heading_formatter.rb +54 -0
  112. data/lib/reek/report/json_report.rb +1 -1
  113. data/lib/reek/report/location_formatter.rb +40 -0
  114. data/lib/reek/report/progress_formatter.rb +79 -0
  115. data/lib/reek/report/simple_warning_formatter.rb +34 -0
  116. data/lib/reek/report/text_report.rb +1 -2
  117. data/lib/reek/report/xml_report.rb +3 -3
  118. data/lib/reek/report/yaml_report.rb +1 -1
  119. data/lib/reek/report.rb +15 -10
  120. data/lib/reek/smell_configuration.rb +2 -2
  121. data/lib/reek/smell_detectors/attribute.rb +5 -11
  122. data/lib/reek/smell_detectors/base_detector.rb +30 -26
  123. data/lib/reek/smell_detectors/boolean_parameter.rb +3 -5
  124. data/lib/reek/smell_detectors/class_variable.rb +5 -14
  125. data/lib/reek/smell_detectors/control_parameter.rb +18 -33
  126. data/lib/reek/smell_detectors/data_clump.rb +15 -9
  127. data/lib/reek/smell_detectors/duplicate_method_call.rb +23 -17
  128. data/lib/reek/smell_detectors/feature_envy.rb +9 -7
  129. data/lib/reek/smell_detectors/instance_variable_assumption.rb +14 -23
  130. data/lib/reek/smell_detectors/irresponsible_module.rb +5 -12
  131. data/lib/reek/smell_detectors/long_parameter_list.rb +10 -7
  132. data/lib/reek/smell_detectors/long_yield_list.rb +10 -7
  133. data/lib/reek/smell_detectors/manual_dispatch.rb +4 -5
  134. data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +20 -20
  135. data/lib/reek/smell_detectors/module_initialize.rb +3 -5
  136. data/lib/reek/smell_detectors/nested_iterators.rb +16 -24
  137. data/lib/reek/smell_detectors/nil_check.rb +8 -15
  138. data/lib/reek/smell_detectors/repeated_conditional.rb +13 -11
  139. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +7 -8
  140. data/lib/reek/smell_detectors/too_many_constants.rb +10 -9
  141. data/lib/reek/smell_detectors/too_many_instance_variables.rb +10 -6
  142. data/lib/reek/smell_detectors/too_many_methods.rb +11 -7
  143. data/lib/reek/smell_detectors/too_many_statements.rb +10 -6
  144. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +10 -11
  145. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +14 -18
  146. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +17 -22
  147. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +26 -27
  148. data/lib/reek/smell_detectors/unused_parameters.rb +4 -6
  149. data/lib/reek/smell_detectors/unused_private_method.rb +11 -18
  150. data/lib/reek/smell_detectors/utility_function.rb +12 -16
  151. data/lib/reek/smell_detectors.rb +1 -2
  152. data/lib/reek/smell_warning.rb +15 -8
  153. data/lib/reek/source/source_code.rb +57 -58
  154. data/lib/reek/source/source_locator.rb +8 -8
  155. data/lib/reek/spec/should_reek.rb +2 -2
  156. data/lib/reek/spec/should_reek_of.rb +9 -16
  157. data/lib/reek/spec/should_reek_only_of.rb +4 -4
  158. data/lib/reek/spec.rb +6 -6
  159. data/lib/reek/tree_dresser.rb +8 -8
  160. data/lib/reek/version.rb +1 -1
  161. data/reek.gemspec +5 -7
  162. data/samples/checkstyle.xml +1 -1
  163. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
  164. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
  165. data/samples/configuration/full_configuration.reek +8 -4
  166. data/samples/configuration/full_mask.reek +5 -4
  167. data/samples/configuration/partial_mask.reek +3 -2
  168. data/samples/configuration/regular_configuration/.reek.yml +4 -0
  169. data/samples/paths.rb +5 -4
  170. data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
  171. data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
  172. data/spec/factories/factories.rb +2 -13
  173. data/spec/reek/ast/node_spec.rb +103 -10
  174. data/spec/reek/ast/reference_collector_spec.rb +1 -1
  175. data/spec/reek/ast/sexp_extensions_spec.rb +14 -34
  176. data/spec/reek/cli/application_spec.rb +52 -42
  177. data/spec/reek/cli/command/todo_list_command_spec.rb +6 -4
  178. data/spec/reek/cli/silencer_spec.rb +28 -0
  179. data/spec/reek/code_comment_spec.rb +31 -38
  180. data/spec/reek/configuration/app_configuration_spec.rb +46 -33
  181. data/spec/reek/configuration/configuration_file_finder_spec.rb +133 -51
  182. data/spec/reek/configuration/default_directive_spec.rb +1 -1
  183. data/spec/reek/configuration/directory_directives_spec.rb +6 -7
  184. data/spec/reek/configuration/excluded_paths_spec.rb +6 -6
  185. data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
  186. data/spec/reek/configuration/schema_validator_spec.rb +165 -0
  187. data/spec/reek/context/code_context_spec.rb +70 -106
  188. data/spec/reek/context/ghost_context_spec.rb +9 -9
  189. data/spec/reek/context/method_context_spec.rb +2 -2
  190. data/spec/reek/context/module_context_spec.rb +3 -3
  191. data/spec/reek/context/root_context_spec.rb +1 -1
  192. data/spec/reek/context_builder_spec.rb +20 -0
  193. data/spec/reek/documentation_link_spec.rb +20 -0
  194. data/spec/reek/errors/base_error_spec.rb +13 -0
  195. data/spec/reek/examiner_spec.rb +136 -29
  196. data/spec/reek/rake/task_spec.rb +25 -2
  197. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +82 -80
  198. data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +6 -6
  199. data/spec/reek/report/json_report_spec.rb +13 -46
  200. data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
  201. data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
  202. data/spec/reek/report/text_report_spec.rb +4 -4
  203. data/spec/reek/report/xml_report_spec.rb +3 -3
  204. data/spec/reek/report/yaml_report_spec.rb +9 -38
  205. data/spec/reek/report_spec.rb +3 -3
  206. data/spec/reek/smell_detectors/base_detector_spec.rb +4 -5
  207. data/spec/reek/smell_detectors/boolean_parameter_spec.rb +2 -2
  208. data/spec/reek/smell_detectors/class_variable_spec.rb +26 -32
  209. data/spec/reek/smell_detectors/control_parameter_spec.rb +34 -4
  210. data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +3 -3
  211. data/spec/reek/smell_detectors/feature_envy_spec.rb +47 -2
  212. data/spec/reek/smell_detectors/irresponsible_module_spec.rb +0 -11
  213. data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +10 -10
  214. data/spec/reek/smell_detectors/module_initialize_spec.rb +14 -0
  215. data/spec/reek/smell_detectors/nested_iterators_spec.rb +1 -1
  216. data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
  217. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
  218. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
  219. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
  220. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +36 -15
  221. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +9 -9
  222. data/spec/reek/smell_detectors/unused_parameters_spec.rb +3 -3
  223. data/spec/reek/smell_detectors/unused_private_method_spec.rb +21 -10
  224. data/spec/reek/smell_detectors/utility_function_spec.rb +57 -5
  225. data/spec/reek/smell_warning_spec.rb +12 -8
  226. data/spec/reek/source/source_code_spec.rb +22 -21
  227. data/spec/reek/source/source_locator_spec.rb +17 -17
  228. data/spec/reek/spec/should_reek_of_spec.rb +25 -29
  229. data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
  230. data/spec/reek/spec/should_reek_spec.rb +8 -8
  231. data/spec/reek/spec/smell_matcher_spec.rb +23 -23
  232. data/spec/reek/tree_dresser_spec.rb +12 -17
  233. data/spec/spec_helper.rb +6 -17
  234. data/tasks/configuration.rake +8 -5
  235. metadata +74 -41
  236. data/defaults.reek +0 -131
  237. data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
  238. data/lib/reek/report/formatter/heading_formatter.rb +0 -52
  239. data/lib/reek/report/formatter/location_formatter.rb +0 -42
  240. data/lib/reek/report/formatter/progress_formatter.rb +0 -81
  241. data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
  242. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -36
  243. data/lib/reek/report/formatter.rb +0 -33
  244. data/lib/reek/smell_detectors/syntax.rb +0 -37
  245. data/samples/configuration/non_public_modifiers_mask.reek +0 -3
  246. data/samples/smelly_with_inline_mask.rb +0 -8
  247. data/samples/smelly_with_modifiers.rb +0 -12
  248. data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
  249. data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
  250. data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
  251. /data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
  252. /data/samples/{clean.rb → clean_source/clean.rb} +0 -0
  253. /data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
  254. /data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
  255. /data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
  256. /data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
  257. /data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
  258. /data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
  259. /data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
  260. /data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
@@ -3,20 +3,25 @@ Feature: `reject` configuration setting
3
3
  As a user
4
4
  I want to be able to reject specific patterns and names to include them into reporting
5
5
 
6
- Scenario: reject names as list and as single item
6
+ Scenario: reject names
7
7
  Given a file named "config.reek" with:
8
8
  """
9
9
  ---
10
- UncommunicativeMethodName:
11
- reject:
12
- - awesome_helper
13
- - little_helper
14
- UncommunicativeParameterName:
15
- reject:
16
- - solid_argument
17
- - nifty_argument
18
- UncommunicativeModuleName:
19
- reject: Dummy
10
+ detectors:
11
+ UncommunicativeMethodName:
12
+ reject:
13
+ - awesome_helper
14
+ - little_helper
15
+ UncommunicativeParameterName:
16
+ reject:
17
+ - solid_argument
18
+ - nifty_argument
19
+ UncommunicativeModuleName:
20
+ reject:
21
+ - Dummy
22
+ UncommunicativeVariableName:
23
+ reject:
24
+ - fine_name
20
25
  """
21
26
  And a file named "smelly.rb" with:
22
27
  """
@@ -28,51 +33,57 @@ Feature: `reject` configuration setting
28
33
  def little_helper(nifty_argument); nifty_argument; end
29
34
  # Should not report UncommunicativeMethodName and UncommunicativeParameterName
30
35
  def meth(argument); argument; end
36
+ fine_name = 2 # Should report UncommunicativeMethodName
37
+ other_name = 2 # Should not report UncommunicativeMethodName
31
38
  end
32
39
  """
33
- When I run `reek -c config.reek smelly.rb`
40
+ When I run reek -c config.reek smelly.rb
34
41
  Then it reports:
35
42
  """
36
- smelly.rb -- 5 warnings:
37
- [4]:UncommunicativeMethodName: Dummy#awesome_helper has the name 'awesome_helper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
38
- [6]:UncommunicativeMethodName: Dummy#little_helper has the name 'little_helper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
39
- [2]:UncommunicativeModuleName: Dummy has the name 'Dummy' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Module-Name.md]
40
- [4]:UncommunicativeParameterName: Dummy#awesome_helper has the parameter name 'solid_argument' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Parameter-Name.md]
41
- [6]:UncommunicativeParameterName: Dummy#little_helper has the parameter name 'nifty_argument' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Parameter-Name.md]
43
+ smelly.rb -- 6 warnings:
44
+ [4]:UncommunicativeMethodName: Dummy#awesome_helper has the name 'awesome_helper'
45
+ [6]:UncommunicativeMethodName: Dummy#little_helper has the name 'little_helper'
46
+ [2]:UncommunicativeModuleName: Dummy has the name 'Dummy'
47
+ [4]:UncommunicativeParameterName: Dummy#awesome_helper has the parameter name 'solid_argument'
48
+ [6]:UncommunicativeParameterName: Dummy#little_helper has the parameter name 'nifty_argument'
49
+ [9]:UncommunicativeVariableName: Dummy has the variable name 'fine_name'
42
50
  """
43
51
 
44
- Scenario: reject regexes as list and as single item
52
+ Scenario: Reject regexes
45
53
  Given a file named "config.reek" with:
46
54
  """
47
55
  ---
48
- UncommunicativeMethodName:
49
- reject: !ruby/regexp /helper/
50
- UncommunicativeParameterName:
51
- reject:
52
- - !ruby/regexp /solid/
53
- - !ruby/regexp /nifty/
54
- UncommunicativeModuleName:
55
- reject: !ruby/regexp /ummy/
56
+ detectors:
57
+ UncommunicativeMethodName:
58
+ accept:
59
+ - /oobar/
60
+ UncommunicativeParameterName:
61
+ accept:
62
+ - /ola/
63
+ UncommunicativeModuleName:
64
+ accept:
65
+ - /lassy/
66
+ UncommunicativeVariableName:
67
+ reject:
68
+ - /^fine_name/
56
69
  """
57
70
  And a file named "smelly.rb" with:
58
71
  """
59
- # Should report UncommunicativeModuleName
60
- class Dummy
61
- # Should report UncommunicativeMethodName and UncommunicativeParameterName
62
- def awesome_helper(solid_argument); solid_argument; end
63
- # Should report UncommunicativeMethodName and UncommunicativeParameterName
64
- def little_helper(nifty_argument); nifty_argument; end
72
+ # Should not report UncommunicativeModuleName
73
+ class Classy1
65
74
  # Should not report UncommunicativeMethodName and UncommunicativeParameterName
66
- def meth(argument); argument; end
75
+ def foobar1(hola1); hola1; end
76
+ # Should report UncommunicativeMethodName and UncommunicativeParameterName
77
+ def m2(a2); a2; end
78
+ fine_name = 2 # Should report UncommunicativeMethodName
79
+ my_fine_name = 2 # Should not report UncommunicativeMethodName
67
80
  end
68
81
  """
69
- When I run `reek -c config.reek smelly.rb`
82
+ When I run reek -c config.reek smelly.rb
70
83
  Then it reports:
71
84
  """
72
- smelly.rb -- 5 warnings:
73
- [4]:UncommunicativeMethodName: Dummy#awesome_helper has the name 'awesome_helper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
74
- [6]:UncommunicativeMethodName: Dummy#little_helper has the name 'little_helper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
75
- [2]:UncommunicativeModuleName: Dummy has the name 'Dummy' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Module-Name.md]
76
- [4]:UncommunicativeParameterName: Dummy#awesome_helper has the parameter name 'solid_argument' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Parameter-Name.md]
77
- [6]:UncommunicativeParameterName: Dummy#little_helper has the parameter name 'nifty_argument' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Parameter-Name.md]
85
+ smelly.rb -- 3 warnings:
86
+ [6]:UncommunicativeMethodName: Classy1#m2 has the name 'm2'
87
+ [6]:UncommunicativeParameterName: Classy1#m2 has the parameter name 'a2'
88
+ [7]:UncommunicativeVariableName: Classy1 has the variable name 'fine_name'
78
89
  """
@@ -0,0 +1,59 @@
1
+ Feature: Validate schema
2
+ In order to ensure that I am using the right configuration
3
+ As a user
4
+ I want to be notified when I am using a configuration that violates our schema
5
+
6
+ Scenario: Our generated default configuration
7
+ Given our default configuration file
8
+ And the clean file 'clean.rb'
9
+ When I run reek -c defaults.reek clean.rb
10
+ Then it succeeds
11
+ And it reports nothing
12
+
13
+ Scenario: Detectors, directories and exclude paths all mixed
14
+ Given a file named "config.reek" with:
15
+ """
16
+ ---
17
+ detectors:
18
+ IrresponsibleModule:
19
+ enabled: false
20
+ NestedIterators:
21
+ exclude:
22
+ - "MyWorker#self.class_method"
23
+ - "AnotherWorker#instance_method"
24
+ DataClump:
25
+ max_copies: 3
26
+ min_clump_size: 3
27
+
28
+ directories:
29
+ "web_app/app/controllers":
30
+ NestedIterators:
31
+ enabled: false
32
+ "web_app/app/helpers":
33
+ UtilityFunction:
34
+ enabled: false
35
+
36
+ exclude_paths:
37
+ - lib/legacy
38
+ - lib/rake/legacy_tasks
39
+ """
40
+ And the clean file 'clean.rb'
41
+ When I run reek -c config.reek clean.rb
42
+ Then it succeeds
43
+ And it reports nothing
44
+
45
+ Scenario: Invalid detector name
46
+ Given a file named "config.reek" with:
47
+ """
48
+ ---
49
+ detectors:
50
+ DoesNotExist:
51
+ enabled: true
52
+ """
53
+ And the clean file 'clean.rb'
54
+ When I run reek -c config.reek clean.rb
55
+ Then the exit status indicates an error
56
+ And stderr reports:
57
+ """
58
+ Error: We found some problems with your configuration file: [/detectors/DoesNotExist] key 'DoesNotExist:' is undefined.
59
+ """
@@ -7,12 +7,13 @@ Feature: Unused Private Method detector
7
7
  Given a file named "config.reek" with:
8
8
  """
9
9
  ---
10
- IrresponsibleModule:
11
- enabled: false
12
- UnusedPrivateMethod:
13
- enabled: true
14
- exclude:
15
- - "Outer::Awesome#foobar"
10
+ detectors:
11
+ IrresponsibleModule:
12
+ enabled: false
13
+ UnusedPrivateMethod:
14
+ enabled: true
15
+ exclude:
16
+ - Outer::Awesome#foobar
16
17
  """
17
18
  And a file named "sample.rb" with:
18
19
  """
@@ -27,23 +28,24 @@ Feature: Unused Private Method detector
27
28
  end
28
29
  end
29
30
  """
30
- When I run `reek -c config.reek sample.rb`
31
+ When I run reek -c config.reek sample.rb
31
32
  Then it reports:
32
33
  """
33
34
  sample.rb -- 1 warning:
34
- [4]:UnusedPrivateMethod: Outer::Smelly has the unused private instance method 'foobar' [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
35
+ [4]:UnusedPrivateMethod: Outer::Smelly has the unused private instance method 'foobar'
35
36
  """
36
37
 
37
38
  Scenario: Use regexes for excluding contexts
38
39
  Given a file named "config.reek" with:
39
40
  """
40
41
  ---
41
- IrresponsibleModule:
42
- enabled: false
43
- UnusedPrivateMethod:
44
- enabled: true
45
- exclude:
46
- - !ruby/regexp /(.*)wesome#foo(.*)/
42
+ detectors:
43
+ IrresponsibleModule:
44
+ enabled: false
45
+ UnusedPrivateMethod:
46
+ enabled: true
47
+ exclude:
48
+ - wesome#foo
47
49
  """
48
50
  And a file named "sample.rb" with:
49
51
  """
@@ -58,9 +60,9 @@ Feature: Unused Private Method detector
58
60
  end
59
61
  end
60
62
  """
61
- When I run `reek -c config.reek sample.rb`
63
+ When I run reek -c config.reek sample.rb
62
64
  Then it reports:
63
65
  """
64
66
  sample.rb -- 1 warning:
65
- [4]:UnusedPrivateMethod: Outer::Smelly has the unused private instance method 'foobar' [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
67
+ [4]:UnusedPrivateMethod: Outer::Smelly has the unused private instance method 'foobar'
66
68
  """
@@ -3,7 +3,7 @@ Feature: Offer different ways how to load configuration
3
3
  Reek can be configured in two ways:
4
4
  - Using the cli "-c" switch to pass a configuration file on the command line.
5
5
  - Having a Reek configuration file that is automatically found. Reek will
6
- look for a file ending in .reek in the following places, in order:
6
+ look for a file ending in .reek.yml in the following places, in order:
7
7
  - The current working directory
8
8
  - The working directory's ancestor directories, traversing all the way up
9
9
  to the root.
@@ -17,8 +17,8 @@ Feature: Offer different ways how to load configuration
17
17
  And it reports:
18
18
  """
19
19
  smelly.rb -- 2 warnings:
20
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
21
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
20
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
21
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
22
22
  """
23
23
 
24
24
  Scenario: Configuration via CLI
@@ -30,19 +30,62 @@ Feature: Offer different ways how to load configuration
30
30
 
31
31
  Scenario: Configuration file in working directory
32
32
  Given the smelly file 'smelly.rb'
33
- And a configuration file 'full_mask.reek'
33
+ And a file named ".reek.yml" with:
34
+ """
35
+ ---
36
+ detectors:
37
+ UncommunicativeMethodName:
38
+ enabled: false
39
+ UncommunicativeVariableName:
40
+ enabled: false
41
+ """
34
42
  When I run reek smelly.rb
35
43
  Then it reports no errors
36
44
  And it succeeds
37
45
 
38
- Scenario: Two opposing configuration files and we stop after the first one
39
- Given the smelly file 'smelly.rb' in a subdirectory
40
- And a configuration file 'partial_mask.reek' in a subdirectory
41
- And a configuration file 'full_mask.reek'
42
- When I run "reek smelly.rb" in a subdirectory
46
+ Scenario: Do not use the default config file when we explicitly specify one configuration file
47
+ Given the smelly file 'smelly.rb'
48
+ And a file named "config.reek" with:
49
+ """
50
+ ---
51
+ detectors:
52
+ UncommunicativeMethodName:
53
+ enabled: false
54
+ """
55
+ And a file named ".reek.yml" with:
56
+ """
57
+ ---
58
+ UncommunicativeVariableName:
59
+ enabled: false
60
+ """
61
+ When I run reek -c config.reek smelly.rb
62
+ Then the exit status indicates smells
63
+ And it reports:
64
+ """
65
+ smelly.rb -- 1 warning:
66
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
67
+ """
68
+
69
+ Scenario: Prefer the default config file over other configuration files
70
+ Given the smelly file 'smelly.rb'
71
+ And a file named "config.reek" with:
72
+ """
73
+ ---
74
+ detectors:
75
+ UncommunicativeMethodName:
76
+ enabled: false
77
+ """
78
+ And a file named ".reek.yml" with:
79
+ """
80
+ ---
81
+ detectors:
82
+ UncommunicativeVariableName:
83
+ enabled: false
84
+ """
85
+ When I run reek smelly.rb
43
86
  Then the exit status indicates smells
44
87
  And it reports:
45
88
  """
46
89
  smelly.rb -- 1 warning:
47
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
90
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
48
91
  """
@@ -33,8 +33,8 @@ Feature: Erroneous source comments are handled properly
33
33
  And it reports:
34
34
  """
35
35
  smelly.rb -- 2 warnings:
36
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
37
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
36
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
37
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
38
38
  2 total warnings
39
39
  """
40
40
 
@@ -48,7 +48,7 @@ Feature: Erroneous source comments are handled properly
48
48
  """
49
49
  When I run reek bad_comment.rb
50
50
  Then it reports the error "Error: You are trying to configure the smell detector 'UncommunicativeMethodName'"
51
- And it reports the error "Unfortunately we can not parse the configuration you have given."
51
+ And it reports the error "Unfortunately we cannot parse the configuration you have given."
52
52
  And it reports the error "The source is 'bad_comment.rb'"
53
53
  And it reports the error "the comment belongs to the expression starting in line 3"
54
54
 
@@ -48,7 +48,7 @@ Feature: Well formed source comments are handled properly
48
48
  And it reports:
49
49
  """
50
50
  enable_detector_explicitly.rb -- 1 warning:
51
- [3]:TooManyInstanceVariables: Alfa has at least 5 instance variables [https://github.com/troessner/reek/blob/master/docs/Too-Many-Instance-Variables.md]
51
+ [3]:TooManyInstanceVariables: Alfa has at least 5 instance variables
52
52
  """
53
53
 
54
54
  Scenario: Configure smell detector with the basic exclude option as string
@@ -112,5 +112,5 @@ Feature: Well formed source comments are handled properly
112
112
  And it reports:
113
113
  """
114
114
  configure_detector_specific_option.rb -- 1 warning:
115
- [3]:TooManyInstanceVariables: Alfa has at least 3 instance variables [https://github.com/troessner/reek/blob/master/docs/Too-Many-Instance-Variables.md]
115
+ [3]:TooManyInstanceVariables: Alfa has at least 3 instance variables
116
116
  """
@@ -0,0 +1,32 @@
1
+ Feature: Handling different locales
2
+ In order to work in a variety of environments
3
+ As a developer
4
+ I want Reek to work properly in any locale
5
+
6
+ Scenario: Running Reek in an UTF-8 locale
7
+ Given I set the environment variable "LANG" to "en_US.utf8"
8
+ And a file "konnichiwa.rb" with:
9
+ """
10
+ puts 'こんにちは世界'
11
+ """
12
+ When I run reek -V konnichiwa.rb
13
+ Then it succeeds
14
+ And it reports no errors
15
+ And it reports:
16
+ """
17
+ konnichiwa.rb -- 0 warnings
18
+ """
19
+
20
+ Scenario: Running Reek in the POSIX locale
21
+ Given I set the environment variable "LANG" to "POSIX"
22
+ And a file "konnichiwa.rb" with:
23
+ """
24
+ puts 'こんにちは世界'
25
+ """
26
+ When I run reek -V konnichiwa.rb
27
+ Then it succeeds
28
+ And it reports no errors
29
+ And it reports:
30
+ """
31
+ konnichiwa.rb -- 0 warnings
32
+ """
@@ -4,95 +4,135 @@ Feature: Reek can be driven through its Task
4
4
 
5
5
  Scenario: source_files points at the desired files
6
6
  Given the smelly file 'smelly.rb'
7
- When I run rake reek with:
7
+ And a file "Rakefile" with:
8
8
  """
9
+ require 'reek/rake/task'
10
+
9
11
  Reek::Rake::Task.new do |t|
10
12
  t.source_files = 'smelly.rb'
11
- t.reek_opts = '--no-color'
13
+ t.reek_opts = '--no-color --no-documentation'
12
14
  end
13
15
  """
16
+ When I run `rake reek`
14
17
  Then the exit status indicates an error
15
18
  And it reports:
16
19
  """
17
20
  smelly.rb -- 2 warnings:
18
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
19
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
21
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
22
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
20
23
  """
21
24
 
22
25
  Scenario: source_files using a FileList instead of a String
23
26
  Given the smelly file 'smelly.rb'
24
- When I run rake reek with:
27
+ And a file "Rakefile" with:
25
28
  """
29
+ require 'reek/rake/task'
30
+
26
31
  Reek::Rake::Task.new do |t|
27
32
  t.source_files = FileList['smelly.*']
28
- t.reek_opts = '--no-color'
33
+ t.reek_opts = '--no-color --no-documentation'
29
34
  end
30
35
  """
36
+ When I run `rake reek`
31
37
  Then the exit status indicates an error
32
38
  And it reports:
33
39
  """
34
40
  smelly.rb -- 2 warnings:
35
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
36
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
41
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
42
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
37
43
  """
38
44
 
39
45
  Scenario: name changes the task name
40
46
  Given the smelly file 'smelly.rb'
41
- When I run rake silky with:
47
+ And a file "Rakefile" with:
42
48
  """
49
+ require 'reek/rake/task'
50
+
43
51
  Reek::Rake::Task.new('silky') do |t|
44
52
  t.source_files = 'smelly.rb'
45
- t.reek_opts = '--no-color'
53
+ t.reek_opts = '--no-color --no-documentation'
46
54
  end
47
55
  """
56
+ When I run `rake silky`
48
57
  Then the exit status indicates an error
49
58
  And it reports:
50
59
  """
51
60
  smelly.rb -- 2 warnings:
52
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
53
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
61
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
62
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
54
63
  """
55
64
 
56
65
  Scenario: verbose prints the reek command
57
66
  Given the smelly file 'smelly.rb'
58
- When I run rake reek with:
67
+ And a file "Rakefile" with:
59
68
  """
69
+ require 'reek/rake/task'
70
+
60
71
  Reek::Rake::Task.new do |t|
61
72
  t.source_files = 'smelly.rb'
62
73
  t.verbose = true
63
74
  end
64
75
  """
76
+ When I run `rake reek`
65
77
  Then the exit status indicates an error
66
78
  And stdout includes "Running 'reek' rake command"
67
79
 
68
80
  Scenario: fail_on_error can hide the error status
69
81
  Given the smelly file 'smelly.rb'
70
- When I run rake reek with:
82
+ And a file "Rakefile" with:
71
83
  """
84
+ require 'reek/rake/task'
85
+
72
86
  Reek::Rake::Task.new do |t|
73
87
  t.fail_on_error = false
74
88
  t.source_files = 'smelly.rb'
75
- t.reek_opts = '--no-color'
89
+ t.reek_opts = '--no-color --no-documentation'
76
90
  end
77
91
  """
92
+ When I run `rake reek`
78
93
  Then it reports no errors
79
94
  And it succeeds
80
95
  And it reports:
81
96
  """
82
97
  smelly.rb -- 2 warnings:
83
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
84
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
98
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
99
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
85
100
  """
86
101
 
87
102
  Scenario: can be configured with config_file
88
103
  Given the smelly file 'smelly.rb'
89
104
  And a configuration file 'full_mask.reek'
90
- When I run rake reek with:
105
+ And a file "Rakefile" with:
91
106
  """
107
+ require 'reek/rake/task'
108
+
92
109
  Reek::Rake::Task.new do |t|
93
110
  t.config_file = 'full_mask.reek'
94
111
  t.source_files = 'smelly.rb'
95
112
  end
96
113
  """
114
+ When I run `rake reek`
97
115
  Then it succeeds
98
116
  And it reports nothing
117
+
118
+ Scenario: REEK_SRC overrides the files to check
119
+ Given the smelly file 'smelly.rb'
120
+ And the clean file 'clean.rb'
121
+ And a file "Rakefile" with:
122
+ """
123
+ require 'reek/rake/task'
124
+
125
+ Reek::Rake::Task.new do |t|
126
+ t.source_files = 'clean.rb'
127
+ t.reek_opts = '--no-color --no-documentation'
128
+ end
129
+ """
130
+ When I set the environment variable "REEK_SRC" to "smelly.rb"
131
+ And I run `rake reek`
132
+ Then the exit status indicates an error
133
+ And it reports:
134
+ """
135
+ smelly.rb -- 2 warnings:
136
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
137
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
138
+ """
@@ -24,7 +24,7 @@ Feature: Report smells using simple JSON layout
24
24
  "context": "Smelly#x",
25
25
  "lines": [ 4 ],
26
26
  "message": "has the name 'x'",
27
- "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md",
27
+ "documentation_link": "https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Method-Name.md",
28
28
  "name": "x"
29
29
  },
30
30
  {
@@ -33,7 +33,7 @@ Feature: Report smells using simple JSON layout
33
33
  "context": "Smelly#x",
34
34
  "lines": [ 5 ],
35
35
  "message": "has the variable name 'y'",
36
- "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md",
36
+ "documentation_link": "https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Variable-Name.md",
37
37
  "name": "y"
38
38
  }
39
39
  ]
@@ -53,7 +53,7 @@ Feature: Report smells using simple JSON layout
53
53
  1
54
54
  ],
55
55
  "message": "has no descriptive comment",
56
- "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md"
56
+ "documentation_link": "https://github.com/troessner/reek/blob/v5.0.0/docs/Irresponsible-Module.md"
57
57
  }
58
58
  ]
59
59
  """