reek 2.0.4 → 3.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 (275) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +13 -0
  3. data/.rubocop.yml +47 -0
  4. data/.travis.yml +31 -0
  5. data/.yardopts +3 -6
  6. data/CHANGELOG +24 -0
  7. data/CONTRIBUTING.md +111 -0
  8. data/Gemfile +16 -0
  9. data/README.md +112 -59
  10. data/bin/reek +2 -2
  11. data/config/cucumber.yml +3 -0
  12. data/config/defaults.reek +0 -1
  13. data/docs/API.md +79 -0
  14. data/docs/Attribute.md +43 -0
  15. data/docs/Basic-Smell-Options.md +44 -0
  16. data/docs/Boolean-Parameter.md +52 -0
  17. data/docs/Class-Variable.md +40 -0
  18. data/docs/Code-Smells.md +34 -0
  19. data/docs/Command-Line-Options.md +84 -0
  20. data/docs/Configuration-Files.md +49 -0
  21. data/docs/Control-Couple.md +22 -0
  22. data/docs/Control-Parameter.md +29 -0
  23. data/docs/Data-Clump.md +44 -0
  24. data/docs/Duplicate-Method-Call.md +49 -0
  25. data/docs/Feature-Envy.md +49 -0
  26. data/docs/How-reek-works-internally.md +114 -0
  27. data/docs/Irresponsible-Module.md +39 -0
  28. data/docs/Large-Class.md +20 -0
  29. data/docs/Long-Parameter-List.md +38 -0
  30. data/docs/Long-Yield-List.md +36 -0
  31. data/docs/Module-Initialize.md +62 -0
  32. data/docs/Nested-Iterators.md +38 -0
  33. data/docs/Nil-Check.md +39 -0
  34. data/docs/Prima-Donna-Method.md +53 -0
  35. data/docs/RSpec-matchers.md +137 -0
  36. data/docs/Rake-Task.md +58 -0
  37. data/docs/Reek-Driven-Development.md +37 -0
  38. data/docs/Repeated-Conditional.md +44 -0
  39. data/docs/Simulated-Polymorphism.md +16 -0
  40. data/docs/Smell-Suppression.md +32 -0
  41. data/docs/Too-Many-Instance-Variables.md +43 -0
  42. data/docs/Too-Many-Methods.md +55 -0
  43. data/docs/Too-Many-Statements.md +50 -0
  44. data/docs/Uncommunicative-Method-Name.md +24 -0
  45. data/docs/Uncommunicative-Module-Name.md +23 -0
  46. data/docs/Uncommunicative-Name.md +16 -0
  47. data/docs/Uncommunicative-Parameter-Name.md +24 -0
  48. data/docs/Uncommunicative-Variable-Name.md +24 -0
  49. data/docs/Unused-Parameters.md +27 -0
  50. data/docs/Utility-Function.md +44 -0
  51. data/docs/Versioning-Policy.md +7 -0
  52. data/docs/YAML-Reports.md +111 -0
  53. data/docs/yard_plugin.rb +14 -0
  54. data/features/{ruby_api/api.feature → command_line_interface/basic_usage.feature} +6 -5
  55. data/features/command_line_interface/options.feature +1 -0
  56. data/features/command_line_interface/smell_selection.feature +4 -8
  57. data/features/command_line_interface/smells_count.feature +25 -32
  58. data/features/command_line_interface/stdin.feature +2 -2
  59. data/features/configuration_files/masking_smells.feature +30 -41
  60. data/features/configuration_files/overrides_defaults.feature +5 -3
  61. data/features/configuration_loading.feature +26 -23
  62. data/features/programmatic_access.feature +43 -0
  63. data/features/rake_task/rake_task.feature +25 -22
  64. data/features/reports/json.feature +24 -26
  65. data/features/reports/reports.feature +77 -103
  66. data/features/reports/yaml.feature +26 -20
  67. data/features/samples.feature +26 -31
  68. data/features/step_definitions/.rubocop.yml +5 -0
  69. data/features/step_definitions/reek_steps.rb +16 -28
  70. data/features/step_definitions/sample_file_steps.rb +158 -0
  71. data/features/support/env.rb +16 -27
  72. data/lib/reek/{source → ast}/ast_node_class_map.rb +11 -12
  73. data/lib/reek/ast/node.rb +132 -0
  74. data/lib/reek/{core → ast}/object_refs.rb +2 -1
  75. data/lib/reek/ast/reference_collector.rb +32 -0
  76. data/lib/reek/{source → ast}/sexp_extensions.rb +43 -7
  77. data/lib/reek/ast/sexp_formatter.rb +31 -0
  78. data/lib/reek/cli/application.rb +5 -4
  79. data/lib/reek/cli/command.rb +2 -1
  80. data/lib/reek/cli/input.rb +6 -5
  81. data/lib/reek/cli/option_interpreter.rb +13 -9
  82. data/lib/reek/cli/options.rb +16 -8
  83. data/lib/reek/cli/reek_command.rb +4 -3
  84. data/lib/reek/cli/silencer.rb +14 -0
  85. data/lib/reek/{core → cli}/warning_collector.rb +2 -1
  86. data/lib/reek/code_comment.rb +36 -0
  87. data/lib/reek/configuration/app_configuration.rb +18 -3
  88. data/lib/reek/configuration/configuration_file_finder.rb +18 -32
  89. data/lib/reek/{core → context}/code_context.rb +8 -6
  90. data/lib/reek/{core → context}/method_context.rb +11 -5
  91. data/lib/reek/{core → context}/module_context.rb +9 -4
  92. data/lib/reek/{core/stop_context.rb → context/root_context.rb} +4 -2
  93. data/lib/reek/{core → context}/singleton_method_context.rb +3 -6
  94. data/lib/reek/examiner.rb +32 -29
  95. data/lib/reek/report/formatter.rb +70 -0
  96. data/lib/reek/report/heading_formatter.rb +45 -0
  97. data/lib/reek/report/location_formatter.rb +35 -0
  98. data/lib/reek/report/report.rb +198 -0
  99. data/lib/reek/smells/attribute.rb +41 -11
  100. data/lib/reek/smells/boolean_parameter.rb +4 -2
  101. data/lib/reek/smells/class_variable.rb +4 -2
  102. data/lib/reek/smells/control_parameter.rb +4 -2
  103. data/lib/reek/smells/data_clump.rb +4 -3
  104. data/lib/reek/smells/duplicate_method_call.rb +15 -5
  105. data/lib/reek/smells/feature_envy.rb +8 -2
  106. data/lib/reek/smells/irresponsible_module.rb +13 -8
  107. data/lib/reek/smells/long_parameter_list.rb +6 -4
  108. data/lib/reek/smells/long_yield_list.rb +4 -2
  109. data/lib/reek/smells/module_initialize.rb +4 -2
  110. data/lib/reek/smells/nested_iterators.rb +4 -2
  111. data/lib/reek/smells/nil_check.rb +6 -3
  112. data/lib/reek/smells/prima_donna_method.rb +21 -12
  113. data/lib/reek/smells/repeated_conditional.rb +7 -4
  114. data/lib/reek/{core → smells}/smell_configuration.rb +3 -1
  115. data/lib/reek/smells/smell_detector.rb +11 -5
  116. data/lib/reek/{core → smells}/smell_repository.rb +9 -5
  117. data/lib/reek/smells/smell_warning.rb +101 -0
  118. data/lib/reek/smells/too_many_instance_variables.rb +4 -2
  119. data/lib/reek/smells/too_many_methods.rb +4 -2
  120. data/lib/reek/smells/too_many_statements.rb +4 -2
  121. data/lib/reek/smells/uncommunicative_method_name.rb +4 -2
  122. data/lib/reek/smells/uncommunicative_module_name.rb +4 -2
  123. data/lib/reek/smells/uncommunicative_parameter_name.rb +4 -2
  124. data/lib/reek/smells/uncommunicative_variable_name.rb +4 -2
  125. data/lib/reek/smells/unused_parameters.rb +4 -2
  126. data/lib/reek/smells/utility_function.rb +11 -22
  127. data/lib/reek/smells.rb +24 -11
  128. data/lib/reek/source/source_code.rb +69 -12
  129. data/lib/reek/source/source_locator.rb +34 -19
  130. data/lib/reek/spec/should_reek.rb +4 -3
  131. data/lib/reek/spec/should_reek_of.rb +2 -1
  132. data/lib/reek/spec/should_reek_only_of.rb +4 -3
  133. data/lib/reek/spec.rb +3 -3
  134. data/lib/reek/tree_dresser.rb +32 -0
  135. data/lib/reek/tree_walker.rb +182 -0
  136. data/lib/reek/version.rb +1 -1
  137. data/lib/reek.rb +3 -3
  138. data/reek.gemspec +18 -25
  139. data/spec/factories/factories.rb +4 -2
  140. data/spec/gem/updates_spec.rb +1 -1
  141. data/spec/gem/yard_spec.rb +2 -2
  142. data/spec/quality/reek_source_spec.rb +3 -3
  143. data/spec/reek/{source/sexp_node_spec.rb → ast/node_spec.rb} +4 -6
  144. data/spec/reek/{core → ast}/object_refs_spec.rb +4 -6
  145. data/spec/reek/{source → ast}/reference_collector_spec.rb +27 -19
  146. data/spec/reek/{source → ast}/sexp_extensions_spec.rb +7 -19
  147. data/spec/reek/{source → ast}/sexp_formatter_spec.rb +13 -8
  148. data/spec/reek/cli/option_interpreter_spec.rb +15 -0
  149. data/spec/reek/cli/options_spec.rb +19 -0
  150. data/spec/reek/cli/warning_collector_spec.rb +28 -0
  151. data/spec/reek/{source/code_comment_spec.rb → code_comment_spec.rb} +19 -17
  152. data/spec/reek/configuration/app_configuration_spec.rb +37 -26
  153. data/spec/reek/configuration/configuration_file_finder_spec.rb +67 -21
  154. data/spec/reek/{core → context}/code_context_spec.rb +18 -21
  155. data/spec/reek/{core → context}/method_context_spec.rb +33 -27
  156. data/spec/reek/{core → context}/module_context_spec.rb +5 -7
  157. data/spec/reek/context/root_context_spec.rb +14 -0
  158. data/spec/reek/context/singleton_method_context_spec.rb +17 -0
  159. data/spec/reek/examiner_spec.rb +9 -50
  160. data/spec/reek/{cli → report}/html_report_spec.rb +6 -9
  161. data/spec/reek/report/json_report_spec.rb +20 -0
  162. data/spec/reek/{cli → report}/text_report_spec.rb +16 -19
  163. data/spec/reek/report/xml_report_spec.rb +34 -0
  164. data/spec/reek/report/yaml_report_spec.rb +20 -0
  165. data/spec/reek/smells/attribute_spec.rb +93 -88
  166. data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
  167. data/spec/reek/smells/boolean_parameter_spec.rb +31 -5
  168. data/spec/reek/smells/class_variable_spec.rb +10 -10
  169. data/spec/reek/smells/control_parameter_spec.rb +5 -5
  170. data/spec/reek/smells/data_clump_spec.rb +6 -6
  171. data/spec/reek/smells/duplicate_method_call_spec.rb +7 -7
  172. data/spec/reek/smells/feature_envy_spec.rb +12 -13
  173. data/spec/reek/smells/irresponsible_module_spec.rb +28 -32
  174. data/spec/reek/smells/long_parameter_list_spec.rb +7 -7
  175. data/spec/reek/smells/long_yield_list_spec.rb +6 -6
  176. data/spec/reek/smells/module_initialize_spec.rb +4 -4
  177. data/spec/reek/smells/nested_iterators_spec.rb +6 -6
  178. data/spec/reek/smells/nil_check_spec.rb +6 -6
  179. data/spec/reek/smells/prima_donna_method_spec.rb +8 -5
  180. data/spec/reek/smells/repeated_conditional_spec.rb +18 -17
  181. data/spec/reek/{core → smells}/smell_configuration_spec.rb +5 -7
  182. data/spec/reek/smells/smell_detector_shared.rb +6 -7
  183. data/spec/reek/smells/smell_repository_spec.rb +29 -0
  184. data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -9
  185. data/spec/reek/smells/too_many_instance_variables_spec.rb +5 -5
  186. data/spec/reek/smells/too_many_methods_spec.rb +12 -8
  187. data/spec/reek/smells/too_many_statements_spec.rb +10 -9
  188. data/spec/reek/smells/uncommunicative_method_name_spec.rb +5 -5
  189. data/spec/reek/smells/uncommunicative_module_name_spec.rb +8 -8
  190. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +18 -6
  191. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +10 -7
  192. data/spec/reek/smells/unused_parameters_spec.rb +4 -4
  193. data/spec/reek/smells/utility_function_spec.rb +65 -39
  194. data/spec/reek/source/source_code_spec.rb +10 -10
  195. data/spec/reek/source/source_locator_spec.rb +30 -0
  196. data/spec/reek/spec/should_reek_of_spec.rb +9 -25
  197. data/spec/reek/spec/should_reek_only_of_spec.rb +4 -7
  198. data/spec/reek/spec/should_reek_spec.rb +4 -32
  199. data/spec/reek/tree_dresser_spec.rb +16 -0
  200. data/spec/reek/{core/tree_walker_spec.rb → tree_walker_spec.rb} +5 -7
  201. data/spec/samples/checkstyle.xml +2 -0
  202. data/spec/samples/configuration/with_excluded_paths.reek +4 -0
  203. data/spec/samples/{overrides/masked/lower.reek → masked_by_dotfile/.reek} +3 -1
  204. data/spec/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +5 -0
  205. data/spec/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +2 -0
  206. data/spec/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +6 -0
  207. data/spec/samples/{ruby20_syntax.rb → unusual_syntax.rb} +8 -0
  208. data/spec/spec_helper.rb +21 -10
  209. data/tasks/develop.rake +2 -2
  210. data/tasks/reek.rake +1 -1
  211. metadata +158 -141
  212. data/features/support/hooks.rb +0 -15
  213. data/lib/reek/cli/report/formatter.rb +0 -69
  214. data/lib/reek/cli/report/heading_formatter.rb +0 -45
  215. data/lib/reek/cli/report/location_formatter.rb +0 -34
  216. data/lib/reek/cli/report/report.rb +0 -131
  217. data/lib/reek/core/tree_walker.rb +0 -180
  218. data/lib/reek/smell_warning.rb +0 -87
  219. data/lib/reek/source/ast_node.rb +0 -38
  220. data/lib/reek/source/code_comment.rb +0 -37
  221. data/lib/reek/source/core_extras.rb +0 -46
  222. data/lib/reek/source/reference_collector.rb +0 -27
  223. data/lib/reek/source/sexp_formatter.rb +0 -22
  224. data/lib/reek/source/sexp_node.rb +0 -79
  225. data/lib/reek/source/source_file.rb +0 -16
  226. data/lib/reek/source/source_repository.rb +0 -45
  227. data/lib/reek/source/tree_dresser.rb +0 -24
  228. data/lib/reek/source.rb +0 -16
  229. data/spec/reek/cli/json_report_spec.rb +0 -20
  230. data/spec/reek/cli/option_interperter_spec.rb +0 -14
  231. data/spec/reek/cli/yaml_report_spec.rb +0 -23
  232. data/spec/reek/core/singleton_method_context_spec.rb +0 -9
  233. data/spec/reek/core/smell_repository_spec.rb +0 -17
  234. data/spec/reek/core/stop_context_spec.rb +0 -17
  235. data/spec/reek/core/warning_collector_spec.rb +0 -30
  236. data/spec/reek/source/object_source_spec.rb +0 -20
  237. data/spec/reek/source/tree_dresser_spec.rb +0 -18
  238. data/spec/samples/config/allow_duplication.reek +0 -3
  239. data/spec/samples/config/deeper_nested_iterators.reek +0 -3
  240. data/spec/samples/configuration_loading/minimal_dirty.rb +0 -4
  241. data/spec/samples/configuration_loading/reek-test-run-disable_smells.reek +0 -7
  242. data/spec/samples/configuration_loading/reek-test-run-enable_smells.reek +0 -7
  243. data/spec/samples/corrupt_config_file/corrupt.reek +0 -1
  244. data/spec/samples/corrupt_config_file/dirty.rb +0 -8
  245. data/spec/samples/demo/demo.rb +0 -8
  246. data/spec/samples/empty_config_file/dirty.rb +0 -8
  247. data/spec/samples/empty_config_file/empty.reek +0 -0
  248. data/spec/samples/inline_config/dirty.rb +0 -16
  249. data/spec/samples/inline_config/masked.reek +0 -7
  250. data/spec/samples/mask_some/dirty.rb +0 -8
  251. data/spec/samples/mask_some/some.reek +0 -8
  252. data/spec/samples/masked/dirty.rb +0 -8
  253. data/spec/samples/masked/masked.reek +0 -5
  254. data/spec/samples/minimal_smelly_and_masked/config.reek +0 -7
  255. data/spec/samples/minimal_smelly_and_masked/minimal_dirty.rb +0 -4
  256. data/spec/samples/mixed_results/clean_one.rb +0 -7
  257. data/spec/samples/mixed_results/clean_three.rb +0 -7
  258. data/spec/samples/mixed_results/clean_two.rb +0 -7
  259. data/spec/samples/mixed_results/dirty_one.rb +0 -8
  260. data/spec/samples/mixed_results/dirty_two.rb +0 -8
  261. data/spec/samples/not_quite_masked/dirty.rb +0 -8
  262. data/spec/samples/not_quite_masked/masked.reek +0 -5
  263. data/spec/samples/not_quite_masked/smelly.rb +0 -3
  264. data/spec/samples/one_smelly_file/dirty.rb +0 -3
  265. data/spec/samples/overrides/masked/dirty.rb +0 -8
  266. data/spec/samples/overrides/upper.reek +0 -5
  267. data/spec/samples/overrides_defaults/camel_case.rb +0 -14
  268. data/spec/samples/overrides_defaults/config.reek +0 -6
  269. data/spec/samples/ruby21_syntax.rb +0 -5
  270. data/spec/samples/standard_smelly/dirty.rb +0 -8
  271. data/spec/samples/standard_smelly/minimal_dirty.rb +0 -4
  272. data/spec/samples/three_smelly_files/dirty_one.rb +0 -3
  273. data/spec/samples/three_smelly_files/dirty_three.rb +0 -5
  274. data/spec/samples/three_smelly_files/dirty_two.rb +0 -4
  275. /data/spec/samples/{simple_configuration.reek → configuration/simple_configuration.reek} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8af5e0348f9f24426352d7790b0c3b4574b7128b
4
- data.tar.gz: 42b3c7339cae9caebbcab1ab5a6386b21165ae6a
3
+ metadata.gz: da371c20978d5a436025bc2ecddc2df4582a9c7e
4
+ data.tar.gz: 8aa3729d6814cba34e69ff9e1696ce93450221c6
5
5
  SHA512:
6
- metadata.gz: c33ef48a39ed8a20ba2a5e4b1973851004f668d4b1878805ce0a245743cd5bbba0c64c4a96747200762b273eae7762433c0509376552620ebd490fa0c2203f9f
7
- data.tar.gz: f682a7ae37aa0787e5dd6215e03ee5340b121e0bc7532f8c0275b6c8274ffccd6345a3a61d7b51e3beb80baa53bb47fdfceaac6422802057741de0d45e7d1d36
6
+ metadata.gz: d15340c5aa637820c280d28008579ecc97f9de7a56bf74e47f6f217a9f593d3a1416dfa6757b4beb3900032c505eed91aa8fa21de94374ac1e2d1537706cbabb
7
+ data.tar.gz: c49a1ae86f1265e493f6e5eff700e2d02c2849358a49db20d87d9c52498138da0ca38fd7bd83cb90d0c16cb7b19789aa43422b052910b145ac611d9421bc6bf8
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ pkg
2
+ spec/output
3
+ tmp
4
+ doc
5
+ .yardoc
6
+ .bundle
7
+ .rspec
8
+ .rbx
9
+ Gemfile.lock
10
+ *.swp
11
+ tags
12
+ .pryrc
13
+ .tags*
data/.rubocop.yml ADDED
@@ -0,0 +1,47 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'spec/samples/**/*'
4
+ - 'tmp/**/*'
5
+ - 'vendor/**/*'
6
+
7
+ # FIXME: Make the class shorter
8
+ Metrics/ClassLength:
9
+ Exclude:
10
+ - lib/reek/tree_walker.rb
11
+ - lib/reek/cli/options.rb
12
+
13
+ # FIXME: Lower the method length by fixing the biggest offenders
14
+ Metrics/MethodLength:
15
+ Max: 15
16
+
17
+ # Be a little more lenient with line length
18
+ Metrics/LineLength:
19
+ Max: 100
20
+
21
+ # Allow small arrays of words with quotes
22
+ Style/WordArray:
23
+ MinSize: 3
24
+
25
+ # Allow single-line method definitions
26
+ Style/SingleLineMethods:
27
+ Enabled: false
28
+
29
+ # Always use raise to signal exceptions
30
+ Style/SignalException:
31
+ EnforcedStyle: only_raise
32
+
33
+ # Place . on the previous line
34
+ Style/DotPosition:
35
+ EnforcedStyle: trailing
36
+
37
+ # Require empty lines between defs, except for one-line defs
38
+ Style/EmptyLineBetweenDefs:
39
+ AllowAdjacentOneLineDefs: true
40
+
41
+ # Allow multiline block chains
42
+ Style/MultilineBlockChain:
43
+ Enabled: false
44
+
45
+ # Allow Perl-style references to regex matches
46
+ Style/PerlBackrefs:
47
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,31 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ bundler_args: --without local_development
5
+ script:
6
+ - bundle exec rake
7
+ - bundle exec ataru check
8
+ rvm:
9
+ - 2.0.0
10
+ - 2.1
11
+ - 2.2
12
+ - rbx-2
13
+ - ruby-head
14
+ matrix:
15
+ include:
16
+ - rvm: jruby-19mode
17
+ env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
18
+ - rvm: jruby-head
19
+ env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
20
+ allow_failures:
21
+ - rvm: jruby-head
22
+ env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
23
+ - rvm: ruby-head
24
+ fast_finish: true
25
+ notifications:
26
+ recipients:
27
+ - timo.roessner@googlemail.com
28
+ - matijs@matijs.net
29
+ - emil.rehnberg@gmail.com
30
+ - chastell@chastell.net
31
+ irc: "irc.freenode.org#reek"
data/.yardopts CHANGED
@@ -1,10 +1,7 @@
1
1
  --no-private
2
2
  --readme README.md
3
- lib/reek.rb
4
- lib/reek/*.rb
5
- lib/reek/smells/*.rb
6
- lib/reek/source/*.rb
7
- lib/reek/spec/*.rb
8
- lib/reek/rake/*.rb
3
+ --load ./docs/yard_plugin.rb
9
4
  -
10
5
  *.txt
6
+ *.md
7
+ docs/*.md
data/CHANGELOG CHANGED
@@ -1,3 +1,27 @@
1
+ == 3.0.0
2
+
3
+ * (troessner) Make directories excludable via configuration.
4
+ * (mvz) Define and document public API
5
+ * (troessner) Recognize methods defined with class << self syntax as singleton methods.
6
+ * (troessner) Use ruby22 instead of ruby21 for parsing.
7
+ * (nTraum) Drop support for Ruby 1.9
8
+
9
+ == 2.2.1
10
+
11
+ * (mvz) Support methods using array decomposition arguments
12
+
13
+ == 2.2.0
14
+
15
+ * (sauliusgrigaitis) Add support for XML reports
16
+ * (beanieboi) Don’t track private methods in the Attributes smell
17
+ * (Sebastian Boehm) Do not enable colorization if stdout is not a TTY
18
+
19
+ == 2.1.0
20
+
21
+ * (mvz) Ensure require 'reek' is enough to use reek's classes
22
+ * (mvz) Pick config file that comes first alphabetically
23
+ * (mvz) Separate FeatureEnvy and UtilityFunction
24
+
1
25
  == 2.0.4
2
26
 
3
27
  * (chastell) Recognise .reek as a valid configuration file
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,111 @@
1
+ # Contributing to reek
2
+
3
+ We welcome any and all contributions to reek!
4
+
5
+ If what you’re proposing requires significant work discuss it beforehand
6
+ as an issue – it’s much easier for us to guide you towards a good
7
+ solution and less frustrating for you than doing a lot of work
8
+ only to find us suggesting large parts should be rewritten.
9
+
10
+ Don’t hesitate to offer trivial fixes (spelling, better naming
11
+ ideas, etc.) – we’ll let you know if you’re overdoing it. :)
12
+
13
+
14
+
15
+ ## Reporting Issues
16
+
17
+ Search [all existing (open _and_ closed)
18
+ issues](https://github.com/troessner/reek/issues?q=is%3Aissue)
19
+ for a possible previous report; comment there if the issue is not
20
+ actually resolved properly or you have any additional information.
21
+
22
+ Include the steps to reproduce the issue,
23
+ the expected outcome and the actual outcome.
24
+
25
+ Include as much information as possible: the exact reek
26
+ invocation that you use, reek’s config and version, Ruby
27
+ version, Ruby platform (MRI, JRuby, etc.), operating system.
28
+
29
+ Try to provide a minimal example that reproduces the issue.
30
+ Extra kudos if you can write it as a failing test. :)
31
+
32
+
33
+
34
+ ## Setup and Pull Request Basics
35
+
36
+ Fork reek, then clone it, make sure you have
37
+ [Bundler](http://bundler.io) installed, install dependencies
38
+ and make sure all of the existing tests pass:
39
+
40
+ ```
41
+ git clone git@github.com:…username…/reek.git
42
+ cd reek
43
+ gem install bundler
44
+ bundle
45
+ bundle exec rake
46
+ ```
47
+
48
+ Once you’re sure your copy of reek works (and that there are no
49
+ failing tests on the "develop" branch) create your own branch from our "develop" branch.
50
+
51
+ We are using the popular [gitflow branch model](http://nvie.com/posts/a-successful-git-branching-model/) and
52
+ require contributions to follow to this model as well.
53
+ This probably sounds more complicated than it is, for you this just means that you should branch off
54
+ of our "develop" branch for your pull request, not master (which is the default already):
55
+
56
+ ```
57
+ git checkout -b your_feature_or_fix_name
58
+ ```
59
+
60
+ Then start hacking and add new tests which make sure that your new feature works or
61
+ demonstrate that your fix was needed; please also [write good commit
62
+ messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
63
+
64
+ Once you’re happy with your feature / fix – or want to
65
+ share it as a work-in-progress and request comments – once
66
+ again make sure all of the tests pass. This will also run
67
+ [RuboCop](https://github.com/bbatsov/rubocop) – fix any
68
+ offences RuboCop finds (or discuss them in the pull request):
69
+
70
+ ```
71
+ bundle exec rake
72
+ ```
73
+
74
+ Once your code is ready for review push it to your repository:
75
+
76
+ ```
77
+ git push -u origin
78
+ ```
79
+
80
+ Then go to your GitHub fork and [make a pull
81
+ request](https://help.github.com/articles/creating-a-pull-request/)
82
+ to the original repository.
83
+
84
+
85
+
86
+ ## Review and Fixes
87
+
88
+ Try to gauge and let us know in the pull request whether what
89
+ you propose is a backward-compatible bugfix and should go into the
90
+ next patch release, is a backward-compatible feature and should go
91
+ into the next minor release, or has to break backward-compatibility
92
+ and so needs to wait for the next major release of reek.
93
+
94
+ Once your PR is open someone will review it, discuss the details (if
95
+ needed) and either merge right away or ask for some further fixes.
96
+
97
+ GitHub doesn’t have a good way to amend pull requests from external
98
+ repositories. In cases where it’s easier to make a direct fix
99
+ to your pull request (rather than describing it in the comments)
100
+ we’ll either open a separate pull request to the branch in your
101
+ repository or ask you to give us commit access to your repository.
102
+
103
+ If there were any fixes to your pull request we’ll ask you to
104
+ [squash](http://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Squashing-Commits)
105
+ all of the commits into one:
106
+
107
+ ```
108
+ git rebase -i develop
109
+ # squash squash squash
110
+ git push -f origin
111
+ ```
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # The gem's dependencies are specified in the gemspec
4
+ gemspec
5
+
6
+ group :local_development do
7
+ gem 'pry'
8
+ gem 'yard', '~> 0.8.7'
9
+
10
+ platforms :mri do
11
+ gem 'pry-byebug'
12
+ gem 'pry-stack_explorer'
13
+
14
+ gem 'redcarpet', '~> 3.3.1'
15
+ end
16
+ end
data/README.md CHANGED
@@ -1,16 +1,18 @@
1
- # Reek -- code smell detection for Ruby
1
+ # `reek`: code smell detection for Ruby
2
2
 
3
3
  ## Overview
4
4
 
5
5
 
6
6
  [![Build Status](https://secure.travis-ci.org/troessner/reek.png?branch=master)](https://travis-ci.org/troessner/reek?branch=master)
7
- [![Gem Version](https://badge.fury.io/rb/reek.png)](https://badge.fury.io/rb/reek)
7
+ [![Gem Version](https://badge.fury.io/rb/reek.svg)](https://badge.fury.io/rb/reek)
8
8
  [![Dependency Status](https://gemnasium.com/troessner/reek.png)](https://gemnasium.com/troessner/reek)
9
9
  [![Inline docs](https://inch-ci.org/github/troessner/reek.png)](https://inch-ci.org/github/troessner/reek)
10
10
 
11
11
  ## Quickstart
12
12
 
13
- `reek` is a tool that examines Ruby classes, modules and methods and reports any [Code Smells](https://github.com/troessner/reek/wiki/Code-Smells) it finds. Install it like this:
13
+ `reek` is a tool that examines Ruby classes, modules and methods and reports any
14
+ [Code Smells](docs/Code-Smells.md) it finds.
15
+ Install it like this:
14
16
 
15
17
  ```Bash
16
18
  gem install reek
@@ -24,34 +26,32 @@ reek [options] [dir_or_source_file]*
24
26
 
25
27
  ## Example
26
28
 
27
- Imagine a source file <tt>demo.rb</tt> containing:
29
+ Imagine a source file `demo.rb` containing:
28
30
 
29
31
  ```Ruby
30
32
  class Dirty
31
33
  # This method smells of :reek:NestedIterators but ignores them
32
34
  def awful(x, y, offset = 0, log = false)
33
35
  puts @screen.title
34
- @screen = widgets.map {|w| w.each {|key| key += 3}}
36
+ @screen = widgets.map { |w| w.each { |key| key += 3 * x } }
35
37
  puts @screen.contents
36
38
  end
37
39
  end
38
40
  ```
39
41
 
40
- Reek will report the following code smells in this file:
42
+ `reek` will report the following code smells in this file:
41
43
 
42
44
  ```
43
45
  $ reek demo.rb
44
- spec/samples/demo/demo.rb -- 6 warnings:
45
- Dirty has no descriptive comment (IrresponsibleModule)
46
- Dirty#awful has 4 parameters (LongParameterList)
47
- Dirty#awful has boolean parameter 'log' (ControlCouple)
48
- Dirty#awful has the parameter name 'x' (UncommunicativeName)
49
- Dirty#awful has the parameter name 'y' (UncommunicativeName)
50
- Dirty#awful has the variable name 'w' (UncommunicativeName)
51
- Dirty#awful has unused parameter 'log' (UnusedParameters)
52
- Dirty#awful has unused parameter 'offset' (UnusedParameters)
53
- Dirty#awful has unused parameter 'x' (UnusedParameters)
54
- Dirty#awful has unused parameter 'y' (UnusedParameters)
46
+ demo.rb -- 8 warnings:
47
+ [1]:Dirty has no descriptive comment (IrresponsibleModule)
48
+ [3]:Dirty#awful has 4 parameters (LongParameterList)
49
+ [3]:Dirty#awful has boolean parameter 'log' (BooleanParameter)
50
+ [3]:Dirty#awful has the parameter name 'x' (UncommunicativeParameterName)
51
+ [5]:Dirty#awful has the variable name 'w' (UncommunicativeVariableName)
52
+ [3]:Dirty#awful has unused parameter 'log' (UnusedParameters)
53
+ [3]:Dirty#awful has unused parameter 'offset' (UnusedParameters)
54
+ [3]:Dirty#awful has unused parameter 'y' (UnusedParameters)
55
55
  ```
56
56
 
57
57
  ## Sources
@@ -70,13 +70,13 @@ So
70
70
  reek
71
71
  ```
72
72
 
73
- is the exact same thing like being explicit:
73
+ is the exact same thing as being explicit:
74
74
 
75
75
  ```Bash
76
76
  reek .
77
77
  ```
78
78
 
79
- Additionally can you pipe code to reek like this:
79
+ Additionally you can pipe code to `reek` like this:
80
80
 
81
81
  ```Bash
82
82
  echo "class C; def m; end; end" | reek
@@ -93,11 +93,22 @@ $stdin -- 3 warnings:
93
93
 
94
94
  ## Code smells
95
95
 
96
- `reek` currently includes checks for some aspects of [Control Couple](https://github.com/troessner/reek/wiki/Control-Couple), [Data Clump](https://github.com/troessner/reek/wiki/Data-Clump), [Feature Envy](https://github.com/troessner/reek/wiki/Feature-Envy), [Large Class](https://github.com/troessner/reek/wiki/Large-Class), [Long Parameter List](https://github.com/troessner/reek/wiki/Long-Parameter-List), [Simulated Polymorphism](https://github.com/troessner/reek/wiki/Simulated-Polymorphism), [Too Many Statements](https://github.com/troessner/reek/wiki/Too-Many-Statements), [Uncommunicative Name](https://github.com/troessner/reek/wiki/Uncommunicative-Name), [Unused Parameters](https://github.com/troessner/reek/wiki/Unused-Parameters) and more. See the [Code Smells](https://github.com/troessner/reek/wiki/Code-Smells) for up to date details of exactly what `reek` will check in your code.
96
+ `reek` currently includes checks for some aspects of
97
+ [Control Couple](docs/Control-Couple.md),
98
+ [Data Clump](docs/Data-Clump.md),
99
+ [Feature Envy](docs/Feature-Envy.md),
100
+ [Large Class](docs/Large-Class.md),
101
+ [Long Parameter List](docs/Long-Parameter-List.md),
102
+ [Simulated Polymorphism](docs/Simulated-Polymorphism.md),
103
+ [Too Many Statements](docs/Too-Many-Statements.md),
104
+ [Uncommunicative Name](docs/Uncommunicative-Name.md),
105
+ [Unused Parameters](docs/Unused-Parameters.md)
106
+ and more. See the [Code Smells](docs/Code-Smells.md)
107
+ for up to date details of exactly what `reek` will check in your code.
97
108
 
98
109
  ## Configuration
99
110
 
100
- ### Command line interface
111
+ ### Command-line interface
101
112
 
102
113
  For a basic overview, run
103
114
 
@@ -105,29 +116,45 @@ For a basic overview, run
105
116
  reek --help
106
117
  ```
107
118
 
108
- For a summary of those CLI options see [Command-Line Options](https://github.com/troessner/reek/wiki/Command-Line-Options).
119
+ For a summary of those CLI options see [Command-Line Options](docs/Command-Line-Options.md).
109
120
 
110
- ### Configuration files
121
+ ### Configuration file
111
122
 
112
123
  #### Configuration loading
113
124
 
114
- Configuring `reek` via configuration file is by far the most powerful way.
125
+ Configuring `reek` via a configuration file is by far the most powerful way.
115
126
 
116
- There are 3 ways of passing `reek` a configuration file:
127
+ There are three ways of passing `reek` a configuration file:
117
128
 
118
- 1. Using the cli "-c" switch (see "Command line interface" above)
119
- 2. Having a file ending with .reek either in your current working directory or in a parent directory (more on that later)
120
- 3. Having a file ending with .reek in your HOME directory
129
+ 1. Using the CLI `-c` switch (see [_Command-line interface_](#command-line-interface) above)
130
+ 2. Having a file ending with `.reek` either in your current working directory or in a parent directory (more on that later)
131
+ 3. Having a file ending with `.reek` in your home directory
121
132
 
122
- The order in which `reek` tries to find such a configuration file is exactly like above: First `reek` checks if we have given it a configuration file explicitly via CLI. Then it checks the current working directory for a file and if it can't find one, it traverses up the directories until it hits the root directory. And lastly, it checks your HOME directory.
133
+ The order in which `reek` tries to find such a configuration
134
+ file is exactly the above: first it checks if we have given
135
+ it a configuration file explicitly via CLI; then it checks
136
+ the current working directory for a file and if it can't
137
+ find one, it traverses up the directories until it hits the
138
+ root directory; lastly, it checks your home directory.
123
139
 
124
- As soon as `reek` detects a configuration file it stops searching immediately, meaning that from `reek`'s point of view there exists one configuration file and one configuration only regardless of how many ".reek" files you might have on your filesystem.
140
+ As soon as `reek` detects a configuration file it stops searching
141
+ immediately, meaning that from `reek`'s point of view there exists
142
+ exactly one configuration file and one configuration, regardless
143
+ of how many `*.reek` files you might have on your filesystem.
125
144
 
126
145
  #### Configuration options
127
146
 
128
- The first thing you probably want to check out are the [Basic Smell Options](https://github.com/troessner/reek/wiki/Basic-Smell-Options) which are supported by every smell type.
129
- Certain smell types offer a configuration that goes beyond that of the basic smell options - for instance [Data Clump](https://github.com/troessner/reek/wiki/Data-Clump).
130
- All options that go beyond the [Basic Smell Options](https://github.com/troessner/reek/wiki/Basic-Smell-Options) should be documented in the corresponding smell type wiki page but if you want to get a quick and full overview over all possible configurations you can always check out [the default.reek file in this repository](https://github.com/troessner/reek/blob/master/config/defaults.reek).
147
+ The first thing you probably want to check out are the
148
+ [Basic Smell Options](docs/Basic-Smell-Options.md)
149
+ which are supported by every smell type. Certain smell
150
+ types offer a configuration that goes beyond that
151
+ of the basic smell options, for instance
152
+ [Data Clump](docs/Data-Clump.md).
153
+ All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md)
154
+ should be documented in the corresponding smell type wiki page,
155
+ but if you want to get a quick and full overview over all possible
156
+ configurations you can always check out [the `config/default.reek`
157
+ file in this repository](config/defaults.reek).
131
158
 
132
159
  Here's an excerpt of a `reek` configuration file from a commercial project:
133
160
 
@@ -135,20 +162,30 @@ Here's an excerpt of a `reek` configuration file from a commercial project:
135
162
  ---
136
163
  IrresponsibleModule:
137
164
  enabled: false
165
+
138
166
  NestedIterators:
139
167
  exclude:
140
168
  - "ActiveModelErrorAdder#self.run" # should be refactored
141
169
  - "BookingRequests::Transfer#remote_validation"
142
170
  - "BookingRequestsController#vehicle_options" # respond_to block
143
171
  - "Content::Base#self.expose_fields" # unavoidable due to metaprogramming
172
+
144
173
  DataClump:
145
174
  max_copies: 3
146
175
  min_clump_size: 3
176
+
177
+ exclude_paths:
178
+ - app/views
179
+ - app/controllers
147
180
  ```
148
181
 
182
+ Additionally to the smell configuration you can exclude whole directories from scans using `exclude_paths` as you can see at the end of the configuration above.
183
+
149
184
  ### Source code comments
150
185
 
151
- `reek` is not the police. In case you need to suppress a smell warning and you can't or don't want to use configuration files for whatever reasons you can also use source code comments like this:
186
+ `reek` is not the police. In case you need to suppress a smell
187
+ warning and you can't or don't want to use configuration files for
188
+ whatever reasons you can also use source code comments like this:
152
189
 
153
190
  ```Ruby
154
191
  # This method smells of :reek:NestedIterators
@@ -157,7 +194,7 @@ def smelly_method foo
157
194
  end
158
195
  ```
159
196
 
160
- This is further explained [here](https://github.com/troessner/reek/wiki/Smell-Suppression)
197
+ This is further explained under [Smell Suppresion](docs/Smell-Suppression.md).
161
198
 
162
199
 
163
200
  ## Integration
@@ -168,21 +205,21 @@ Besides the obvious
168
205
  reek [options] [dir_or_source_file]*
169
206
  ```
170
207
 
171
- there are quite a few other ways how to use reek in your projects:
208
+ there are quite a few other ways how to use `reek` in your projects:
172
209
 
173
- * Use `reek`'s [Rake Task](https://github.com/troessner/reek/wiki/Rake-Task) to automate detecting code smells
174
- * Add `reek`'s custom matcher to your [RSpec examples](https://github.com/troessner/reek/wiki/RSpec-Integration)
175
- * Include `reek` using the [Developer API](https://github.com/troessner/reek/wiki/Developer-Api)
210
+ * Use `reek`'s [Rake task](docs/Rake-Task.md) to automate detecting code smells
211
+ * Add `reek`'s custom matcher to your [RSpec examples](docs/RSpec-matchers.md)
212
+ * Include `reek` using the [Developer API](docs/API.md)
176
213
 
177
- ## Developing reek / Contributing
214
+ ## Developing `reek` / Contributing
178
215
 
179
- The first thing you want to do after checking out the source code is to run bundler
216
+ The first thing you want to do after checking out the source code is to run Bundler:
180
217
 
181
218
  ```
182
219
  bundle install
183
220
  ```
184
221
 
185
- and then to run the tests:
222
+ and then run the tests:
186
223
 
187
224
  ```bash
188
225
  bundle exec rspec spec/your/file_spec.rb # Runs all tests in spec/your/file_spec.rb
@@ -191,49 +228,65 @@ bundle exec cucumber features/your_file.feature # Runs all scenarios in your
191
228
  bundle exec cucumber features/your_file.feature:23 # Runs scenario at line 23
192
229
  ```
193
230
 
194
- Or just run the whole test suite by running
231
+ Or just run the whole test suite:
195
232
 
196
233
  ```
197
234
  bundle exec rake
198
235
  ```
199
236
 
200
- From then on continue by following the establish [pull request workflow](https://help.github.com/articles/using-pull-requests/).
237
+ From then on you should check out:
238
+ * [How reek works internally](docs/How-reek-works-internally.md)
239
+ * [the contributing guide](CONTRIBUTING.md)
240
+
201
241
 
202
242
  If you don't feel like getting your hands dirty with code there are still other ways you can help us:
203
243
 
204
- * Work on the [wiki](https://github.com/troessner/reek/wiki)
205
- * Open up an [issue](https://github.com/troessner/reek/issues) and report bugs or suggest other improvements
244
+ * Open up an [issue](https://github.com/troessner/reek/issues) and report bugs
245
+ * Suggest other improvements like additional smells for instance
206
246
 
207
247
  ## Output formats
208
248
 
209
- `reek` supports 3 output formats:
249
+ `reek` supports 5 output formats:
210
250
 
211
251
  * plain text (default)
212
- * html (`--format html`)
213
- * yaml (`--format yaml`)
214
- * json (`--format json`)
252
+ * HTML (`--format html`)
253
+ * YAML (`--format yaml`, see also [YAML Reports](docs/YAML-Reports.md))
254
+ * JSON (`--format json`)
255
+ * XML (`--format xml`)
256
+
257
+ ## Working with Rails
258
+
259
+ With current versions of `reek` it's best to examine only your `app/models` folder, because `reek` raises false positives against views and controllers.
260
+
261
+ For example, `params` is a kind of DTO (data transfer object) close to the system boundary, and so its characteristics should be different than regular code. But Reek doesn't know that (yet); `reek` thinks that all those `params[:something]` calls are a problem, and reports them as smells.
262
+
263
+ We plan to improve Reek in the near future so that it plays better with Rails. For now though, your best bet is to restrict it to looking at `app/models` and `lib`.
215
264
 
216
265
  ## Additional resources
217
266
 
218
267
  ### Tools
219
268
 
220
- There's a vim plugin for `reek`:
221
- [https://github.com/rainerborene/vim-reek](https://github.com/rainerborene/vim-reek)
269
+ * [Vim plugin for `reek`](https://github.com/rainerborene/vim-reek)
270
+ * [TextMate Bundle for `reek`](https://github.com/peeyush1234/reek.tmbundle)
271
+ * [Colorful output for `reek`](https://github.com/joenas/preek)
272
+ (also with [Guard::Preek](https://github.com/joenas/guard-preek))
273
+ * [Atom plugin for `reek`](https://atom.io/packages/linter-reek)
274
+ * [overcommit, a Git commit hook manager with support for
275
+ `reek`](https://github.com/brigade/overcommit)
222
276
 
223
- TextMate Bundle for `reek`:
224
- [https://github.com/peeyush1234/reek.tmbundle](https://github.com/peeyush1234/reek.tmbundle)
277
+ ### Miscellaneous
225
278
 
226
- Colorful output for `reek`: [Preek](https://github.com/joenas/preek) (also with
227
- [Guard::Preek](https://github.com/joenas/guard-preek))
279
+ * [Reek Driven Development](docs/Reek-Driven-Development.md)
280
+ * [Versioning policy](docs/Versioning-Policy.md)
228
281
 
229
- ### Find out more:
282
+ ### More information
230
283
 
231
284
  * [Stack Overflow](https://stackoverflow.com/questions/tagged/reek)
232
- * [RDoc](http://rdoc.info/projects/troessner/reek)
285
+ * [RubyDoc.info](http://www.rubydoc.info/gems/reek)
233
286
 
234
287
  ## Contributors
235
288
 
236
- A non exhaustive list:
289
+ A non-exhaustive list:
237
290
 
238
291
  * Kevin Rutherford
239
292
  * Matijs van Zuijlen
data/bin/reek CHANGED
@@ -6,6 +6,6 @@
6
6
  # Author: Kevin Rutherford
7
7
  #
8
8
 
9
- require 'reek/cli/application'
9
+ require_relative '../lib/reek/cli/application'
10
10
 
11
- exit Reek::Cli::Application.new(ARGV).execute
11
+ exit Reek::CLI::Application.new(ARGV).execute
@@ -0,0 +1,3 @@
1
+ default: --tags ~@wip -fprogress -r features features
2
+ wip: -fpretty --tags @wip --wip features
3
+
data/config/defaults.reek CHANGED
@@ -109,4 +109,3 @@ UnusedParameters:
109
109
  UtilityFunction:
110
110
  enabled: true
111
111
  exclude: []
112
- max_helper_calls: 1