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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 8688a1d76cc81f34b630798bdd47068e760e4a397548747194edb5e6bb42d255
4
- data.tar.gz: 850489fdbab5642d489eebae9427c5028dff6093f29551f322a44201ace1142e
2
+ SHA1:
3
+ metadata.gz: dcc26f0cc3bb682d6af4ccd125c9968049fa7659
4
+ data.tar.gz: 3f07f95ea9d5dc2d9a3228d9720aa991ac1f5232
5
5
  SHA512:
6
- metadata.gz: 8dd0a801d1ea96549e942b90d1a8552786a0b6b4d9ef1febaec2abdeb77bc747ece35d31b3ca4cf97108a268e6b2edabb4e02959c2aed72cd3d4469d5d078b4d
7
- data.tar.gz: 2d8f97017347131099c498b3dd744459bd0e7e729c29e4c274f4ed8cc5487b520402787c1ae7cc88d276597117a7ee1521cc496998ec7f805a644e0929b12bc8
6
+ metadata.gz: caeb105aa52968eb387304da206083cf07394d1f378c01a6aabf040e2aa264d0016491e69dba31910fa64982cdc8bf9902b036b63639279422c93ad934a91725
7
+ data.tar.gz: 8af65a286c9207f04770b530865755aeeca35b4162d3db66c987b0e6d5c02438faeeee3251bef91ef5e91e4b75235ec2ae23f805a07bfc64d448e7e5066610d6
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ AllCops:
6
6
  - 'samples/**/*'
7
7
  - 'tmp/**/*'
8
8
  - 'vendor/**/*'
9
- TargetRubyVersion: 2.1
9
+ TargetRubyVersion: 2.3
10
10
 
11
11
  # Place . on the previous line
12
12
  Layout/DotPosition:
@@ -60,9 +60,21 @@ Metrics/ClassLength:
60
60
  - lib/reek/context_builder.rb
61
61
  - lib/reek/cli/options.rb
62
62
 
63
+ Style/SafeNavigation:
64
+ Exclude:
65
+ - lib/reek/ast/node.rb
66
+ - lib/reek/ast/sexp_extensions/module.rb
67
+
63
68
  # FIXME: Lower the method length by fixing the biggest offenders
64
69
  Metrics/MethodLength:
65
70
  Max: 15
71
+ Exclude:
72
+ - 'lib/reek/cli/options.rb'
73
+
74
+ Metrics/AbcSize:
75
+ Exclude:
76
+ - 'lib/reek/cli/options.rb'
77
+ - 'lib/reek/configuration/configuration_converter.rb'
66
78
 
67
79
  # Be rather lenient with line length
68
80
  Metrics/LineLength:
@@ -100,8 +112,8 @@ RSpec/MultipleDescribes:
100
112
  Exclude:
101
113
  - 'spec/reek/ast/sexp_extensions_spec.rb'
102
114
  - 'spec/reek/code_comment_spec.rb'
103
- - 'spec/reek/report/formatter/location_formatter_spec.rb'
104
- - 'spec/reek/report/formatter/progress_formatter_spec.rb'
115
+ - 'spec/reek/report/location_formatter_spec.rb'
116
+ - 'spec/reek/report/progress_formatter_spec.rb'
105
117
 
106
118
  # FIXME: Update specs to avoid offenses
107
119
  RSpec/MultipleExpectations:
@@ -119,6 +131,8 @@ RSpec/NestedGroups:
119
131
  Exclude:
120
132
  - 'spec/reek/report/code_climate/code_climate_fingerprint_spec.rb'
121
133
  - 'spec/reek/cli/application_spec.rb'
134
+ - 'spec/reek/configuration/schema_validator_spec.rb'
135
+ - 'spec/reek/configuration/configuration_file_finder_spec.rb'
122
136
 
123
137
  # rubocop-rspec expects a CodeClimate namespace to go with the code_climate directory.
124
138
  RSpec/FilePath:
data/.simplecov CHANGED
@@ -1,6 +1,7 @@
1
1
  SimpleCov.start do
2
2
  track_files 'lib/**/*.rb'
3
3
  add_filter 'lib/reek/version.rb' # version.rb is loaded too early to test
4
+ add_filter 'lib/reek/cli/options.rb' # tested mostly via integration tests
4
5
  end
5
6
 
6
7
  SimpleCov.at_exit do
data/.travis.yml CHANGED
@@ -2,14 +2,9 @@ sudo: false
2
2
  dist: trusty
3
3
  cache: bundler
4
4
  language: ruby
5
- before_install:
6
- - gem update --system
7
- - gem install bundler
8
5
  bundler_args: --without debugging
9
6
  script: bundle exec rake ci
10
7
  rvm:
11
- - 2.1
12
- - 2.2
13
8
  - 2.3
14
9
  - 2.4
15
10
  - 2.5
data/.yardopts CHANGED
@@ -1,4 +1,4 @@
1
- --no-private
1
+ --private
2
2
  --readme README.md
3
3
  --load ./docs/yard_plugin.rb
4
4
  -
data/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Change log
2
2
 
3
+ ## 5.0.0 (2018-06-18)
4
+
5
+ *Breaking changes:*
6
+
7
+ * (David Fisher) Change PrimaDonnaMethod to MissingSafeMethod
8
+ * (mvz) Always include documentation in JSON and YAML
9
+ * (mvz) Remove Syntax smell detector
10
+ * (mvz) Remove deprecated Examiner#description (in favor of Examiner#origin)
11
+ * (mvz) Allow only detector names in configuration hash
12
+ * (mvz) Do not accept a class as parameter for reek_of
13
+ * (mvz) Allow only .reek.yml instead of any file name ending in .reek
14
+ * (troessner) Validate our configuration by using a schema
15
+ * (troessner) Scope detectors in the configuration under `detectors`
16
+ * (troessner) Move directory directives under a special key
17
+ * (troessner) Use strings not regexes in our configuration file
18
+ * (troessner) Replace `wiki-links` flag with `documentation` flag
19
+ * (troessner) Add yml extension to Reeks configuration file
20
+ * (troessner) Drop legacy code comment separator
21
+ * (troessner) Drop Ruby 2.2 support
22
+ * (troessner) Drop Ruby 2.1 support
23
+
24
+ *Non breaking changes:*
25
+
26
+ * (Paul Sadauskas) Add support for --stdin-filename
27
+ * (mvz) Generate versioned documentation links
28
+ * (mvz) Bugfix: Only report FeatureEnvy for instance methods
29
+ * (troessner) List all smells
30
+
3
31
  ## 4.8.2 (2018-06-26)
4
32
 
5
33
  * (mvz) Only report FeatureEnvy for instance methods
data/Gemfile CHANGED
@@ -16,7 +16,7 @@ group :development do
16
16
  gem 'yard', '~> 0.9.5'
17
17
 
18
18
  if RUBY_VERSION >= '2.3'
19
- gem 'rubocop', '~> 0.53.0'
19
+ gem 'rubocop', '~> 0.57.1'
20
20
  gem 'rubocop-rspec', '~> 1.20'
21
21
  end
22
22
 
data/README.md CHANGED
@@ -39,13 +39,18 @@
39
39
  * [![Gem Version](https://badge.fury.io/rb/reek.svg)](https://badge.fury.io/rb/reek)
40
40
  * ![](http://img.shields.io/github/tag/troessner/reek.svg)
41
41
  * ![](http://img.shields.io/badge/license-MIT-brightgreen.svg)
42
- * [![Dependency Status](https://gemnasium.com/badges/github.com/troessner/reek.svg)](https://gemnasium.com/github.com/troessner/reek)
43
42
  * [![Inline docs](https://inch-ci.org/github/troessner/reek.png)](https://inch-ci.org/github/troessner/reek)
44
43
  * [![Code Climate](https://codeclimate.com/github/troessner/reek/badges/gpa.svg)](https://codeclimate.com/github/troessner/reek)
45
44
  * [![codebeat](https://codebeat.co/badges/42fed4ff-3e55-4aed-8ecc-409b4aa539b3)](https://codebeat.co/projects/github-com-troessner-reek)
46
45
  * ![](http://ruby-gem-downloads-badge.herokuapp.com/reek?type=total)
47
46
  * ![](http://ruby-gem-downloads-badge.herokuapp.com/reek?label=downloads-current-version)
48
47
 
48
+ ## Reek 5 is out!
49
+
50
+ Reek 5 is out and with it a bunch of breaking changes. If you're a new user you can just
51
+ continue with the quickstart below. If you're a Reek 4 user and would like to upgrade to 5, don't
52
+ worry, this shouldn't take you more than 10 minutes. Check out our [Upgrade Guide](docs/Reek-4-to-Reek-5-migration.md).
53
+
49
54
  ## Quickstart
50
55
 
51
56
  Reek is a tool that examines Ruby classes, modules and methods and reports any
@@ -84,7 +89,7 @@ end
84
89
  Reek will report the following code smells in this file:
85
90
 
86
91
  ```
87
- $ reek --no-wiki-links demo.rb
92
+ $ reek --no-documentation demo.rb
88
93
  Inspecting 1 file(s):
89
94
  S
90
95
 
@@ -97,8 +102,6 @@ demo.rb -- 2 warnings:
97
102
 
98
103
  Reek is officially supported for the following CRuby versions:
99
104
 
100
- - 2.1
101
- - 2.2
102
105
  - 2.3
103
106
  - 2.4
104
107
  - 2.5
@@ -254,12 +257,13 @@ For a summary of those CLI options see [Command-Line Options](docs/Command-Line-
254
257
  #### Configuration loading
255
258
 
256
259
  Configuring Reek via a configuration file is by far the most powerful way.
260
+ Reek expects this filename to be `.reek.yml` but you can override this via the CLI `-c` switch (see below).
257
261
 
258
- There are three ways of passing Reek a configuration file:
262
+ There are three ways of passing Reek the configuration file:
259
263
 
260
264
  1. Using the CLI `-c` switch (see [_Command-line interface_](#command-line-interface) above)
261
- 2. Having a file ending with `.reek` either in your current working directory or in a parent directory (more on that later)
262
- 3. Having a file ending with `.reek` in your home directory
265
+ 2. Having the configuration file either in your current working directory or in a parent directory (more on that later)
266
+ 3. Having the configuration file in your home directory
263
267
 
264
268
  The order in which Reek tries to find such a configuration
265
269
  file is exactly the above: first it checks if we have given
@@ -277,43 +281,46 @@ of how many `*.reek` files you might have on your filesystem.
277
281
 
278
282
  We put a lot of effort into making Reek's configuration as self explanatory as possible so the
279
283
  best way to understand it is by looking at a simple
280
- example (e.g. `config.reek` in your project directory):
284
+ example (e.g. `.reek.yml` in your project directory):
281
285
 
282
286
  ```yaml
283
287
  ---
284
288
 
285
289
  ### Generic smell configuration
286
290
 
287
- # You can disable smells completely
288
- IrresponsibleModule:
289
- enabled: false
290
-
291
- # You can use filters to silence Reek warnings.
292
- # Either because you simply disagree with Reek (we are not the police) or
293
- # because you want to fix this at a later point in time.
294
- NestedIterators:
295
- exclude:
296
- - "MyWorker#self.class_method" # should be refactored
297
- - "AnotherWorker#instance_method" # should be refactored as well
298
-
299
- # A lot of smells allow fine tuning their configuration. You can look up all available options
300
- # in the corresponding smell documentation in /docs. In most cases you probably can just go
301
- # with the defaults as documented in defaults.reek.
302
- DataClump:
303
- max_copies: 3
304
- min_clump_size: 3
291
+ detectors:
292
+ # You can disable smells completely
293
+ IrresponsibleModule:
294
+ enabled: false
295
+
296
+ # You can use filters to silence Reek warnings.
297
+ # Either because you simply disagree with Reek (we are not the police) or
298
+ # because you want to fix this at a later point in time.
299
+ NestedIterators:
300
+ exclude:
301
+ - "MyWorker#self.class_method" # should be refactored
302
+ - "AnotherWorker#instance_method" # should be refactored as well
303
+
304
+ # A lot of smells allow fine tuning their configuration. You can look up all available options
305
+ # in the corresponding smell documentation in /docs. In most cases you probably can just go
306
+ # with the defaults as documented in defaults.reek.yml.
307
+ DataClump:
308
+ max_copies: 3
309
+ min_clump_size: 3
305
310
 
306
311
  ### Directory specific configuration
307
312
 
308
313
  # You can configure smells on a per-directory base.
309
314
  # E.g. the classic Rails case: controllers smell of NestedIterators (see /docs/Nested-Iterators.md) and
310
315
  # helpers smell of UtilityFunction (see docs/Utility-Function.md)
311
- "web_app/app/controllers":
312
- NestedIterators:
313
- enabled: false
314
- "web_app/app/helpers":
315
- UtilityFunction:
316
- enabled: false
316
+ # Note that we only allow configuration on a directory level, not a file level, so all paths have to point to directories.
317
+ directories:
318
+ "web_app/app/controllers":
319
+ NestedIterators:
320
+ enabled: false
321
+ "web_app/app/helpers":
322
+ UtilityFunction:
323
+ enabled: false
317
324
 
318
325
  ### Excluding directories
319
326
 
@@ -323,6 +330,14 @@ exclude_paths:
323
330
  - lib/rake/legacy_tasks
324
331
  ```
325
332
 
333
+ As you see above, Reek's configuration consists of 3 different sections denoted by 3 different keys:
334
+
335
+ * detectors
336
+ * directories
337
+ * exclude_paths
338
+
339
+ Whatever you add to your configuration should be scoped under one of those keys.
340
+
326
341
  If you have a directory directive for which a default directive exists, the more specific
327
342
  one (which is the directory directive) will take precedence.
328
343
 
@@ -330,15 +345,12 @@ This configuration for instance:
330
345
 
331
346
  ```yaml
332
347
  ---
333
- IrresponsibleModule:
334
- enabled: false
335
-
336
- TooManyStatements:
337
- max_statements: 5
338
-
339
- "app/controllers":
348
+ detectors:
349
+ IrresponsibleModule:
350
+ enabled: false
351
+
340
352
  TooManyStatements:
341
- max_statements: 10
353
+ max_statements: 5
342
354
  ```
343
355
 
344
356
  translates to:
@@ -347,16 +359,53 @@ translates to:
347
359
  * TooManyStatements#max_statements is 10 in "app/controllers"
348
360
  * TooManyStatements#max_statements is 5 everywhere else
349
361
 
350
- For more details please check out the [Basic Smell Options](docs/Basic-Smell-Options.md)
351
- which are supported by every smell type. As you can see above, certain smell
352
- types offer a configuration that goes beyond that of the basic smell options, for instance
362
+ Every smell detector supports our [Basic Smell Options](docs/Basic-Smell-Options.md). As you can see above,
363
+ certain smell types offer a configuration that goes beyond that of the basic smell options, for instance
353
364
  [Data Clump](docs/Data-Clump.md).
354
365
  All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md)
355
366
  are documented in the corresponding smell type /docs page (if you want to get a quick overview over all possible
356
- configurations you can also check out [the `default.reek` file in this repository](defaults.reek).
367
+ configurations you can also check out [the `defaults.reek.yml` file in this repository](docs/defaults.reek.yml).
357
368
 
358
369
  Note that you do not need a configuration file at all.
359
- If you're fine with all the [defaults](defaults.reek) we set you can skip this completely.
370
+ If you're fine with all the [defaults.reek.yml](docs/defaults.reek.yml) we set you can skip this completely.
371
+
372
+ Don't worry about introducing a mistake in your configuration file that might go unnoticed - Reek uses a
373
+ schema to validate your configuration against on start up and will faily loudly in case you
374
+ misspelled an option or used the wrong data type for a value like this:
375
+
376
+ ```
377
+ Error: We found some problems with your configuration file: [/detectors/DetectorWithTypo] key 'DetectorWithTypo:' is undefined.
378
+ ```
379
+
380
+ Reek takes one configuration file and one configuration file only with `.reek.yml` being the default name.
381
+
382
+ In case you have to have one or more configuration files in the directory (e.g. you're
383
+ toying around with different, mutually exclusive settings) you need to tell Reek
384
+ explicitly which file to use via `reek -c config.reek`.
385
+
386
+ ### Source code comments
387
+
388
+ In case you need to suppress a smell warning and you can't or don't want to
389
+ use configuration files for whatever reasons you can also use special
390
+ source code comments like this:
391
+
392
+ ```Ruby
393
+ # This method smells of :reek:NestedIterators
394
+ def smelly_method foo
395
+ foo.each {|bar| bar.each {|baz| baz.qux}}
396
+ end
397
+ ```
398
+
399
+ You can even pass in smell specific configuration settings:
400
+
401
+ ```Ruby
402
+ # :reek:NestedIterators { max_allowed_nesting: 2 }
403
+ def smelly_method foo
404
+ foo.each {|bar| bar.each {|baz| baz.qux}}
405
+ end
406
+ ```
407
+
408
+ This is an incredibly powerful feature and further explained under [Smell Suppresion](docs/Smell-Suppression.md).
360
409
 
361
410
  ### Generating a 'todo' list
362
411
 
@@ -404,42 +453,6 @@ reek -c other_configuration.reek --todo lib/
404
453
  `other_configuration.reek` will simply be ignored (as outlined before, Reek
405
454
  is supposed to have one configuration file and one file only).
406
455
 
407
- ### Beware of multiple configuration files
408
-
409
- Reek takes one configuration file and one configuration file only.
410
-
411
- If you have more than one configuration file in the same directory Reek
412
- will not know what configuration file to use. If this happens Reek will
413
- print a warning on STDERR and exit with the failure exit status 1.
414
-
415
- In case you have to have one or more configuration files in the directory (e.g. you're
416
- toying around with different, mutually exclusive settings) you need to tell Reek
417
- explicitly which file to use via `reek -c config.reek`.
418
-
419
- ### Source code comments
420
-
421
- In case you need to suppress a smell warning and you can't or don't want to
422
- use configuration files for whatever reasons you can also use special
423
- source code comments like this:
424
-
425
- ```Ruby
426
- # This method smells of :reek:NestedIterators
427
- def smelly_method foo
428
- foo.each {|bar| bar.each {|baz| baz.qux}}
429
- end
430
- ```
431
-
432
- You can even pass in smell specific configuration settings:
433
-
434
- ```Ruby
435
- # :reek:NestedIterators { max_allowed_nesting: 2 }
436
- def smelly_method foo
437
- foo.each {|bar| bar.each {|baz| baz.qux}}
438
- end
439
- ```
440
-
441
- This is an incredible powerful feature and further explained under [Smell Suppresion](docs/Smell-Suppression.md).
442
-
443
456
  ## Usage
444
457
 
445
458
  Besides the obvious
@@ -559,23 +572,24 @@ Making Reek "Rails"-friendly is fairly simple since we support directory specifi
559
572
  Just add this to your configuration file:
560
573
 
561
574
  ```Yaml
562
- "app/controllers":
563
- IrresponsibleModule:
564
- enabled: false
565
- NestedIterators:
566
- max_allowed_nesting: 2
567
- UnusedPrivateMethod:
568
- enabled: false
569
- InstanceVariableAssumption:
570
- enabled: false
571
- "app/helpers":
572
- IrresponsibleModule:
573
- enabled: false
574
- UtilityFunction:
575
- enabled: false
576
- "app/mailers":
577
- InstanceVariableAssumption:
578
- enabled: false
575
+ directories:
576
+ "app/controllers":
577
+ IrresponsibleModule:
578
+ enabled: false
579
+ NestedIterators:
580
+ max_allowed_nesting: 2
581
+ UnusedPrivateMethod:
582
+ enabled: false
583
+ InstanceVariableAssumption:
584
+ enabled: false
585
+ "app/helpers":
586
+ IrresponsibleModule:
587
+ enabled: false
588
+ UtilityFunction:
589
+ enabled: false
590
+ "app/mailers":
591
+ InstanceVariableAssumption:
592
+ enabled: false
579
593
  ```
580
594
 
581
595
  Be careful though, Reek does not merge your configuration entries, so if you already have a directory directive for "app/controllers" or "app/helpers" you need to update those directives instead of copying the above YAML sample into your configuration file.
@@ -588,6 +602,7 @@ Be careful though, Reek does not merge your configuration entries, so if you alr
588
602
  * [TextMate Bundle](https://github.com/peeyush1234/reek.tmbundle)
589
603
  * [Atom plugin](https://atom.io/packages/linter-reek)
590
604
  * [SublimeLinter plugin](https://packagecontrol.io/packages/SublimeLinter-contrib-reek)
605
+ * [VS Code plugin](https://github.com/rubyide/vscode-ruby)
591
606
  * [Emacs plugin](https://github.com/hanmoi-choi/reek-emacs)
592
607
 
593
608
  ### Projects that use or support us