reek 4.8.1 → 5.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 (227) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +17 -3
  3. data/.simplecov +1 -0
  4. data/.travis.yml +0 -5
  5. data/.yardopts +1 -1
  6. data/CHANGELOG.md +44 -0
  7. data/Gemfile +1 -1
  8. data/README.md +115 -100
  9. data/Rakefile +16 -3
  10. data/bin/reek +1 -3
  11. data/docs/API.md +2 -9
  12. data/docs/Basic-Smell-Options.md +51 -11
  13. data/docs/Code-Smells.md +1 -1
  14. data/docs/Command-Line-Options.md +14 -4
  15. data/docs/Duplicate-Method-Call.md +49 -1
  16. data/docs/Feature-Envy.md +44 -0
  17. data/docs/How-To-Write-New-Detectors.md +2 -3
  18. data/docs/Instance-Variable-Assumption.md +1 -1
  19. data/docs/{Prima-Donna-Method.md → Missing-Safe-Method.md} +11 -9
  20. data/docs/Rake-Task.md +1 -1
  21. data/docs/Reek-4-to-Reek-5-migration.md +193 -0
  22. data/docs/Reek-Driven-Development.md +1 -1
  23. data/docs/Uncommunicative-Method-Name.md +45 -6
  24. data/docs/Uncommunicative-Module-Name.md +49 -7
  25. data/docs/Uncommunicative-Parameter-Name.md +43 -5
  26. data/docs/Uncommunicative-Variable-Name.md +73 -2
  27. data/docs/Unused-Private-Method.md +1 -1
  28. data/docs/defaults.reek.yml +129 -0
  29. data/docs/yard_plugin.rb +1 -0
  30. data/features/command_line_interface/basic_usage.feature +2 -2
  31. data/features/command_line_interface/options.feature +46 -4
  32. data/features/command_line_interface/show_progress.feature +4 -4
  33. data/features/command_line_interface/smell_selection.feature +1 -1
  34. data/features/command_line_interface/smells_count.feature +6 -6
  35. data/features/command_line_interface/stdin.feature +30 -8
  36. data/features/configuration_files/accept_setting.feature +45 -28
  37. data/features/configuration_files/directory_specific_directives.feature +78 -73
  38. data/features/configuration_files/exclude_directives.feature +11 -10
  39. data/features/configuration_files/exclude_paths_directives.feature +4 -4
  40. data/features/configuration_files/masking_smells.feature +38 -9
  41. data/features/configuration_files/mix_accept_reject_setting.feature +31 -28
  42. data/features/configuration_files/reject_setting.feature +52 -41
  43. data/features/configuration_files/schema_validation.feature +59 -0
  44. data/features/configuration_files/unused_private_method.feature +18 -16
  45. data/features/configuration_loading.feature +53 -10
  46. data/features/configuration_via_source_comments/erroneous_source_comments.feature +2 -2
  47. data/features/configuration_via_source_comments/well_formed_source_comments.feature +2 -2
  48. data/features/locales.feature +2 -2
  49. data/features/rake_task/rake_task.feature +15 -15
  50. data/features/reports/json.feature +3 -3
  51. data/features/reports/reports.feature +34 -34
  52. data/features/reports/yaml.feature +3 -3
  53. data/features/rspec_matcher.feature +9 -1
  54. data/features/samples.feature +287 -287
  55. data/features/step_definitions/reek_steps.rb +4 -0
  56. data/features/step_definitions/sample_file_steps.rb +9 -4
  57. data/features/support/env.rb +2 -2
  58. data/features/todo_list.feature +26 -23
  59. data/lib/reek/ast/node.rb +3 -6
  60. data/lib/reek/ast/object_refs.rb +1 -1
  61. data/lib/reek/ast/sexp_extensions/case.rb +3 -1
  62. data/lib/reek/ast/sexp_extensions/if.rb +2 -2
  63. data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -1
  64. data/lib/reek/ast/sexp_extensions/methods.rb +1 -1
  65. data/lib/reek/cli/application.rb +4 -3
  66. data/lib/reek/cli/command/report_command.rb +1 -2
  67. data/lib/reek/cli/command/todo_list_command.rb +4 -2
  68. data/lib/reek/cli/options.rb +29 -14
  69. data/lib/reek/cli/silencer.rb +14 -3
  70. data/lib/reek/code_comment.rb +14 -16
  71. data/lib/reek/configuration/app_configuration.rb +32 -28
  72. data/lib/reek/configuration/configuration_converter.rb +110 -0
  73. data/lib/reek/configuration/configuration_file_finder.rb +15 -40
  74. data/lib/reek/configuration/configuration_validator.rb +12 -23
  75. data/lib/reek/configuration/default_directive.rb +17 -3
  76. data/lib/reek/configuration/directory_directives.rb +17 -11
  77. data/lib/reek/configuration/excluded_paths.rb +1 -1
  78. data/lib/reek/configuration/rake_task_converter.rb +29 -0
  79. data/lib/reek/configuration/schema.yml +210 -0
  80. data/lib/reek/configuration/schema_validator.rb +38 -0
  81. data/lib/reek/context/attribute_context.rb +1 -1
  82. data/lib/reek/context/code_context.rb +4 -4
  83. data/lib/reek/context/method_context.rb +2 -2
  84. data/lib/reek/context/module_context.rb +1 -1
  85. data/lib/reek/context_builder.rb +9 -9
  86. data/lib/reek/detector_repository.rb +6 -0
  87. data/lib/reek/documentation_link.rb +28 -0
  88. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +4 -3
  89. data/lib/reek/errors/bad_detector_in_comment_error.rb +4 -3
  90. data/lib/reek/errors/config_file_error.rb +11 -0
  91. data/lib/reek/errors/encoding_error.rb +2 -2
  92. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +4 -3
  93. data/lib/reek/errors/incomprehensible_source_error.rb +2 -2
  94. data/lib/reek/errors/syntax_error.rb +41 -0
  95. data/lib/reek/examiner.rb +9 -19
  96. data/lib/reek/rake/task.rb +3 -3
  97. data/lib/reek/report/base_report.rb +8 -12
  98. data/lib/reek/report/code_climate/code_climate_configuration.yml +6 -10
  99. data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
  100. data/lib/reek/report/heading_formatter.rb +54 -0
  101. data/lib/reek/report/json_report.rb +1 -1
  102. data/lib/reek/report/location_formatter.rb +40 -0
  103. data/lib/reek/report/progress_formatter.rb +79 -0
  104. data/lib/reek/report/simple_warning_formatter.rb +34 -0
  105. data/lib/reek/report/text_report.rb +1 -2
  106. data/lib/reek/report/xml_report.rb +3 -3
  107. data/lib/reek/report/yaml_report.rb +1 -1
  108. data/lib/reek/report.rb +15 -10
  109. data/lib/reek/smell_configuration.rb +2 -2
  110. data/lib/reek/smell_detectors/attribute.rb +0 -1
  111. data/lib/reek/smell_detectors/base_detector.rb +8 -11
  112. data/lib/reek/smell_detectors/boolean_parameter.rb +0 -1
  113. data/lib/reek/smell_detectors/class_variable.rb +0 -1
  114. data/lib/reek/smell_detectors/control_parameter.rb +17 -32
  115. data/lib/reek/smell_detectors/data_clump.rb +3 -4
  116. data/lib/reek/smell_detectors/duplicate_method_call.rb +5 -6
  117. data/lib/reek/smell_detectors/feature_envy.rb +1 -1
  118. data/lib/reek/smell_detectors/instance_variable_assumption.rb +0 -1
  119. data/lib/reek/smell_detectors/irresponsible_module.rb +0 -1
  120. data/lib/reek/smell_detectors/long_parameter_list.rb +1 -2
  121. data/lib/reek/smell_detectors/long_yield_list.rb +2 -3
  122. data/lib/reek/smell_detectors/manual_dispatch.rb +2 -2
  123. data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +6 -7
  124. data/lib/reek/smell_detectors/module_initialize.rb +0 -1
  125. data/lib/reek/smell_detectors/nested_iterators.rb +4 -5
  126. data/lib/reek/smell_detectors/nil_check.rb +0 -1
  127. data/lib/reek/smell_detectors/repeated_conditional.rb +3 -4
  128. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +0 -1
  129. data/lib/reek/smell_detectors/too_many_constants.rb +1 -2
  130. data/lib/reek/smell_detectors/too_many_instance_variables.rb +1 -2
  131. data/lib/reek/smell_detectors/too_many_methods.rb +1 -2
  132. data/lib/reek/smell_detectors/too_many_statements.rb +1 -2
  133. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +2 -3
  134. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +2 -3
  135. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +2 -3
  136. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +4 -5
  137. data/lib/reek/smell_detectors/unused_parameters.rb +0 -1
  138. data/lib/reek/smell_detectors/unused_private_method.rb +0 -1
  139. data/lib/reek/smell_detectors/utility_function.rb +1 -2
  140. data/lib/reek/smell_detectors.rb +1 -2
  141. data/lib/reek/smell_warning.rb +15 -8
  142. data/lib/reek/source/source_code.rb +40 -55
  143. data/lib/reek/source/source_locator.rb +7 -7
  144. data/lib/reek/spec/should_reek.rb +2 -2
  145. data/lib/reek/spec/should_reek_of.rb +9 -16
  146. data/lib/reek/spec/should_reek_only_of.rb +4 -4
  147. data/lib/reek/spec.rb +6 -6
  148. data/lib/reek/tree_dresser.rb +5 -5
  149. data/lib/reek/version.rb +1 -1
  150. data/reek.gemspec +4 -4
  151. data/samples/checkstyle.xml +1 -1
  152. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
  153. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
  154. data/samples/configuration/full_configuration.reek +8 -4
  155. data/samples/configuration/full_mask.reek +5 -4
  156. data/samples/configuration/partial_mask.reek +3 -2
  157. data/samples/configuration/regular_configuration/.reek.yml +4 -0
  158. data/samples/paths.rb +5 -4
  159. data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
  160. data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
  161. data/spec/reek/ast/node_spec.rb +5 -5
  162. data/spec/reek/cli/application_spec.rb +18 -4
  163. data/spec/reek/cli/command/todo_list_command_spec.rb +4 -2
  164. data/spec/reek/cli/silencer_spec.rb +28 -0
  165. data/spec/reek/code_comment_spec.rb +0 -7
  166. data/spec/reek/configuration/app_configuration_spec.rb +44 -31
  167. data/spec/reek/configuration/configuration_file_finder_spec.rb +141 -49
  168. data/spec/reek/configuration/default_directive_spec.rb +1 -1
  169. data/spec/reek/configuration/directory_directives_spec.rb +3 -4
  170. data/spec/reek/configuration/excluded_paths_spec.rb +5 -5
  171. data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
  172. data/spec/reek/configuration/schema_validator_spec.rb +165 -0
  173. data/spec/reek/context/code_context_spec.rb +1 -1
  174. data/spec/reek/documentation_link_spec.rb +20 -0
  175. data/spec/reek/examiner_spec.rb +28 -1
  176. data/spec/reek/report/json_report_spec.rb +13 -46
  177. data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
  178. data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
  179. data/spec/reek/report/text_report_spec.rb +4 -4
  180. data/spec/reek/report/xml_report_spec.rb +1 -1
  181. data/spec/reek/report/yaml_report_spec.rb +9 -38
  182. data/spec/reek/report_spec.rb +3 -3
  183. data/spec/reek/smell_detectors/feature_envy_spec.rb +47 -2
  184. data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +9 -9
  185. data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
  186. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
  187. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
  188. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
  189. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +6 -4
  190. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +6 -6
  191. data/spec/reek/smell_detectors/unused_private_method_spec.rb +1 -1
  192. data/spec/reek/smell_warning_spec.rb +4 -0
  193. data/spec/reek/source/source_code_spec.rb +16 -22
  194. data/spec/reek/source/source_locator_spec.rb +11 -11
  195. data/spec/reek/spec/should_reek_of_spec.rb +0 -4
  196. data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
  197. data/spec/reek/spec/should_reek_spec.rb +1 -1
  198. data/spec/reek/tree_dresser_spec.rb +2 -6
  199. data/spec/spec_helper.rb +3 -5
  200. data/tasks/configuration.rake +8 -5
  201. metadata +64 -36
  202. data/.codeclimate.yml +0 -21
  203. data/defaults.reek +0 -131
  204. data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
  205. data/lib/reek/report/formatter/heading_formatter.rb +0 -52
  206. data/lib/reek/report/formatter/location_formatter.rb +0 -42
  207. data/lib/reek/report/formatter/progress_formatter.rb +0 -81
  208. data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
  209. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -36
  210. data/lib/reek/report/formatter.rb +0 -33
  211. data/lib/reek/smell_detectors/syntax.rb +0 -37
  212. data/samples/configuration/non_public_modifiers_mask.reek +0 -3
  213. data/samples/smelly_with_inline_mask.rb +0 -8
  214. data/samples/smelly_with_modifiers.rb +0 -12
  215. data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
  216. data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
  217. data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
  218. /data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
  219. /data/samples/{clean.rb → clean_source/clean.rb} +0 -0
  220. /data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
  221. /data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
  222. /data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
  223. /data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
  224. /data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
  225. /data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
  226. /data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
  227. /data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
@@ -8,16 +8,17 @@ Feature: Directory directives
8
8
  Given a file named "web_app/config.reek" with:
9
9
  """
10
10
  ---
11
- "web_app/app/controllers":
12
- IrresponsibleModule:
13
- enabled: false
14
- NestedIterators:
15
- enabled: false
16
- "web_app/app/helpers":
17
- IrresponsibleModule:
18
- enabled: false
19
- UtilityFunction:
20
- enabled: false
11
+ directories:
12
+ "web_app/app/controllers":
13
+ IrresponsibleModule:
14
+ enabled: false
15
+ NestedIterators:
16
+ enabled: false
17
+ "web_app/app/helpers":
18
+ IrresponsibleModule:
19
+ enabled: false
20
+ UtilityFunction:
21
+ enabled: false
21
22
  """
22
23
  And a file named "web_app/app/controllers/users_controller.rb" with:
23
24
  """
@@ -46,14 +47,14 @@ Feature: Directory directives
46
47
  end
47
48
  end
48
49
  """
49
- When I run `reek -c web_app/config.reek web_app/`
50
+ When I run reek -c web_app/config.reek web_app/
50
51
  Then it reports:
51
52
  """
52
53
  web_app/app/controllers/users_controller.rb -- 1 warning:
53
- [1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user' [https://github.com/troessner/reek/blob/master/docs/Instance-Variable-Assumption.md]
54
+ [1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
54
55
  web_app/app/models/user.rb -- 2 warnings:
55
- [1]:IrresponsibleModule: User has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
56
- [2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
56
+ [1]:IrresponsibleModule: User has no descriptive comment
57
+ [2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role'
57
58
  3 total warnings
58
59
  """
59
60
 
@@ -61,9 +62,10 @@ Feature: Directory directives
61
62
  Given a file named "web_app/config.reek" with:
62
63
  """
63
64
  ---
64
- "controllers/":
65
- IrresponsibleModule:
66
- enabled: false
65
+ directories:
66
+ "controllers/":
67
+ IrresponsibleModule:
68
+ enabled: false
67
69
  """
68
70
  And a file named "controllers/users_controller.rb" with:
69
71
  """
@@ -72,24 +74,25 @@ Feature: Directory directives
72
74
  end
73
75
  end
74
76
  """
75
- When I run `reek -c web_app/config.reek controllers`
77
+ When I run reek -c web_app/config.reek controllers
76
78
  Then it reports nothing
77
79
 
78
80
  Scenario: Partially mask smells in different directories
79
81
  Given a file named "web_app/config.reek" with:
80
82
  """
81
83
  ---
82
- "web_app/app/controllers":
83
- IrresponsibleModule:
84
- enabled: true
85
- "web_app/app/helpers":
86
- IrresponsibleModule:
87
- enabled: false
88
- UtilityFunction:
89
- enabled: false
90
- "web_app/app/models":
91
- IrresponsibleModule:
92
- enabled: false
84
+ directories:
85
+ "web_app/app/controllers":
86
+ IrresponsibleModule:
87
+ enabled: true
88
+ "web_app/app/helpers":
89
+ IrresponsibleModule:
90
+ enabled: false
91
+ UtilityFunction:
92
+ enabled: false
93
+ "web_app/app/models":
94
+ IrresponsibleModule:
95
+ enabled: false
93
96
  """
94
97
  And a file named "web_app/app/controllers/users_controller.rb" with:
95
98
  """
@@ -117,15 +120,15 @@ Feature: Directory directives
117
120
  end
118
121
  end
119
122
  """
120
- When I run `reek -c web_app/config.reek web_app/`
123
+ When I run reek -c web_app/config.reek web_app/
121
124
  Then it reports:
122
125
  """
123
126
  web_app/app/controllers/users_controller.rb -- 3 warnings:
124
- [1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user' [https://github.com/troessner/reek/blob/master/docs/Instance-Variable-Assumption.md]
125
- [1]:IrresponsibleModule: UsersController has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
126
- [4]:NestedIterators: UsersController#show contains iterators nested 2 deep [https://github.com/troessner/reek/blob/master/docs/Nested-Iterators.md]
127
+ [1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
128
+ [1]:IrresponsibleModule: UsersController has no descriptive comment
129
+ [4]:NestedIterators: UsersController#show contains iterators nested 2 deep
127
130
  web_app/app/models/user.rb -- 1 warning:
128
- [2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
131
+ [2]:UnusedParameters: User#logged_in_with_role has unused parameter 'role'
129
132
  4 total warnings
130
133
  """
131
134
 
@@ -133,15 +136,17 @@ Feature: Directory directives
133
136
  Given a file named "config.reek" with:
134
137
  """
135
138
  ---
136
- "web_app/app/controllers":
139
+ directories:
140
+ "web_app/app/controllers":
141
+ IrresponsibleModule:
142
+ enabled: true
143
+ NestedIterators:
144
+ enabled: false
145
+ detectors:
137
146
  IrresponsibleModule:
138
- enabled: true
139
- NestedIterators:
140
147
  enabled: false
141
- IrresponsibleModule:
142
- enabled: false
143
- NestedIterators:
144
- enabled: true
148
+ NestedIterators:
149
+ enabled: true
145
150
  """
146
151
  And a file named "web_app/app/controllers/users_controller.rb" with:
147
152
  """
@@ -163,15 +168,15 @@ Feature: Directory directives
163
168
  end
164
169
  end
165
170
  """
166
- When I run `reek -c config.reek other/ web_app/`
171
+ When I run reek -c config.reek other/ web_app/
167
172
  Then it reports:
168
173
  """
169
174
  other/projects_controller.rb -- 2 warnings:
170
- [1]:InstanceVariableAssumption: ProjectController assumes too much for instance variable '@project' [https://github.com/troessner/reek/blob/master/docs/Instance-Variable-Assumption.md]
171
- [4]:NestedIterators: ProjectController#show contains iterators nested 2 deep [https://github.com/troessner/reek/blob/master/docs/Nested-Iterators.md]
175
+ [1]:InstanceVariableAssumption: ProjectController assumes too much for instance variable '@project'
176
+ [4]:NestedIterators: ProjectController#show contains iterators nested 2 deep
172
177
  web_app/app/controllers/users_controller.rb -- 2 warnings:
173
- [1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user' [https://github.com/troessner/reek/blob/master/docs/Instance-Variable-Assumption.md]
174
- [1]:IrresponsibleModule: UsersController has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
178
+ [1]:InstanceVariableAssumption: UsersController assumes too much for instance variable '@user'
179
+ [1]:IrresponsibleModule: UsersController has no descriptive comment
175
180
  4 total warnings
176
181
  """
177
182
 
@@ -179,10 +184,11 @@ Feature: Directory directives
179
184
  Given a file named "config.reek" with:
180
185
  """
181
186
  ---
182
- "dummy_directory":
183
- # Typo: Should be NestedIterators
184
- IteratorsNested:
185
- enabled: false
187
+ directories:
188
+ "dummy_directory":
189
+ # Typo: Should be NestedIterators
190
+ IteratorsNested:
191
+ enabled: false
186
192
  """
187
193
  And a file named "dummy_directory/dummy.rb" with:
188
194
  """
@@ -190,34 +196,32 @@ Feature: Directory directives
190
196
  end
191
197
  """
192
198
 
193
- When I run `reek -c config.reek dummy_directory/`
199
+ When I run reek -c config.reek dummy_directory/
194
200
  Then the exit status indicates an error
195
201
  And stderr reports:
196
202
  """
197
- You are trying to configure smell type IteratorsNested but we can't find one with that name.
198
- Please make sure you spelled it right. (See 'defaults.reek' in the Reek
199
- repository for a list of all available smell types.)
200
-
203
+ Error: We found some problems with your configuration file: [/directories/dummy_directory/IteratorsNested] key 'IteratorsNested:' is undefined.
201
204
  """
202
205
 
203
206
  Scenario: Abort on file as directory directive
204
207
  Given a file named "config.reek" with:
205
208
  """
206
209
  ---
207
- "dummy_directory/dummy.rb":
208
- NestedIterators:
209
- enabled: false
210
+ directories:
211
+ "dummy_directory/dummy.rb":
212
+ NestedIterators:
213
+ enabled: false
210
214
  """
211
215
  And a file named "dummy_directory/dummy.rb" with:
212
216
  """
213
217
  class Dummy
214
218
  end
215
219
  """
216
- When I run `reek -c config.reek dummy_directory/`
220
+ When I run reek -c config.reek dummy_directory/
217
221
  Then the exit status indicates an error
218
222
  And stderr reports:
219
223
  """
220
- Configuration error: `dummy_directory/dummy.rb` is supposed to be a directory but is a file
224
+ Error: `dummy_directory/dummy.rb` is supposed to be a directory but is a file
221
225
 
222
226
  """
223
227
 
@@ -225,16 +229,17 @@ Feature: Directory directives
225
229
  Given a file named "config.reek" with:
226
230
  """
227
231
  ---
228
- "foo/bar/baz":
229
- IrresponsibleModule:
230
- enabled: false
231
- NestedIterators:
232
- enabled: true
233
- "foo/bar":
234
- IrresponsibleModule:
235
- enabled: true
236
- NestedIterators:
237
- enabled: false
232
+ directories:
233
+ "foo/bar/baz":
234
+ IrresponsibleModule:
235
+ enabled: false
236
+ NestedIterators:
237
+ enabled: true
238
+ "foo/bar":
239
+ IrresponsibleModule:
240
+ enabled: true
241
+ NestedIterators:
242
+ enabled: false
238
243
  """
239
244
  And a file named "foo/bar/baz/klass.rb" with:
240
245
  """
@@ -258,12 +263,12 @@ Feature: Directory directives
258
263
  end
259
264
  end
260
265
  """
261
- When I run `reek -c config.reek foo/`
266
+ When I run reek -c config.reek foo/
262
267
  Then it reports:
263
268
  """
264
269
  foo/bar/baz/klass.rb -- 1 warning:
265
- [4]:NestedIterators: Klass#meth contains iterators nested 2 deep [https://github.com/troessner/reek/blob/master/docs/Nested-Iterators.md]
270
+ [4]:NestedIterators: Klass#meth contains iterators nested 2 deep
266
271
  foo/bar/klazz.rb -- 1 warning:
267
- [1]:IrresponsibleModule: Klazz has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
272
+ [1]:IrresponsibleModule: Klazz has no descriptive comment
268
273
  2 total warnings
269
274
  """
@@ -7,13 +7,14 @@ Feature: Exclude directives
7
7
  Given a file named "config.reek" with:
8
8
  """
9
9
  ---
10
- UncommunicativeMethodName:
11
- exclude:
12
- - "Smelly#x"
13
- UnusedPrivateMethod:
14
- enabled: true
15
- exclude:
16
- - "Smelly#foobar"
10
+ detectors:
11
+ UncommunicativeMethodName:
12
+ exclude:
13
+ - "Smelly#x"
14
+ UnusedPrivateMethod:
15
+ enabled: true
16
+ exclude:
17
+ - "Smelly#foobar"
17
18
  """
18
19
  And a file named "smelly.rb" with:
19
20
  """
@@ -25,10 +26,10 @@ Feature: Exclude directives
25
26
  def foobar; end # Should not report UnusedPrivateMethod
26
27
  end
27
28
  """
28
- When I run `reek -c config.reek smelly.rb`
29
+ When I run reek -c config.reek smelly.rb
29
30
  Then it reports:
30
31
  """
31
32
  smelly.rb -- 2 warnings:
32
- [1]:IrresponsibleModule: Smelly has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
33
- [3]:UnusedParameters: Smelly#foo has unused parameter 'arg' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
33
+ [1]:IrresponsibleModule: Smelly has no descriptive comment
34
+ [3]:UnusedParameters: Smelly#foo has unused parameter 'arg'
34
35
  """
@@ -11,7 +11,7 @@ Feature: Exclude paths directives
11
11
  def alfa(bravo); end
12
12
  end
13
13
  """
14
- When I run `reek .`
14
+ When I run reek .
15
15
  Then the exit status indicates smells
16
16
  Given a file named "config.reek" with:
17
17
  """
@@ -19,7 +19,7 @@ Feature: Exclude paths directives
19
19
  exclude_paths:
20
20
  - bad_files_live_here
21
21
  """
22
- When I run `reek -c config.reek .`
22
+ When I run reek -c config.reek .
23
23
  Then it succeeds
24
24
  And it reports nothing
25
25
  Scenario: Using a file name within an excluded directory
@@ -36,8 +36,8 @@ Feature: Exclude paths directives
36
36
  exclude_paths:
37
37
  - bad_files_live_here
38
38
  """
39
- When I run `reek -c config.reek bad_files_live_here/smelly.rb`
39
+ When I run reek -c config.reek bad_files_live_here/smelly.rb
40
40
  Then the exit status indicates smells
41
- When I run `reek -c config.reek --force-exclusion bad_files_live_here/smelly.rb`
41
+ When I run reek -c config.reek --force-exclusion bad_files_live_here/smelly.rb
42
42
  Then it succeeds
43
43
  And it reports nothing
@@ -7,7 +7,10 @@ Feature: Masking smells using config files
7
7
  Given the smelly file 'smelly.rb'
8
8
  And a configuration file 'corrupt.reek'
9
9
  When I run reek -c corrupt.reek smelly.rb
10
- Then it reports the error 'Error: Invalid configuration file "corrupt.reek" -- Not a hash'
10
+ And stderr reports:
11
+ """
12
+ Error: We found some problems with your configuration file: [/] 'Not a valid configuration file': not a mapping.
13
+ """
11
14
  And the exit status indicates an error
12
15
  And it reports nothing
13
16
 
@@ -30,11 +33,21 @@ Feature: Masking smells using config files
30
33
  And it reports:
31
34
  """
32
35
  smelly.rb -- 1 warning:
33
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
36
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
34
37
  """
35
38
 
36
39
  Scenario: provide extra masking inline in comments
37
- Given the smelly file 'smelly_with_inline_mask.rb'
40
+ Given a file named "smelly_with_inline_mask.rb" with:
41
+ """
42
+ # Smelly class
43
+ # disables :reek:UncommunicativeVariableName
44
+ class Smelly
45
+ # This will reek of UncommunicativeMethodName
46
+ def x
47
+ y = 10 # This will NOT reek of UncommunicativeVariableName
48
+ end
49
+ end
50
+ """
38
51
  And a configuration file 'partial_mask.reek'
39
52
  When I run reek -c partial_mask.reek smelly_with_inline_mask.rb
40
53
  Then it succeeds
@@ -48,18 +61,34 @@ Feature: Masking smells using config files
48
61
  And it reports:
49
62
  """
50
63
  smelly.rb -- 2 warnings:
51
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
52
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
64
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
65
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
53
66
  """
54
67
 
55
68
  Scenario: Disable UtilityFunction for non-public methods
56
- Given the smelly file 'smelly_with_modifiers.rb'
57
- And a configuration file 'non_public_modifiers_mask.reek'
58
- When I run reek -c non_public_modifiers_mask.reek smelly_with_modifiers.rb
69
+ Given a file named "smelly_with_modifiers.rb" with:
70
+ """
71
+ # Smelly class for testing purposes
72
+ class Klass
73
+ def public_method(arg) arg.to_s; end
74
+ protected
75
+ def protected_method(arg) arg.to_s; end
76
+ private
77
+ def private_method(arg) arg.to_s; end
78
+ end
79
+ """
80
+ And a file named "non_public_modifiers_mask.reek.yml" with:
81
+ """
82
+ ---
83
+ detectors:
84
+ UtilityFunction:
85
+ public_methods_only: true
86
+ """
87
+ When I run reek -c non_public_modifiers_mask.reek.yml smelly_with_modifiers.rb
59
88
  Then the exit status indicates smells
60
89
  And it reports:
61
90
  """
62
91
  smelly_with_modifiers.rb -- 1 warning:
63
- [7]:UtilityFunction: Klass#public_method doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
92
+ [3]:UtilityFunction: Klass#public_method doesn't depend on instance state (maybe move it to another class?)
64
93
  """
65
94
  But it does not report private or protected methods
@@ -7,13 +7,14 @@ Feature: Mix `accept` and `reject` configuration settings
7
7
  Given a file named "config.reek" with:
8
8
  """
9
9
  ---
10
- UncommunicativeMethodName:
11
- accept:
12
- - !ruby/regexp /x/
13
- - meth1
14
- reject:
15
- - !ruby/regexp /helper/
16
- - foobar
10
+ detectors:
11
+ UncommunicativeMethodName:
12
+ accept:
13
+ - x
14
+ - meth1
15
+ reject:
16
+ - helper
17
+ - foobar
17
18
  """
18
19
  And a file named "smelly.rb" with:
19
20
  """
@@ -22,26 +23,27 @@ Feature: Mix `accept` and `reject` configuration settings
22
23
  def foobar; end # Should be reported
23
24
  def awesome_helper; end # Should be reported
24
25
  """
25
- When I run `reek -c config.reek smelly.rb`
26
+ When I run reek -c config.reek smelly.rb
26
27
  Then it reports:
27
28
  """
28
29
  smelly.rb -- 2 warnings:
29
- [4]:UncommunicativeMethodName: awesome_helper has the name 'awesome_helper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
30
- [3]:UncommunicativeMethodName: foobar has the name 'foobar' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
30
+ [4]:UncommunicativeMethodName: awesome_helper has the name 'awesome_helper'
31
+ [3]:UncommunicativeMethodName: foobar has the name 'foobar'
31
32
  """
32
33
 
33
34
  Scenario: UncommunicativeModuleName
34
35
  Given a file named "config.reek" with:
35
36
  """
36
37
  ---
37
- IrresponsibleModule:
38
- enabled: false
39
- UncommunicativeModuleName:
40
- accept:
41
- - !ruby/regexp /lassy/
42
- - M
43
- reject:
44
- - !ruby/regexp /Helper/
38
+ detectors:
39
+ IrresponsibleModule:
40
+ enabled: false
41
+ UncommunicativeModuleName:
42
+ accept:
43
+ - lassy
44
+ - M
45
+ reject:
46
+ - Helper
45
47
  """
46
48
  And a file named "smelly.rb" with:
47
49
  """
@@ -49,23 +51,24 @@ Feature: Mix `accept` and `reject` configuration settings
49
51
  class M; end # Should not be reported
50
52
  class BaseHelper; end # Should be reported
51
53
  """
52
- When I run `reek -c config.reek smelly.rb`
54
+ When I run reek -c config.reek smelly.rb
53
55
  Then it reports:
54
56
  """
55
57
  smelly.rb -- 1 warning:
56
- [3]:UncommunicativeModuleName: BaseHelper has the name 'BaseHelper' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Module-Name.md]
58
+ [3]:UncommunicativeModuleName: BaseHelper has the name 'BaseHelper'
57
59
  """
58
60
 
59
61
  Scenario: UncommunicativeParameterName
60
62
  Given a file named "config.reek" with:
61
63
  """
62
64
  ---
63
- UncommunicativeParameterName:
64
- accept:
65
- - !ruby/regexp /x/
66
- - arg1
67
- reject:
68
- - !ruby/regexp /foobar/
65
+ detectors:
66
+ UncommunicativeParameterName:
67
+ accept:
68
+ - x
69
+ - arg1
70
+ reject:
71
+ - foobar
69
72
  """
70
73
  And a file named "smelly.rb" with:
71
74
  """
@@ -73,9 +76,9 @@ Feature: Mix `accept` and `reject` configuration settings
73
76
  def omg(arg1); arg1; end # Should not be reported
74
77
  def omg(foobar); foobar; end # Should be reported
75
78
  """
76
- When I run `reek -c config.reek smelly.rb`
79
+ When I run reek -c config.reek smelly.rb
77
80
  Then it reports:
78
81
  """
79
82
  smelly.rb -- 1 warning:
80
- [3]:UncommunicativeParameterName: omg has the parameter name 'foobar' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Parameter-Name.md]
83
+ [3]:UncommunicativeParameterName: omg has the parameter name 'foobar'
81
84
  """
@@ -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
  """