reek 4.7.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +17 -12
  3. data/.rubocop.yml +36 -7
  4. data/.simplecov +1 -0
  5. data/.travis.yml +3 -9
  6. data/.yardopts +1 -1
  7. data/CHANGELOG.md +59 -0
  8. data/CONTRIBUTING.md +1 -1
  9. data/Gemfile +5 -5
  10. data/README.md +134 -104
  11. data/Rakefile +16 -3
  12. data/bin/reek +1 -3
  13. data/docs/API.md +2 -9
  14. data/docs/Basic-Smell-Options.md +51 -11
  15. data/docs/Code-Smells.md +1 -1
  16. data/docs/Command-Line-Options.md +14 -4
  17. data/docs/Duplicate-Method-Call.md +49 -1
  18. data/docs/Feature-Envy.md +44 -0
  19. data/docs/How-To-Write-New-Detectors.md +7 -7
  20. data/docs/Instance-Variable-Assumption.md +1 -1
  21. data/docs/{Prima-Donna-Method.md → Missing-Safe-Method.md} +11 -9
  22. data/docs/Rake-Task.md +1 -1
  23. data/docs/Reek-4-to-Reek-5-migration.md +193 -0
  24. data/docs/Reek-Driven-Development.md +1 -1
  25. data/docs/Uncommunicative-Method-Name.md +45 -6
  26. data/docs/Uncommunicative-Module-Name.md +49 -7
  27. data/docs/Uncommunicative-Parameter-Name.md +43 -5
  28. data/docs/Uncommunicative-Variable-Name.md +73 -2
  29. data/docs/Unused-Private-Method.md +3 -3
  30. data/docs/defaults.reek.yml +129 -0
  31. data/docs/yard_plugin.rb +1 -0
  32. data/features/command_line_interface/basic_usage.feature +2 -2
  33. data/features/command_line_interface/options.feature +46 -4
  34. data/features/command_line_interface/show_progress.feature +4 -4
  35. data/features/command_line_interface/smell_selection.feature +1 -1
  36. data/features/command_line_interface/smells_count.feature +6 -6
  37. data/features/command_line_interface/stdin.feature +30 -8
  38. data/features/configuration_files/accept_setting.feature +45 -28
  39. data/features/configuration_files/directory_specific_directives.feature +80 -75
  40. data/features/configuration_files/exclude_directives.feature +11 -10
  41. data/features/configuration_files/exclude_paths_directives.feature +4 -4
  42. data/features/configuration_files/masking_smells.feature +38 -9
  43. data/features/configuration_files/mix_accept_reject_setting.feature +31 -28
  44. data/features/configuration_files/reject_setting.feature +52 -41
  45. data/features/configuration_files/schema_validation.feature +59 -0
  46. data/features/configuration_files/unused_private_method.feature +18 -16
  47. data/features/configuration_loading.feature +53 -10
  48. data/features/configuration_via_source_comments/erroneous_source_comments.feature +3 -3
  49. data/features/configuration_via_source_comments/well_formed_source_comments.feature +2 -2
  50. data/features/locales.feature +32 -0
  51. data/features/rake_task/rake_task.feature +58 -18
  52. data/features/reports/json.feature +3 -3
  53. data/features/reports/reports.feature +34 -34
  54. data/features/reports/yaml.feature +3 -3
  55. data/features/rspec_matcher.feature +40 -0
  56. data/features/samples.feature +287 -287
  57. data/features/step_definitions/reek_steps.rb +2 -2
  58. data/features/step_definitions/sample_file_steps.rb +9 -4
  59. data/features/support/env.rb +2 -11
  60. data/features/todo_list.feature +26 -23
  61. data/lib/reek/ast/builder.rb +1 -1
  62. data/lib/reek/ast/node.rb +40 -58
  63. data/lib/reek/ast/object_refs.rb +1 -1
  64. data/lib/reek/ast/reference_collector.rb +2 -4
  65. data/lib/reek/ast/sexp_extensions/case.rb +1 -1
  66. data/lib/reek/ast/sexp_extensions/if.rb +8 -1
  67. data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -1
  68. data/lib/reek/ast/sexp_extensions/methods.rb +4 -6
  69. data/lib/reek/ast/sexp_extensions/send.rb +0 -4
  70. data/lib/reek/cli/application.rb +4 -3
  71. data/lib/reek/cli/command/report_command.rb +1 -2
  72. data/lib/reek/cli/command/todo_list_command.rb +8 -8
  73. data/lib/reek/cli/options.rb +31 -16
  74. data/lib/reek/cli/silencer.rb +14 -3
  75. data/lib/reek/code_comment.rb +14 -16
  76. data/lib/reek/configuration/app_configuration.rb +32 -27
  77. data/lib/reek/configuration/configuration_converter.rb +110 -0
  78. data/lib/reek/configuration/configuration_file_finder.rb +16 -41
  79. data/lib/reek/configuration/configuration_validator.rb +12 -23
  80. data/lib/reek/configuration/default_directive.rb +17 -3
  81. data/lib/reek/configuration/directory_directives.rb +17 -11
  82. data/lib/reek/configuration/excluded_paths.rb +1 -1
  83. data/lib/reek/configuration/rake_task_converter.rb +29 -0
  84. data/lib/reek/configuration/schema.yml +210 -0
  85. data/lib/reek/configuration/schema_validator.rb +38 -0
  86. data/lib/reek/context/attribute_context.rb +3 -3
  87. data/lib/reek/context/code_context.rb +47 -43
  88. data/lib/reek/context/ghost_context.rb +0 -2
  89. data/lib/reek/context/method_context.rb +22 -15
  90. data/lib/reek/context/module_context.rb +5 -9
  91. data/lib/reek/context/root_context.rb +0 -4
  92. data/lib/reek/context/send_context.rb +2 -2
  93. data/lib/reek/context_builder.rb +43 -44
  94. data/lib/reek/detector_repository.rb +11 -11
  95. data/lib/reek/documentation_link.rb +28 -0
  96. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +14 -13
  97. data/lib/reek/errors/bad_detector_in_comment_error.rb +12 -11
  98. data/lib/reek/errors/base_error.rb +3 -0
  99. data/lib/reek/errors/config_file_error.rb +11 -0
  100. data/lib/reek/errors/encoding_error.rb +43 -0
  101. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +13 -12
  102. data/lib/reek/errors/incomprehensible_source_error.rb +22 -24
  103. data/lib/reek/errors/syntax_error.rb +41 -0
  104. data/lib/reek/examiner.rb +24 -26
  105. data/lib/reek/logging_error_handler.rb +7 -5
  106. data/lib/reek/rake/task.rb +8 -4
  107. data/lib/reek/report/base_report.rb +8 -12
  108. data/lib/reek/report/code_climate/code_climate_configuration.rb +1 -1
  109. data/lib/reek/report/code_climate/code_climate_configuration.yml +6 -10
  110. data/lib/reek/report/documentation_link_warning_formatter.rb +17 -0
  111. data/lib/reek/report/heading_formatter.rb +54 -0
  112. data/lib/reek/report/json_report.rb +1 -1
  113. data/lib/reek/report/location_formatter.rb +40 -0
  114. data/lib/reek/report/progress_formatter.rb +79 -0
  115. data/lib/reek/report/simple_warning_formatter.rb +34 -0
  116. data/lib/reek/report/text_report.rb +1 -2
  117. data/lib/reek/report/xml_report.rb +3 -3
  118. data/lib/reek/report/yaml_report.rb +1 -1
  119. data/lib/reek/report.rb +15 -10
  120. data/lib/reek/smell_configuration.rb +2 -2
  121. data/lib/reek/smell_detectors/attribute.rb +5 -11
  122. data/lib/reek/smell_detectors/base_detector.rb +30 -26
  123. data/lib/reek/smell_detectors/boolean_parameter.rb +3 -5
  124. data/lib/reek/smell_detectors/class_variable.rb +5 -14
  125. data/lib/reek/smell_detectors/control_parameter.rb +18 -33
  126. data/lib/reek/smell_detectors/data_clump.rb +15 -9
  127. data/lib/reek/smell_detectors/duplicate_method_call.rb +23 -17
  128. data/lib/reek/smell_detectors/feature_envy.rb +9 -7
  129. data/lib/reek/smell_detectors/instance_variable_assumption.rb +14 -23
  130. data/lib/reek/smell_detectors/irresponsible_module.rb +5 -12
  131. data/lib/reek/smell_detectors/long_parameter_list.rb +10 -7
  132. data/lib/reek/smell_detectors/long_yield_list.rb +10 -7
  133. data/lib/reek/smell_detectors/manual_dispatch.rb +4 -5
  134. data/lib/reek/smell_detectors/{prima_donna_method.rb → missing_safe_method.rb} +20 -20
  135. data/lib/reek/smell_detectors/module_initialize.rb +3 -5
  136. data/lib/reek/smell_detectors/nested_iterators.rb +16 -24
  137. data/lib/reek/smell_detectors/nil_check.rb +8 -15
  138. data/lib/reek/smell_detectors/repeated_conditional.rb +13 -11
  139. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +7 -8
  140. data/lib/reek/smell_detectors/too_many_constants.rb +10 -9
  141. data/lib/reek/smell_detectors/too_many_instance_variables.rb +10 -6
  142. data/lib/reek/smell_detectors/too_many_methods.rb +11 -7
  143. data/lib/reek/smell_detectors/too_many_statements.rb +10 -6
  144. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +10 -11
  145. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +14 -18
  146. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +17 -22
  147. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +26 -27
  148. data/lib/reek/smell_detectors/unused_parameters.rb +4 -6
  149. data/lib/reek/smell_detectors/unused_private_method.rb +11 -18
  150. data/lib/reek/smell_detectors/utility_function.rb +12 -16
  151. data/lib/reek/smell_detectors.rb +1 -2
  152. data/lib/reek/smell_warning.rb +15 -8
  153. data/lib/reek/source/source_code.rb +57 -58
  154. data/lib/reek/source/source_locator.rb +8 -8
  155. data/lib/reek/spec/should_reek.rb +2 -2
  156. data/lib/reek/spec/should_reek_of.rb +9 -16
  157. data/lib/reek/spec/should_reek_only_of.rb +4 -4
  158. data/lib/reek/spec.rb +6 -6
  159. data/lib/reek/tree_dresser.rb +8 -8
  160. data/lib/reek/version.rb +1 -1
  161. data/reek.gemspec +5 -7
  162. data/samples/checkstyle.xml +1 -1
  163. data/samples/configuration/accepts_rejects_and_excludes_for_detectors.reek.yml +29 -0
  164. data/samples/configuration/accepts_rejects_and_excludes_for_directory_directives.reek.yml +30 -0
  165. data/samples/configuration/full_configuration.reek +8 -4
  166. data/samples/configuration/full_mask.reek +5 -4
  167. data/samples/configuration/partial_mask.reek +3 -2
  168. data/samples/configuration/regular_configuration/.reek.yml +4 -0
  169. data/samples/paths.rb +5 -4
  170. data/samples/source_with_hidden_directories/.hidden/hidden.rb +1 -0
  171. data/samples/source_with_hidden_directories/not_hidden.rb +1 -0
  172. data/spec/factories/factories.rb +2 -13
  173. data/spec/reek/ast/node_spec.rb +103 -10
  174. data/spec/reek/ast/reference_collector_spec.rb +1 -1
  175. data/spec/reek/ast/sexp_extensions_spec.rb +14 -34
  176. data/spec/reek/cli/application_spec.rb +52 -42
  177. data/spec/reek/cli/command/todo_list_command_spec.rb +6 -4
  178. data/spec/reek/cli/silencer_spec.rb +28 -0
  179. data/spec/reek/code_comment_spec.rb +31 -38
  180. data/spec/reek/configuration/app_configuration_spec.rb +46 -33
  181. data/spec/reek/configuration/configuration_file_finder_spec.rb +133 -51
  182. data/spec/reek/configuration/default_directive_spec.rb +1 -1
  183. data/spec/reek/configuration/directory_directives_spec.rb +6 -7
  184. data/spec/reek/configuration/excluded_paths_spec.rb +6 -6
  185. data/spec/reek/configuration/rake_task_converter_spec.rb +33 -0
  186. data/spec/reek/configuration/schema_validator_spec.rb +165 -0
  187. data/spec/reek/context/code_context_spec.rb +70 -106
  188. data/spec/reek/context/ghost_context_spec.rb +9 -9
  189. data/spec/reek/context/method_context_spec.rb +2 -2
  190. data/spec/reek/context/module_context_spec.rb +3 -3
  191. data/spec/reek/context/root_context_spec.rb +1 -1
  192. data/spec/reek/context_builder_spec.rb +20 -0
  193. data/spec/reek/documentation_link_spec.rb +20 -0
  194. data/spec/reek/errors/base_error_spec.rb +13 -0
  195. data/spec/reek/examiner_spec.rb +136 -29
  196. data/spec/reek/rake/task_spec.rb +25 -2
  197. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +82 -80
  198. data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +6 -6
  199. data/spec/reek/report/json_report_spec.rb +13 -46
  200. data/spec/reek/report/{formatter/location_formatter_spec.rb → location_formatter_spec.rb} +5 -5
  201. data/spec/reek/report/{formatter/progress_formatter_spec.rb → progress_formatter_spec.rb} +4 -4
  202. data/spec/reek/report/text_report_spec.rb +4 -4
  203. data/spec/reek/report/xml_report_spec.rb +3 -3
  204. data/spec/reek/report/yaml_report_spec.rb +9 -38
  205. data/spec/reek/report_spec.rb +3 -3
  206. data/spec/reek/smell_detectors/base_detector_spec.rb +4 -5
  207. data/spec/reek/smell_detectors/boolean_parameter_spec.rb +2 -2
  208. data/spec/reek/smell_detectors/class_variable_spec.rb +26 -32
  209. data/spec/reek/smell_detectors/control_parameter_spec.rb +34 -4
  210. data/spec/reek/smell_detectors/duplicate_method_call_spec.rb +3 -3
  211. data/spec/reek/smell_detectors/feature_envy_spec.rb +47 -2
  212. data/spec/reek/smell_detectors/irresponsible_module_spec.rb +0 -11
  213. data/spec/reek/smell_detectors/{prima_donna_method_spec.rb → missing_safe_method_spec.rb} +10 -10
  214. data/spec/reek/smell_detectors/module_initialize_spec.rb +14 -0
  215. data/spec/reek/smell_detectors/nested_iterators_spec.rb +1 -1
  216. data/spec/reek/smell_detectors/too_many_constants_spec.rb +3 -3
  217. data/spec/reek/smell_detectors/too_many_instance_variables_spec.rb +1 -1
  218. data/spec/reek/smell_detectors/uncommunicative_method_name_spec.rb +6 -6
  219. data/spec/reek/smell_detectors/uncommunicative_module_name_spec.rb +6 -4
  220. data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +36 -15
  221. data/spec/reek/smell_detectors/uncommunicative_variable_name_spec.rb +9 -9
  222. data/spec/reek/smell_detectors/unused_parameters_spec.rb +3 -3
  223. data/spec/reek/smell_detectors/unused_private_method_spec.rb +21 -10
  224. data/spec/reek/smell_detectors/utility_function_spec.rb +57 -5
  225. data/spec/reek/smell_warning_spec.rb +12 -8
  226. data/spec/reek/source/source_code_spec.rb +22 -21
  227. data/spec/reek/source/source_locator_spec.rb +17 -17
  228. data/spec/reek/spec/should_reek_of_spec.rb +25 -29
  229. data/spec/reek/spec/should_reek_only_of_spec.rb +2 -2
  230. data/spec/reek/spec/should_reek_spec.rb +8 -8
  231. data/spec/reek/spec/smell_matcher_spec.rb +23 -23
  232. data/spec/reek/tree_dresser_spec.rb +12 -17
  233. data/spec/spec_helper.rb +6 -17
  234. data/tasks/configuration.rake +8 -5
  235. metadata +74 -41
  236. data/defaults.reek +0 -131
  237. data/features/configuration_files/warn_about_multiple_configuration_files.feature +0 -44
  238. data/lib/reek/report/formatter/heading_formatter.rb +0 -52
  239. data/lib/reek/report/formatter/location_formatter.rb +0 -42
  240. data/lib/reek/report/formatter/progress_formatter.rb +0 -81
  241. data/lib/reek/report/formatter/simple_warning_formatter.rb +0 -35
  242. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +0 -36
  243. data/lib/reek/report/formatter.rb +0 -33
  244. data/lib/reek/smell_detectors/syntax.rb +0 -37
  245. data/samples/configuration/non_public_modifiers_mask.reek +0 -3
  246. data/samples/smelly_with_inline_mask.rb +0 -8
  247. data/samples/smelly_with_modifiers.rb +0 -12
  248. data/samples/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -5
  249. data/samples/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -6
  250. data/spec/reek/smell_detectors/syntax_spec.rb +0 -17
  251. /data/{samples/configuration/more_than_one_configuration_file/regular.reek → .reek.yml} +0 -0
  252. /data/samples/{clean.rb → clean_source/clean.rb} +0 -0
  253. /data/samples/{exceptions.reek → configuration/home/home.reek.yml} +0 -0
  254. /data/samples/configuration/{more_than_one_configuration_file/todo.reek → regular_configuration/empty_sub_directory/.gitignore} +0 -0
  255. /data/samples/{configuration/single_configuration_file/.reek → no_config_file/.keep} +0 -0
  256. /data/samples/{inline.rb → smelly_source/inline.rb} +0 -0
  257. /data/samples/{optparse.rb → smelly_source/optparse.rb} +0 -0
  258. /data/samples/{redcloth.rb → smelly_source/redcloth.rb} +0 -0
  259. /data/samples/{smelly.rb → smelly_source/smelly.rb} +0 -0
  260. /data/samples/{source_with_hidden_directories/uncommunicative_parameter_name.rb → source_with_non_ruby_files/ruby.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: baf611107a9ba063fb9882a312ae27c556f4a4f6
4
- data.tar.gz: f56386a2775e1a178a1df9af568055c5ac63c80f
3
+ metadata.gz: dcc26f0cc3bb682d6af4ccd125c9968049fa7659
4
+ data.tar.gz: 3f07f95ea9d5dc2d9a3228d9720aa991ac1f5232
5
5
  SHA512:
6
- metadata.gz: d108db6dd4064eced4dfe277238771246120f73874f89ae3800e7bbef91b101d946861cb1793b7a138ce761bf4b26e854ee05b13ca5d39287c46b7c64027436a
7
- data.tar.gz: 2005c56063bdc5a62f3ec3fe53b73d99158b8b124bdbbb45a3d8ff5ab64ab35e2863afdace05d05b5538855fdc80ed4ca138e073b415ac38f7d9dab95ccbc382
6
+ metadata.gz: caeb105aa52968eb387304da206083cf07394d1f378c01a6aabf040e2aa264d0016491e69dba31910fa64982cdc8bf9902b036b63639279422c93ad934a91725
7
+ data.tar.gz: 8af65a286c9207f04770b530865755aeeca35b4162d3db66c987b0e6d5c02438faeeee3251bef91ef5e91e4b75235ec2ae23f805a07bfc64d448e7e5066610d6
data/.codeclimate.yml CHANGED
@@ -1,16 +1,21 @@
1
- engines:
1
+ version: "2"
2
+ plugins:
2
3
  rubocop:
3
4
  enabled: true
4
5
  reek:
5
6
  enabled: true
6
- ratings:
7
- paths:
8
- - lib/**/*
9
- exclude_paths:
10
- - coverage/
11
- - docs/
12
- - features/
13
- - logo/
14
- - pkg/
15
- - spec/
16
- - tmp/
7
+ duplication:
8
+ enabled: true
9
+ config:
10
+ languages:
11
+ ruby:
12
+ mass_threshold: 35
13
+ exclude_patterns:
14
+ - coverage/
15
+ - docs/
16
+ - features/
17
+ - logo/
18
+ - pkg/
19
+ - samples/
20
+ - spec/
21
+ - tmp/
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:
@@ -36,6 +36,15 @@ Layout/MultilineOperationIndentation:
36
36
  Lint/AmbiguousBlockAssociation:
37
37
  Enabled: false
38
38
 
39
+ # Some of our source examples include interpolation explicitely.
40
+ Lint/InterpolationCheck:
41
+ Exclude:
42
+ - 'spec/**/*'
43
+
44
+ # We use :true and :false as AST node types.
45
+ Lint/BooleanSymbol:
46
+ Enabled: false
47
+
39
48
  Lint/HandleExceptions:
40
49
  Exclude:
41
50
  - 'spec/reek/configuration/configuration_file_finder_spec.rb'
@@ -51,9 +60,21 @@ Metrics/ClassLength:
51
60
  - lib/reek/context_builder.rb
52
61
  - lib/reek/cli/options.rb
53
62
 
63
+ Style/SafeNavigation:
64
+ Exclude:
65
+ - lib/reek/ast/node.rb
66
+ - lib/reek/ast/sexp_extensions/module.rb
67
+
54
68
  # FIXME: Lower the method length by fixing the biggest offenders
55
69
  Metrics/MethodLength:
56
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'
57
78
 
58
79
  # Be rather lenient with line length
59
80
  Metrics/LineLength:
@@ -63,6 +84,15 @@ Metrics/LineLength:
63
84
  Metrics/ParameterLists:
64
85
  CountKeywordArgs: false
65
86
 
87
+ Naming/AccessorMethodName:
88
+ Exclude:
89
+ - 'lib/reek/context/visibility_tracker.rb'
90
+
91
+ # EOS is a fine name to use in our specs
92
+ Naming/HeredocDelimiterNaming:
93
+ Exclude:
94
+ - 'spec/**/*'
95
+
66
96
  # FIXME: Update specs to avoid offenses
67
97
  RSpec/AnyInstance:
68
98
  Exclude:
@@ -82,8 +112,8 @@ RSpec/MultipleDescribes:
82
112
  Exclude:
83
113
  - 'spec/reek/ast/sexp_extensions_spec.rb'
84
114
  - 'spec/reek/code_comment_spec.rb'
85
- - 'spec/reek/report/formatter/location_formatter_spec.rb'
86
- - 'spec/reek/report/formatter/progress_formatter_spec.rb'
115
+ - 'spec/reek/report/location_formatter_spec.rb'
116
+ - 'spec/reek/report/progress_formatter_spec.rb'
87
117
 
88
118
  # FIXME: Update specs to avoid offenses
89
119
  RSpec/MultipleExpectations:
@@ -99,7 +129,10 @@ RSpec/MultipleExpectations:
99
129
  # FIXME: Update specs to avoid offenses
100
130
  RSpec/NestedGroups:
101
131
  Exclude:
132
+ - 'spec/reek/report/code_climate/code_climate_fingerprint_spec.rb'
102
133
  - 'spec/reek/cli/application_spec.rb'
134
+ - 'spec/reek/configuration/schema_validator_spec.rb'
135
+ - 'spec/reek/configuration/configuration_file_finder_spec.rb'
103
136
 
104
137
  # rubocop-rspec expects a CodeClimate namespace to go with the code_climate directory.
105
138
  RSpec/FilePath:
@@ -109,10 +142,6 @@ RSpec/FilePath:
109
142
  - 'spec/reek/report/code_climate/code_climate_formatter_spec.rb'
110
143
  - 'spec/reek/report/code_climate/code_climate_report_spec.rb'
111
144
 
112
- Style/AccessorMethodName:
113
- Exclude:
114
- - 'lib/reek/context/visibility_tracker.rb'
115
-
116
145
  # Allow and/or for control flow only
117
146
  Style/AndOr:
118
147
  EnforcedStyle: conditionals
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
@@ -5,26 +5,20 @@ language: ruby
5
5
  bundler_args: --without debugging
6
6
  script: bundle exec rake ci
7
7
  rvm:
8
- - 2.1
9
- - 2.2
10
8
  - 2.3
11
9
  - 2.4
12
- - jruby-9.1.7.0
10
+ - 2.5
11
+ - jruby-9.1.15.0
13
12
  - jruby-head
14
13
  - ruby-head
15
14
  - rubinius-3
16
15
  matrix:
17
16
  allow_failures:
18
- - rvm: jruby-9.1.7.0
17
+ - rvm: jruby-9.1.15.0
19
18
  - rvm: jruby-head
20
19
  - rvm: ruby-head
21
20
  - rvm: rubinius-3
22
21
  fast_finish: true
23
- before_install:
24
- - rvm use @global
25
- - gem uninstall bundler -x
26
- - gem install bundler --version=1.13.7
27
- - bundler --version
28
22
  notifications:
29
23
  email:
30
24
  - timo.roessner@googlemail.com
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,64 @@
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
+
31
+ ## 4.8.2 (2018-06-26)
32
+
33
+ * (mvz) Only report FeatureEnvy for instance methods
34
+ * (mvz) Generate versioned documentation links
35
+
36
+ ## 4.8.1 (2018-04-12)
37
+
38
+ * (mvz) Loosen dependency on rainbow
39
+
40
+ ## 4.8.0 (2018-03-05)
41
+
42
+ * (pocke) Support Ruby 2.5
43
+ * (mvz) Print original exception class in certain error messages
44
+ * (mvz) Only include long exception message in CLI output
45
+ * (chastell) Add official support for Ruby 2.5
46
+ * (mvz) Do not detect ModuleInitialize for nested dynamic classes
47
+
48
+ ## 4.7.3 (2017-11-05)
49
+
50
+ * (mvz) Handle UTF-8 files in all locales
51
+ * (troessner) Handle encoding and other errors when parsing the source
52
+ * (mvz) Report method source line in PrimaDonnaMethod
53
+ * (mvz) Pick up config file in reek matcher
54
+ * (mvz) Let REEK_SRC override set values in rake task
55
+
56
+ ## 4.7.2 (2017-07-24)
57
+
58
+ * (mvz) Also report unused uncommunicative parameter names
59
+ * (mvz) Track visibility correctly when using method definition visibility modifiers
60
+ * (mvz) Handle method comments when using method definition visibility modifiers
61
+
3
62
  ## 4.7.1 (2017-06-12)
4
63
 
5
64
  * (mvz) Improve IrresponsibleModule and fix some bugs along
data/CONTRIBUTING.md CHANGED
@@ -111,7 +111,7 @@ regard than if it were run in a terminal.
111
111
 
112
112
  #### Failing Cucumber Scenarios
113
113
 
114
- If there is a failing scenario and you can not figure out why it is failing,
114
+ If there is a failing scenario and you cannot figure out why it is failing,
115
115
  just run the failing scenario: `bundle exec cucumber
116
116
  features/failing_scenario.feature:line`. By doing so Aruba will leave its set
117
117
  up in the `tmp/aruba` directory. You can then `cd` into this directory and run
data/Gemfile CHANGED
@@ -8,16 +8,16 @@ group :development do
8
8
  gem 'activesupport', '>= 4.2'
9
9
  gem 'aruba', '~> 0.14.0'
10
10
  gem 'ataru', '~> 0.2.0'
11
- gem 'cucumber', '~> 2.0'
12
- gem 'factory_girl', '~> 4.0'
11
+ gem 'cucumber', '~> 3.0'
12
+ gem 'factory_bot', '~> 4.0'
13
13
  gem 'rake', '~> 12.0'
14
14
  gem 'rspec', '~> 3.0'
15
- gem 'simplecov', '~> 0.14.0'
15
+ gem 'simplecov', '~> 0.16.1'
16
16
  gem 'yard', '~> 0.9.5'
17
17
 
18
18
  if RUBY_VERSION >= '2.3'
19
- gem 'rubocop', '~> 0.49.1'
20
- gem 'rubocop-rspec', '~> 1.15.0'
19
+ gem 'rubocop', '~> 0.57.1'
20
+ gem 'rubocop-rspec', '~> 1.20'
21
21
  end
22
22
 
23
23
  platforms :mri do
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  - [Overview](#overview)
8
8
  - [Quickstart](#quickstart)
9
9
  - [Example](#example)
10
- - [Supported rubies](#supported-rubies)
10
+ - [Supported Ruby versions](#supported-ruby-versions)
11
11
  - [Fixing Smell Warnings](#fixing-smell-warnings)
12
12
  - [Sources](#sources)
13
13
  - [Code smells](#code-smells)
@@ -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,25 +89,24 @@ end
84
89
  Reek will report the following code smells in this file:
85
90
 
86
91
  ```
87
- $ reek demo.rb
92
+ $ reek --no-documentation demo.rb
88
93
  Inspecting 1 file(s):
89
94
  S
90
95
 
91
96
  demo.rb -- 2 warnings:
92
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
93
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
97
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
98
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
94
99
  ```
95
100
 
96
- ## Supported rubies
101
+ ## Supported Ruby versions
97
102
 
98
- Reek is officially running on the following MRI rubies:
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
107
+ - 2.5
104
108
 
105
- Other rubies like Rubinius or JRuby are not officially supported but should work as well.
109
+ Other Ruby implementations (like Rubinius or JRuby) are not officially supported but should work as well.
106
110
 
107
111
  ## Fixing Smell Warnings
108
112
 
@@ -253,12 +257,13 @@ For a summary of those CLI options see [Command-Line Options](docs/Command-Line-
253
257
  #### Configuration loading
254
258
 
255
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).
256
261
 
257
- There are three ways of passing Reek a configuration file:
262
+ There are three ways of passing Reek the configuration file:
258
263
 
259
264
  1. Using the CLI `-c` switch (see [_Command-line interface_](#command-line-interface) above)
260
- 2. Having a file ending with `.reek` either in your current working directory or in a parent directory (more on that later)
261
- 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
262
267
 
263
268
  The order in which Reek tries to find such a configuration
264
269
  file is exactly the above: first it checks if we have given
@@ -276,43 +281,46 @@ of how many `*.reek` files you might have on your filesystem.
276
281
 
277
282
  We put a lot of effort into making Reek's configuration as self explanatory as possible so the
278
283
  best way to understand it is by looking at a simple
279
- example (e.g. `config.reek` in your project directory):
284
+ example (e.g. `.reek.yml` in your project directory):
280
285
 
281
286
  ```yaml
282
287
  ---
283
288
 
284
289
  ### Generic smell configuration
285
290
 
286
- # You can disable smells completely
287
- IrresponsibleModule:
288
- enabled: false
289
-
290
- # You can use filters to silence Reek warnings.
291
- # Either because you simply disagree with Reek (we are not the police) or
292
- # because you want to fix this at a later point in time.
293
- NestedIterators:
294
- exclude:
295
- - "MyWorker#self.class_method" # should be refactored
296
- - "AnotherWorker#instance_method" # should be refactored as well
297
-
298
- # A lot of smells allow fine tuning their configuration. You can look up all available options
299
- # in the corresponding smell documentation in /docs. In most cases you probably can just go
300
- # with the defaults as documented in defaults.reek.
301
- DataClump:
302
- max_copies: 3
303
- 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
304
310
 
305
311
  ### Directory specific configuration
306
312
 
307
313
  # You can configure smells on a per-directory base.
308
314
  # E.g. the classic Rails case: controllers smell of NestedIterators (see /docs/Nested-Iterators.md) and
309
315
  # helpers smell of UtilityFunction (see docs/Utility-Function.md)
310
- "web_app/app/controllers":
311
- NestedIterators:
312
- enabled: false
313
- "web_app/app/helpers":
314
- UtilityFunction:
315
- 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
316
324
 
317
325
  ### Excluding directories
318
326
 
@@ -322,6 +330,14 @@ exclude_paths:
322
330
  - lib/rake/legacy_tasks
323
331
  ```
324
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
+
325
341
  If you have a directory directive for which a default directive exists, the more specific
326
342
  one (which is the directory directive) will take precedence.
327
343
 
@@ -329,15 +345,12 @@ This configuration for instance:
329
345
 
330
346
  ```yaml
331
347
  ---
332
- IrresponsibleModule:
333
- enabled: false
334
-
335
- TooManyStatements:
336
- max_statements: 5
337
-
338
- "app/controllers":
348
+ detectors:
349
+ IrresponsibleModule:
350
+ enabled: false
351
+
339
352
  TooManyStatements:
340
- max_statements: 10
353
+ max_statements: 5
341
354
  ```
342
355
 
343
356
  translates to:
@@ -346,16 +359,53 @@ translates to:
346
359
  * TooManyStatements#max_statements is 10 in "app/controllers"
347
360
  * TooManyStatements#max_statements is 5 everywhere else
348
361
 
349
- For more details please check out the [Basic Smell Options](docs/Basic-Smell-Options.md)
350
- which are supported by every smell type. As you can see above, certain smell
351
- 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
352
364
  [Data Clump](docs/Data-Clump.md).
353
365
  All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md)
354
366
  are documented in the corresponding smell type /docs page (if you want to get a quick overview over all possible
355
- 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).
356
368
 
357
369
  Note that you do not need a configuration file at all.
358
- 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).
359
409
 
360
410
  ### Generating a 'todo' list
361
411
 
@@ -403,42 +453,6 @@ reek -c other_configuration.reek --todo lib/
403
453
  `other_configuration.reek` will simply be ignored (as outlined before, Reek
404
454
  is supposed to have one configuration file and one file only).
405
455
 
406
- ### Beware of multiple configuration files
407
-
408
- Reek takes one configuration file and one configuration file only.
409
-
410
- If you have more than one configuration file in the same directory Reek
411
- will not know what configuration file to use. If this happens Reek will
412
- print a warning on STDERR and exit with the failure exit status 1.
413
-
414
- In case you have to have one or more configuration files in the directory (e.g. you're
415
- toying around with different, mutually exclusive settings) you need to tell Reek
416
- explicitly which file to use via `reek -c config.reek`.
417
-
418
- ### Source code comments
419
-
420
- In case you need to suppress a smell warning and you can't or don't want to
421
- use configuration files for whatever reasons you can also use special
422
- source code comments like this:
423
-
424
- ```Ruby
425
- # This method smells of :reek:NestedIterators
426
- def smelly_method foo
427
- foo.each {|bar| bar.each {|baz| baz.qux}}
428
- end
429
- ```
430
-
431
- You can even pass in smell specific configuration settings:
432
-
433
- ```Ruby
434
- # :reek:NestedIterators { max_allowed_nesting: 2 }
435
- def smelly_method foo
436
- foo.each {|bar| bar.each {|baz| baz.qux}}
437
- end
438
- ```
439
-
440
- This is an incredible powerful feature and further explained under [Smell Suppresion](docs/Smell-Suppression.md).
441
-
442
456
  ## Usage
443
457
 
444
458
  Besides the obvious
@@ -528,6 +542,20 @@ If you don't feel like getting your hands dirty with code there are still other
528
542
  * Open up an [issue](https://github.com/troessner/reek/issues) and report bugs
529
543
  * Suggest other improvements like additional smells for instance
530
544
 
545
+ ### Running Code Climate locally
546
+
547
+ If you run into Code Climate issues (e.g., go over code duplication
548
+ threshold) you might want to be able to run Code Climate against
549
+ the Reek codebase locally. To do this, you need to do the following:
550
+
551
+ * [install Docker CE](https://docs.docker.com/engine/installation/)
552
+ * [install Code Climate CLI](https://github.com/codeclimate/codeclimate#installation)
553
+ * `gem install codeclimate`
554
+ * `codeclimate engines:install`
555
+
556
+ Now you can run various Code Climate engines,
557
+ e.g., `codeclimate analyze -e duplication`
558
+
531
559
  ## Output formats
532
560
 
533
561
  Reek supports 5 output formats:
@@ -544,23 +572,24 @@ Making Reek "Rails"-friendly is fairly simple since we support directory specifi
544
572
  Just add this to your configuration file:
545
573
 
546
574
  ```Yaml
547
- "app/controllers":
548
- IrresponsibleModule:
549
- enabled: false
550
- NestedIterators:
551
- max_allowed_nesting: 2
552
- UnusedPrivateMethod:
553
- enabled: false
554
- InstanceVariableAssumption:
555
- enabled: false
556
- "app/helpers":
557
- IrresponsibleModule:
558
- enabled: false
559
- UtilityFunction:
560
- enabled: false
561
- "app/mailers":
562
- InstanceVariableAssumption:
563
- 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
564
593
  ```
565
594
 
566
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.
@@ -573,6 +602,7 @@ Be careful though, Reek does not merge your configuration entries, so if you alr
573
602
  * [TextMate Bundle](https://github.com/peeyush1234/reek.tmbundle)
574
603
  * [Atom plugin](https://atom.io/packages/linter-reek)
575
604
  * [SublimeLinter plugin](https://packagecontrol.io/packages/SublimeLinter-contrib-reek)
605
+ * [VS Code plugin](https://github.com/rubyide/vscode-ruby)
576
606
  * [Emacs plugin](https://github.com/hanmoi-choi/reek-emacs)
577
607
 
578
608
  ### Projects that use or support us
data/Rakefile CHANGED
@@ -3,6 +3,19 @@ require 'rake/clean'
3
3
 
4
4
  Dir['tasks/**/*.rake'].each { |t| load t }
5
5
 
6
- task local_test_run: [:test, :rubocop, 'test:quality']
7
- task ci: [:test, :rubocop, 'test:quality', :ataru]
8
- task default: :local_test_run
6
+ task :ci do
7
+ [
8
+ 'test:spec',
9
+ 'configuration:update_default_configuration',
10
+ 'test:features',
11
+ :rubocop,
12
+ 'test:quality',
13
+ :ataru
14
+ ].each do |name|
15
+ puts "\n=== Running #{name}...\n"
16
+ Rake::Task[name].invoke
17
+ puts "\n=== Running #{name} -> Done\n"
18
+ end
19
+ end
20
+
21
+ task default: :ci