reek 4.8.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +5 -5
  2. data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
  3. data/.rubocop.yml +17 -3
  4. data/.simplecov +1 -0
  5. data/.travis.yml +0 -5
  6. data/.yardopts +1 -1
  7. data/CHANGELOG.md +28 -0
  8. data/Gemfile +1 -1
  9. data/README.md +113 -98
  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/{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 +43 -4
  24. data/docs/Uncommunicative-Module-Name.md +48 -6
  25. data/docs/Uncommunicative-Parameter-Name.md +42 -4
  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/options.feature +46 -4
  31. data/features/command_line_interface/stdin.feature +27 -5
  32. data/features/configuration_files/accept_setting.feature +39 -22
  33. data/features/configuration_files/directory_specific_directives.feature +58 -53
  34. data/features/configuration_files/exclude_directives.feature +8 -7
  35. data/features/configuration_files/masking_smells.feature +35 -6
  36. data/features/configuration_files/mix_accept_reject_setting.feature +24 -21
  37. data/features/configuration_files/reject_setting.feature +45 -34
  38. data/features/configuration_files/schema_validation.feature +59 -0
  39. data/features/configuration_files/unused_private_method.feature +14 -12
  40. data/features/configuration_loading.feature +50 -7
  41. data/features/rake_task/rake_task.feature +5 -5
  42. data/features/reports/json.feature +4 -1
  43. data/features/reports/reports.feature +12 -12
  44. data/features/reports/yaml.feature +3 -0
  45. data/features/rspec_matcher.feature +9 -1
  46. data/features/step_definitions/reek_steps.rb +4 -0
  47. data/features/step_definitions/sample_file_steps.rb +9 -4
  48. data/features/support/env.rb +2 -2
  49. data/features/todo_list.feature +16 -13
  50. data/lib/reek/ast/node.rb +3 -6
  51. data/lib/reek/ast/object_refs.rb +1 -1
  52. data/lib/reek/ast/sexp_extensions/if.rb +1 -1
  53. data/lib/reek/ast/sexp_extensions/methods.rb +1 -1
  54. data/lib/reek/cli/application.rb +4 -3
  55. data/lib/reek/cli/command/report_command.rb +1 -2
  56. data/lib/reek/cli/command/todo_list_command.rb +4 -2
  57. data/lib/reek/cli/options.rb +27 -13
  58. data/lib/reek/cli/silencer.rb +14 -3
  59. data/lib/reek/code_comment.rb +14 -16
  60. data/lib/reek/configuration/app_configuration.rb +32 -28
  61. data/lib/reek/configuration/configuration_converter.rb +110 -0
  62. data/lib/reek/configuration/configuration_file_finder.rb +15 -40
  63. data/lib/reek/configuration/configuration_validator.rb +12 -23
  64. data/lib/reek/configuration/default_directive.rb +17 -3
  65. data/lib/reek/configuration/directory_directives.rb +17 -11
  66. data/lib/reek/configuration/excluded_paths.rb +1 -1
  67. data/lib/reek/configuration/rake_task_converter.rb +29 -0
  68. data/lib/reek/configuration/schema.yml +210 -0
  69. data/lib/reek/configuration/schema_validator.rb +38 -0
  70. data/lib/reek/context/attribute_context.rb +1 -1
  71. data/lib/reek/context/code_context.rb +4 -4
  72. data/lib/reek/context/method_context.rb +2 -2
  73. data/lib/reek/context/module_context.rb +1 -1
  74. data/lib/reek/context_builder.rb +9 -9
  75. data/lib/reek/detector_repository.rb +6 -0
  76. data/lib/reek/documentation_link.rb +2 -2
  77. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +1 -1
  78. data/lib/reek/errors/bad_detector_in_comment_error.rb +1 -1
  79. data/lib/reek/errors/config_file_error.rb +11 -0
  80. data/lib/reek/errors/encoding_error.rb +2 -2
  81. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +1 -1
  82. data/lib/reek/errors/incomprehensible_source_error.rb +2 -2
  83. data/lib/reek/errors/syntax_error.rb +41 -0
  84. data/lib/reek/examiner.rb +9 -19
  85. data/lib/reek/rake/task.rb +3 -3
  86. data/lib/reek/report.rb +15 -10
  87. data/lib/reek/report/base_report.rb +8 -12
  88. data/lib/reek/report/code_climate/code_climate_configuration.yml +5 -9
  89. data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
  90. data/lib/reek/report/heading_formatter.rb +54 -0
  91. data/lib/reek/report/json_report.rb +1 -1
  92. data/lib/reek/report/location_formatter.rb +40 -0
  93. data/lib/reek/report/progress_formatter.rb +79 -0
  94. data/lib/reek/report/simple_warning_formatter.rb +34 -0
  95. data/lib/reek/report/text_report.rb +1 -2
  96. data/lib/reek/report/xml_report.rb +3 -3
  97. data/lib/reek/report/yaml_report.rb +1 -1
  98. data/lib/reek/smell_configuration.rb +2 -2
  99. data/lib/reek/smell_detectors.rb +1 -2
  100. data/lib/reek/smell_detectors/attribute.rb +0 -1
  101. data/lib/reek/smell_detectors/base_detector.rb +8 -11
  102. data/lib/reek/smell_detectors/boolean_parameter.rb +0 -1
  103. data/lib/reek/smell_detectors/class_variable.rb +0 -1
  104. data/lib/reek/smell_detectors/control_parameter.rb +17 -32
  105. data/lib/reek/smell_detectors/data_clump.rb +3 -4
  106. data/lib/reek/smell_detectors/duplicate_method_call.rb +5 -6
  107. data/lib/reek/smell_detectors/feature_envy.rb +0 -1
  108. data/lib/reek/smell_detectors/instance_variable_assumption.rb +0 -1
  109. data/lib/reek/smell_detectors/irresponsible_module.rb +0 -1
  110. data/lib/reek/smell_detectors/long_parameter_list.rb +1 -2
  111. data/lib/reek/smell_detectors/long_yield_list.rb +2 -3
  112. data/lib/reek/smell_detectors/manual_dispatch.rb +2 -2
  113. data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +6 -7
  114. data/lib/reek/smell_detectors/module_initialize.rb +0 -1
  115. data/lib/reek/smell_detectors/nested_iterators.rb +4 -5
  116. data/lib/reek/smell_detectors/nil_check.rb +0 -1
  117. data/lib/reek/smell_detectors/repeated_conditional.rb +3 -4
  118. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +0 -1
  119. data/lib/reek/smell_detectors/too_many_constants.rb +1 -2
  120. data/lib/reek/smell_detectors/too_many_instance_variables.rb +1 -2
  121. data/lib/reek/smell_detectors/too_many_methods.rb +1 -2
  122. data/lib/reek/smell_detectors/too_many_statements.rb +1 -2
  123. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +2 -3
  124. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +2 -3
  125. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +2 -3
  126. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +4 -5
  127. data/lib/reek/smell_detectors/unused_parameters.rb +0 -1
  128. data/lib/reek/smell_detectors/unused_private_method.rb +0 -1
  129. data/lib/reek/smell_detectors/utility_function.rb +1 -2
  130. data/lib/reek/smell_warning.rb +10 -8
  131. data/lib/reek/source/source_code.rb +40 -55
  132. data/lib/reek/source/source_locator.rb +7 -7
  133. data/lib/reek/spec.rb +6 -6
  134. data/lib/reek/spec/should_reek.rb +2 -2
  135. data/lib/reek/spec/should_reek_of.rb +9 -16
  136. data/lib/reek/spec/should_reek_only_of.rb +4 -4
  137. data/lib/reek/tree_dresser.rb +5 -5
  138. data/lib/reek/version.rb +1 -1
  139. data/reek.gemspec +3 -3
  140. data/samples/checkstyle.xml +1 -1
  141. data/samples/{clean.rb → clean_source/clean.rb} +0 -0
  142. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
  143. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
  144. data/samples/configuration/full_configuration.reek +8 -4
  145. data/samples/configuration/full_mask.reek +5 -4
  146. data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
  147. data/samples/configuration/partial_mask.reek +3 -2
  148. data/samples/configuration/regular_configuration/.reek.yml +4 -0
  149. data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
  150. data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
  151. data/samples/paths.rb +5 -4
  152. data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
  153. data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
  154. data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
  155. data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
  156. data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
  157. data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
  158. data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
  159. data/spec/reek/ast/node_spec.rb +5 -5
  160. data/spec/reek/cli/application_spec.rb +18 -4
  161. data/spec/reek/cli/command/todo_list_command_spec.rb +4 -2
  162. data/spec/reek/cli/silencer_spec.rb +28 -0
  163. data/spec/reek/code_comment_spec.rb +0 -7
  164. data/spec/reek/configuration/app_configuration_spec.rb +44 -31
  165. data/spec/reek/configuration/configuration_file_finder_spec.rb +133 -49
  166. data/spec/reek/configuration/default_directive_spec.rb +1 -1
  167. data/spec/reek/configuration/directory_directives_spec.rb +3 -4
  168. data/spec/reek/configuration/excluded_paths_spec.rb +5 -5
  169. data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
  170. data/spec/reek/configuration/schema_validator_spec.rb +165 -0
  171. data/spec/reek/context/code_context_spec.rb +1 -1
  172. data/spec/reek/examiner_spec.rb +28 -1
  173. data/spec/reek/report/json_report_spec.rb +13 -46
  174. data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
  175. data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
  176. data/spec/reek/report/text_report_spec.rb +4 -4
  177. data/spec/reek/report/xml_report_spec.rb +1 -1
  178. data/spec/reek/report/yaml_report_spec.rb +9 -38
  179. data/spec/reek/report_spec.rb +3 -3
  180. data/spec/reek/smell_detectors/feature_envy_spec.rb +2 -2
  181. data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +9 -9
  182. data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
  183. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
  184. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
  185. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
  186. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +6 -4
  187. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +6 -6
  188. data/spec/reek/smell_detectors/unused_private_method_spec.rb +1 -1
  189. data/spec/reek/smell_warning_spec.rb +4 -0
  190. data/spec/reek/source/source_code_spec.rb +16 -22
  191. data/spec/reek/source/source_locator_spec.rb +11 -11
  192. data/spec/reek/spec/should_reek_of_spec.rb +0 -4
  193. data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
  194. data/spec/reek/spec/should_reek_spec.rb +1 -1
  195. data/spec/reek/tree_dresser_spec.rb +2 -6
  196. data/spec/spec_helper.rb +3 -5
  197. data/tasks/configuration.rake +8 -5
  198. metadata +56 -35
  199. data/defaults.reek +0 -131
  200. data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
  201. data/lib/reek/report/formatter.rb +0 -33
  202. data/lib/reek/report/formatter/heading_formatter.rb +0 -52
  203. data/lib/reek/report/formatter/location_formatter.rb +0 -42
  204. data/lib/reek/report/formatter/progress_formatter.rb +0 -81
  205. data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
  206. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -23
  207. data/lib/reek/smell_detectors/syntax.rb +0 -37
  208. data/samples/configuration/non_public_modifiers_mask.reek +0 -3
  209. data/samples/smelly_with_inline_mask.rb +0 -8
  210. data/samples/smelly_with_modifiers.rb +0 -12
  211. data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
  212. data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
  213. data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
@@ -37,13 +37,14 @@ Feature: Reek can be controlled using command-line options
37
37
  reek -s lib
38
38
  cat my_class.rb | reek
39
39
 
40
- See https://wiki.github.com/troessner/reek for detailed help.
40
+ See https://github.com/troessner/reek for detailed help.
41
41
 
42
42
  Configuration:
43
43
  -c, --config FILE Read configuration options from FILE
44
44
  --smell SMELL Only look for a specific smell.
45
- Call it like this: reek --smell PrimaDonnaMethod source.rb
46
- Check out https://github.com/troessner/reek/blob/v4.8.1/docs/Code-Smells.md for a list of smells
45
+ Call it like this: reek --smell MissingSafeMethod source.rb
46
+ Check out https://github.com/troessner/reek/blob/v5.0.0/docs/Code-Smells.md for a list of smells
47
+ --stdin-filename FILE When passing code in via pipe, assume this filename when checking file or directory rules in the config.
47
48
 
48
49
  Generate a todo list:
49
50
  -t, --todo Generate a todo list
@@ -60,7 +61,7 @@ Feature: Reek can be controlled using command-line options
60
61
  Text format options:
61
62
  --[no-]color Use colors for the output (default: true)
62
63
  -V, --[no-]empty-headings Show headings for smell-free source files (default: false)
63
- -U, --[no-]wiki-links Show link to related wiki page for each smell (default: true)
64
+ -U, --[no-]documentation Show link to related documentation page for each smell (default: true)
64
65
  -n, --[no-]line-numbers Show line numbers in the output (default: true)
65
66
  -s, --single-line Show location in editor-compatible single-line-per-smell format
66
67
  -P, --[no-]progress Show progress of each source as it is examined (default: true)
@@ -76,5 +77,46 @@ Feature: Reek can be controlled using command-line options
76
77
 
77
78
  Utility options:
78
79
  -h, --help Show this message
80
+ -l, --list List all available smell detectors
79
81
  -v, --version Show version
80
82
  """
83
+
84
+ Scenario: List all available smell detectors
85
+ When I run reek --list
86
+ Then it succeeds
87
+ And it reports:
88
+ """
89
+ All available smell detectors:
90
+
91
+ Attribute
92
+ BooleanParameter
93
+ ClassVariable
94
+ ControlParameter
95
+ DataClump
96
+ DuplicateMethodCall
97
+ FeatureEnvy
98
+ InstanceVariableAssumption
99
+ IrresponsibleModule
100
+ LongParameterList
101
+ LongYieldList
102
+ ManualDispatch
103
+ MissingSafeMethod
104
+ ModuleInitialize
105
+ NestedIterators
106
+ NilCheck
107
+ RepeatedConditional
108
+ SubclassedFromCoreClass
109
+ TooManyConstants
110
+ TooManyInstanceVariables
111
+ TooManyMethods
112
+ TooManyStatements
113
+ UncommunicativeMethodName
114
+ UncommunicativeModuleName
115
+ UncommunicativeParameterName
116
+ UncommunicativeVariableName
117
+ UnusedParameters
118
+ UnusedPrivateMethod
119
+ UtilityFunction
120
+
121
+ Check out https://github.com/troessner/reek/blob/v5.0.0/docs/Code-Smells.md for a details on each detector
122
+ """
@@ -34,10 +34,32 @@ Feature: Reek reads from $stdin when no files are given
34
34
 
35
35
  Scenario: syntax error causes the source to be ignored
36
36
  When I pass "= invalid syntax =" to reek
37
- Then the exit status indicates smells
38
- And it reports:
37
+ Then it succeeds
38
+ And it reports the error "Parser::SyntaxError: unexpected token tEQL"
39
+
40
+ Scenario: providing a filename to use for the config to match against
41
+ Given a file named "web_app/config.reek" with:
39
42
  """
40
- STDIN -- 2 warnings:
41
- [2]:Syntax: This file has unexpected token $end
42
- [1]:Syntax: This file has unexpected token tEQL
43
+ ---
44
+ directories:
45
+ "web_app/app/controllers":
46
+ IrresponsibleModule:
47
+ enabled: false
48
+ NestedIterators:
49
+ enabled: false
50
+ InstanceVariableAssumption:
51
+ enabled: false
43
52
  """
53
+ When I pass a stdin to reek --config web_app/config.reek --stdin-filename web_app/app/controllers/users_controller with:
54
+ """
55
+ class UsersController < ApplicationController
56
+ def show
57
+ respond_with do |format|
58
+ format.json { |json| @user.to_custom_json }
59
+ format.xml { |xml| @user.to_fancy_xml }
60
+ end
61
+ end
62
+ end
63
+ """
64
+ Then it succeeds
65
+ And it reports nothing
@@ -3,20 +3,25 @@ Feature: `accept` configuration setting
3
3
  As a user
4
4
  I want to be able to accept specific patterns and names to exclude them from reporting
5
5
 
6
- Scenario: Accept names as list and as single item
6
+ Scenario: Accept names
7
7
  Given a file named "config.reek" with:
8
8
  """
9
9
  ---
10
- UncommunicativeMethodName:
11
- accept:
12
- - m1
13
- - m2
14
- UncommunicativeParameterName:
15
- accept:
16
- - a1
17
- - a2
18
- UncommunicativeModuleName:
19
- accept: C1
10
+ detectors:
11
+ UncommunicativeMethodName:
12
+ accept:
13
+ - m1
14
+ - m2
15
+ UncommunicativeParameterName:
16
+ accept:
17
+ - a1
18
+ - a2
19
+ UncommunicativeModuleName:
20
+ accept:
21
+ - C1
22
+ UncommunicativeVariableName:
23
+ accept:
24
+ - var1
20
25
  """
21
26
  And a file named "smelly.rb" with:
22
27
  """
@@ -28,28 +33,37 @@ Feature: `accept` configuration setting
28
33
  def m2(a2); a2; end
29
34
  # Should report UncommunicativeMethodName and UncommunicativeParameterName
30
35
  def m3(a3); a3; end
36
+ var1 = 2 # Should not report UncommunicativeVariableName
37
+ myvar1 = 2 # Should not report UncommunicativeVariableName
38
+ var2 = 2 # Should report UncommunicativeVariableName
31
39
  end
32
40
  """
33
41
  When I run reek -c config.reek smelly.rb
34
42
  Then it reports:
35
43
  """
36
- smelly.rb -- 2 warnings:
44
+ smelly.rb -- 3 warnings:
37
45
  [8]:UncommunicativeMethodName: C1#m3 has the name 'm3'
38
46
  [8]:UncommunicativeParameterName: C1#m3 has the parameter name 'a3'
47
+ [11]:UncommunicativeVariableName: C1 has the variable name 'var2'
39
48
  """
40
49
 
41
- Scenario: Accept regexes as list and as single item
50
+ Scenario: Accept regexes
42
51
  Given a file named "config.reek" with:
43
52
  """
44
53
  ---
45
- UncommunicativeMethodName:
46
- accept:
47
- - !ruby/regexp /oobar/
48
- UncommunicativeParameterName:
49
- accept:
50
- - !ruby/regexp /ola/
51
- UncommunicativeModuleName:
52
- accept: !ruby/regexp /lassy/
54
+ detectors:
55
+ UncommunicativeMethodName:
56
+ accept:
57
+ - /oobar/
58
+ UncommunicativeParameterName:
59
+ accept:
60
+ - /ola/
61
+ UncommunicativeModuleName:
62
+ accept:
63
+ - /lassy/
64
+ UncommunicativeVariableName:
65
+ accept:
66
+ - /^var1/
53
67
  """
54
68
  And a file named "smelly.rb" with:
55
69
  """
@@ -59,12 +73,15 @@ Feature: `accept` configuration setting
59
73
  def foobar1(hola1); hola1; end
60
74
  # Should report UncommunicativeMethodName and UncommunicativeParameterName
61
75
  def m2(a2); a2; end
76
+ var1 = 2 # Should not report UncommunicativeVariableName
77
+ myvar1 = 2 # Should report UncommunicativeVariableName
62
78
  end
63
79
  """
64
80
  When I run reek -c config.reek smelly.rb
65
81
  Then it reports:
66
82
  """
67
- smelly.rb -- 2 warnings:
83
+ smelly.rb -- 3 warnings:
68
84
  [6]:UncommunicativeMethodName: Classy1#m2 has the name 'm2'
69
85
  [6]:UncommunicativeParameterName: Classy1#m2 has the parameter name 'a2'
86
+ [8]:UncommunicativeVariableName: Classy1 has the variable name 'myvar1'
70
87
  """
@@ -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
  """
@@ -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
  """
@@ -79,17 +81,18 @@ Feature: Directory directives
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
  """
@@ -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
  """
@@ -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
  """
@@ -194,19 +200,17 @@ Feature: Directory directives
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
  """
@@ -217,7 +221,7 @@ Feature: Directory directives
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
  """
@@ -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
  """
@@ -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
 
@@ -34,7 +37,17 @@ Feature: Masking smells using config files
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
@@ -53,13 +66,29 @@ Feature: Masking smells using config files
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?)
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