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
@@ -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
  """
@@ -34,14 +35,15 @@ Feature: Mix `accept` and `reject` configuration settings
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
  """
@@ -60,12 +62,13 @@ Feature: Mix `accept` and `reject` configuration settings
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
  """
@@ -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
40
  When I run reek -c config.reek smelly.rb
34
41
  Then it reports:
35
42
  """
36
- smelly.rb -- 5 warnings:
43
+ smelly.rb -- 6 warnings:
37
44
  [4]:UncommunicativeMethodName: Dummy#awesome_helper has the name 'awesome_helper'
38
45
  [6]:UncommunicativeMethodName: Dummy#little_helper has the name 'little_helper'
39
46
  [2]:UncommunicativeModuleName: Dummy has the name 'Dummy'
40
47
  [4]:UncommunicativeParameterName: Dummy#awesome_helper has the parameter name 'solid_argument'
41
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
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'
74
- [6]:UncommunicativeMethodName: Dummy#little_helper has the name 'little_helper'
75
- [2]:UncommunicativeModuleName: Dummy has the name 'Dummy'
76
- [4]:UncommunicativeParameterName: Dummy#awesome_helper has the parameter name 'solid_argument'
77
- [6]:UncommunicativeParameterName: Dummy#little_helper has the parameter name 'nifty_argument'
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
  """
@@ -38,12 +39,13 @@ Feature: Unused Private Method detector
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
  """
@@ -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.
@@ -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
43
62
  Then the exit status indicates smells
44
63
  And it reports:
45
64
  """
46
65
  smelly.rb -- 1 warning:
47
66
  [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
48
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
86
+ Then the exit status indicates smells
87
+ And it reports:
88
+ """
89
+ smelly.rb -- 1 warning:
90
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
91
+ """
@@ -10,7 +10,7 @@ Feature: Reek can be driven through its Task
10
10
 
11
11
  Reek::Rake::Task.new do |t|
12
12
  t.source_files = 'smelly.rb'
13
- t.reek_opts = '--no-color --no-wiki-links'
13
+ t.reek_opts = '--no-color --no-documentation'
14
14
  end
15
15
  """
16
16
  When I run `rake reek`
@@ -30,7 +30,7 @@ Feature: Reek can be driven through its Task
30
30
 
31
31
  Reek::Rake::Task.new do |t|
32
32
  t.source_files = FileList['smelly.*']
33
- t.reek_opts = '--no-color --no-wiki-links'
33
+ t.reek_opts = '--no-color --no-documentation'
34
34
  end
35
35
  """
36
36
  When I run `rake reek`
@@ -50,7 +50,7 @@ Feature: Reek can be driven through its Task
50
50
 
51
51
  Reek::Rake::Task.new('silky') do |t|
52
52
  t.source_files = 'smelly.rb'
53
- t.reek_opts = '--no-color --no-wiki-links'
53
+ t.reek_opts = '--no-color --no-documentation'
54
54
  end
55
55
  """
56
56
  When I run `rake silky`
@@ -86,7 +86,7 @@ Feature: Reek can be driven through its Task
86
86
  Reek::Rake::Task.new do |t|
87
87
  t.fail_on_error = false
88
88
  t.source_files = 'smelly.rb'
89
- t.reek_opts = '--no-color --no-wiki-links'
89
+ t.reek_opts = '--no-color --no-documentation'
90
90
  end
91
91
  """
92
92
  When I run `rake reek`
@@ -124,7 +124,7 @@ Feature: Reek can be driven through its Task
124
124
 
125
125
  Reek::Rake::Task.new do |t|
126
126
  t.source_files = 'clean.rb'
127
- t.reek_opts = '--no-color --no-wiki-links'
127
+ t.reek_opts = '--no-color --no-documentation'
128
128
  end
129
129
  """
130
130
  When I set the environment variable "REEK_SRC" to "smelly.rb"
@@ -24,6 +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
+ "documentation_link": "https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Method-Name.md",
27
28
  "name": "x"
28
29
  },
29
30
  {
@@ -32,6 +33,7 @@ Feature: Report smells using simple JSON layout
32
33
  "context": "Smelly#x",
33
34
  "lines": [ 5 ],
34
35
  "message": "has the variable name 'y'",
36
+ "documentation_link": "https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Variable-Name.md",
35
37
  "name": "y"
36
38
  }
37
39
  ]
@@ -50,7 +52,8 @@ Feature: Report smells using simple JSON layout
50
52
  "lines": [
51
53
  1
52
54
  ],
53
- "message": "has no descriptive comment"
55
+ "message": "has no descriptive comment",
56
+ "documentation_link": "https://github.com/troessner/reek/blob/v5.0.0/docs/Irresponsible-Module.md"
54
57
  }
55
58
  ]
56
59
  """
@@ -175,25 +175,25 @@ Feature: Correctly formatted reports
175
175
  | smelly/ |
176
176
  | smelly |
177
177
 
178
- Scenario Outline: -U or --wiki-links adds helpful links to smell warnings
178
+ Scenario Outline: -U or --documentation adds helpful links to smell warnings
179
179
  Given the smelly file 'smelly.rb'
180
180
  When I run reek <option> smelly.rb
181
181
  Then the exit status indicates smells
182
182
  And it reports:
183
183
  """
184
184
  smelly.rb -- 2 warnings:
185
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v4.8.1/docs/Uncommunicative-Method-Name.md]
186
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v4.8.1/docs/Uncommunicative-Variable-Name.md]
185
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Method-Name.md]
186
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Variable-Name.md]
187
187
  """
188
188
 
189
189
  Examples:
190
- | option |
191
- | -U |
192
- | --wiki-links |
190
+ | option |
191
+ | -U |
192
+ | --documentation |
193
193
 
194
- Scenario: --no-wiki-links drops links from smell warnings
194
+ Scenario: --no-documentation drops links from smell warnings
195
195
  Given the smelly file 'smelly.rb'
196
- When I run reek --no-wiki-links smelly.rb
196
+ When I run reek --no-documentation smelly.rb
197
197
  Then the exit status indicates smells
198
198
  And it reports:
199
199
  """
@@ -202,18 +202,18 @@ Feature: Correctly formatted reports
202
202
  [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
203
203
  """
204
204
 
205
- Scenario Outline: --wiki-links is independent of --line-numbers
205
+ Scenario Outline: --documentation is independent of --line-numbers
206
206
  Given the smelly file 'smelly.rb'
207
207
  When I run reek <option> smelly.rb
208
208
  Then the exit status indicates smells
209
209
  And it reports:
210
210
  """
211
211
  smelly.rb -- 2 warnings:
212
- UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v4.8.1/docs/Uncommunicative-Method-Name.md]
213
- UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v4.8.1/docs/Uncommunicative-Variable-Name.md]
212
+ UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Method-Name.md]
213
+ UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.0.0/docs/Uncommunicative-Variable-Name.md]
214
214
  """
215
215
 
216
216
  Examples:
217
217
  | option |
218
218
  | --no-line-numbers -U |
219
- | --no-line-numbers --wiki-links |
219
+ | --no-line-numbers --documentation |