reek 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -21
  3. data/.travis.yml +1 -0
  4. data/.yardopts +3 -6
  5. data/CHANGELOG +6 -0
  6. data/CONTRIBUTING.md +8 -3
  7. data/README.md +94 -42
  8. data/config/defaults.reek +0 -1
  9. data/docs/API.md +50 -0
  10. data/docs/Attribute.md +43 -0
  11. data/docs/Basic-Smell-Options.md +44 -0
  12. data/docs/Boolean-Parameter.md +52 -0
  13. data/docs/Class-Variable.md +40 -0
  14. data/docs/Code-Smells.md +34 -0
  15. data/docs/Command-Line-Options.md +84 -0
  16. data/docs/Configuration-Files.md +38 -0
  17. data/docs/Control-Couple.md +22 -0
  18. data/docs/Control-Parameter.md +29 -0
  19. data/docs/Data-Clump.md +44 -0
  20. data/docs/Duplicate-Method-Call.md +49 -0
  21. data/docs/Feature-Envy.md +29 -0
  22. data/docs/How-reek-works-internally.md +44 -0
  23. data/docs/Irresponsible-Module.md +39 -0
  24. data/docs/Large-Class.md +20 -0
  25. data/docs/Long-Parameter-List.md +38 -0
  26. data/docs/Long-Yield-List.md +36 -0
  27. data/docs/Module-Initialize.md +62 -0
  28. data/docs/Nested-Iterators.md +38 -0
  29. data/docs/Nil-Check.md +39 -0
  30. data/docs/Prima-Donna-Method.md +53 -0
  31. data/docs/RSpec-matchers.md +133 -0
  32. data/docs/Rake-Task.md +58 -0
  33. data/docs/Reek-Driven-Development.md +45 -0
  34. data/docs/Repeated-Conditional.md +44 -0
  35. data/docs/Simulated-Polymorphism.md +16 -0
  36. data/docs/Smell-Suppression.md +32 -0
  37. data/docs/Too-Many-Instance-Variables.md +43 -0
  38. data/docs/Too-Many-Methods.md +55 -0
  39. data/docs/Too-Many-Statements.md +50 -0
  40. data/docs/Uncommunicative-Method-Name.md +24 -0
  41. data/docs/Uncommunicative-Module-Name.md +23 -0
  42. data/docs/Uncommunicative-Name.md +16 -0
  43. data/docs/Uncommunicative-Parameter-Name.md +24 -0
  44. data/docs/Uncommunicative-Variable-Name.md +24 -0
  45. data/docs/Unused-Parameters.md +27 -0
  46. data/docs/Utility-Function.md +46 -0
  47. data/docs/Versioning-Policy.md +7 -0
  48. data/docs/YAML-Reports.md +111 -0
  49. data/docs/yard_plugin.rb +14 -0
  50. data/features/command_line_interface/options.feature +1 -0
  51. data/features/programmatic_access.feature +1 -1
  52. data/features/samples.feature +3 -3
  53. data/lib/reek.rb +2 -2
  54. data/lib/reek/cli/input.rb +2 -2
  55. data/lib/reek/cli/option_interpreter.rb +2 -0
  56. data/lib/reek/cli/options.rb +10 -4
  57. data/lib/reek/cli/reek_command.rb +2 -2
  58. data/lib/reek/cli/report/report.rb +60 -0
  59. data/lib/reek/cli/silencer.rb +13 -0
  60. data/lib/reek/{source → core}/ast_node.rb +1 -1
  61. data/lib/reek/{source → core}/ast_node_class_map.rb +10 -11
  62. data/lib/reek/{source → core}/code_comment.rb +1 -1
  63. data/lib/reek/core/code_context.rb +1 -1
  64. data/lib/reek/core/examiner.rb +85 -0
  65. data/lib/reek/core/method_context.rb +1 -1
  66. data/lib/reek/core/module_context.rb +2 -2
  67. data/lib/reek/core/reference_collector.rb +31 -0
  68. data/lib/reek/core/singleton_method_context.rb +0 -4
  69. data/lib/reek/core/smell_repository.rb +4 -2
  70. data/lib/reek/{source → core}/tree_dresser.rb +1 -1
  71. data/lib/reek/{source → sexp}/sexp_extensions.rb +5 -5
  72. data/lib/reek/sexp/sexp_formatter.rb +29 -0
  73. data/lib/reek/sexp/sexp_node.rb +91 -0
  74. data/lib/reek/smells.rb +4 -2
  75. data/lib/reek/smells/attribute.rb +35 -7
  76. data/lib/reek/smells/boolean_parameter.rb +1 -1
  77. data/lib/reek/smells/class_variable.rb +1 -1
  78. data/lib/reek/smells/control_parameter.rb +1 -1
  79. data/lib/reek/smells/data_clump.rb +1 -1
  80. data/lib/reek/smells/duplicate_method_call.rb +12 -4
  81. data/lib/reek/smells/feature_envy.rb +1 -1
  82. data/lib/reek/smells/irresponsible_module.rb +3 -3
  83. data/lib/reek/smells/long_parameter_list.rb +1 -1
  84. data/lib/reek/smells/long_yield_list.rb +1 -1
  85. data/lib/reek/smells/module_initialize.rb +1 -1
  86. data/lib/reek/smells/nested_iterators.rb +1 -1
  87. data/lib/reek/smells/nil_check.rb +3 -2
  88. data/lib/reek/smells/prima_donna_method.rb +18 -11
  89. data/lib/reek/smells/repeated_conditional.rb +3 -3
  90. data/lib/reek/smells/smell_detector.rb +5 -1
  91. data/lib/reek/smells/smell_warning.rb +99 -0
  92. data/lib/reek/smells/too_many_instance_variables.rb +1 -1
  93. data/lib/reek/smells/too_many_methods.rb +1 -1
  94. data/lib/reek/smells/too_many_statements.rb +1 -1
  95. data/lib/reek/smells/uncommunicative_method_name.rb +1 -1
  96. data/lib/reek/smells/uncommunicative_module_name.rb +1 -1
  97. data/lib/reek/smells/uncommunicative_parameter_name.rb +1 -1
  98. data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
  99. data/lib/reek/smells/unused_parameters.rb +1 -1
  100. data/lib/reek/smells/utility_function.rb +3 -16
  101. data/lib/reek/source/source_code.rb +31 -13
  102. data/lib/reek/source/source_locator.rb +16 -17
  103. data/lib/reek/source/source_repository.rb +10 -11
  104. data/lib/reek/spec/should_reek.rb +2 -2
  105. data/lib/reek/spec/should_reek_of.rb +2 -2
  106. data/lib/reek/spec/should_reek_only_of.rb +2 -2
  107. data/lib/reek/version.rb +1 -1
  108. data/reek.gemspec +3 -4
  109. data/spec/factories/factories.rb +1 -1
  110. data/spec/gem/yard_spec.rb +1 -1
  111. data/spec/quality/reek_source_spec.rb +2 -2
  112. data/spec/reek/cli/html_report_spec.rb +3 -3
  113. data/spec/reek/cli/json_report_spec.rb +3 -3
  114. data/spec/reek/cli/{option_interperter_spec.rb → option_interpreter_spec.rb} +1 -1
  115. data/spec/reek/cli/options_spec.rb +19 -0
  116. data/spec/reek/cli/text_report_spec.rb +7 -7
  117. data/spec/reek/cli/xml_report_spec.rb +34 -0
  118. data/spec/reek/cli/yaml_report_spec.rb +3 -3
  119. data/spec/reek/configuration/app_configuration_spec.rb +1 -1
  120. data/spec/reek/configuration/configuration_file_finder_spec.rb +22 -1
  121. data/spec/reek/{source → core}/code_comment_spec.rb +14 -14
  122. data/spec/reek/core/code_context_spec.rb +1 -1
  123. data/spec/reek/{examiner_spec.rb → core/examiner_spec.rb} +12 -12
  124. data/spec/reek/core/method_context_spec.rb +27 -22
  125. data/spec/reek/core/module_context_spec.rb +2 -2
  126. data/spec/reek/core/object_refs_spec.rb +1 -1
  127. data/spec/reek/{source → core}/object_source_spec.rb +1 -1
  128. data/spec/reek/{source → core}/reference_collector_spec.rb +25 -16
  129. data/spec/reek/core/singleton_method_context_spec.rb +12 -2
  130. data/spec/reek/core/smell_configuration_spec.rb +1 -1
  131. data/spec/reek/core/smell_repository_spec.rb +12 -1
  132. data/spec/reek/core/stop_context_spec.rb +1 -1
  133. data/spec/reek/core/tree_dresser_spec.rb +16 -0
  134. data/spec/reek/core/tree_walker_spec.rb +3 -3
  135. data/spec/reek/core/warning_collector_spec.rb +6 -6
  136. data/spec/reek/{source → sexp}/sexp_extensions_spec.rb +8 -8
  137. data/spec/reek/{source → sexp}/sexp_formatter_spec.rb +11 -5
  138. data/spec/reek/{source → sexp}/sexp_node_spec.rb +3 -3
  139. data/spec/reek/smells/attribute_spec.rb +89 -85
  140. data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
  141. data/spec/reek/smells/boolean_parameter_spec.rb +1 -1
  142. data/spec/reek/smells/class_variable_spec.rb +1 -1
  143. data/spec/reek/smells/control_parameter_spec.rb +1 -1
  144. data/spec/reek/smells/data_clump_spec.rb +2 -2
  145. data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
  146. data/spec/reek/smells/feature_envy_spec.rb +2 -2
  147. data/spec/reek/smells/irresponsible_module_spec.rb +1 -1
  148. data/spec/reek/smells/long_parameter_list_spec.rb +2 -2
  149. data/spec/reek/smells/long_yield_list_spec.rb +1 -1
  150. data/spec/reek/smells/module_initialize_spec.rb +1 -1
  151. data/spec/reek/smells/nested_iterators_spec.rb +2 -2
  152. data/spec/reek/smells/nil_check_spec.rb +1 -1
  153. data/spec/reek/smells/prima_donna_method_spec.rb +1 -1
  154. data/spec/reek/smells/repeated_conditional_spec.rb +1 -1
  155. data/spec/reek/smells/smell_detector_shared.rb +2 -2
  156. data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -7
  157. data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
  158. data/spec/reek/smells/too_many_methods_spec.rb +1 -1
  159. data/spec/reek/smells/too_many_statements_spec.rb +4 -4
  160. data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
  161. data/spec/reek/smells/uncommunicative_module_name_spec.rb +1 -1
  162. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +1 -1
  163. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +1 -1
  164. data/spec/reek/smells/unused_parameters_spec.rb +1 -1
  165. data/spec/reek/smells/utility_function_spec.rb +1 -1
  166. data/spec/reek/source/source_code_spec.rb +1 -1
  167. data/spec/reek/spec/should_reek_of_spec.rb +1 -1
  168. data/spec/reek/spec/should_reek_only_of_spec.rb +1 -1
  169. data/spec/reek/spec/should_reek_spec.rb +1 -1
  170. data/spec/samples/checkstyle.xml +2 -0
  171. data/spec/spec_helper.rb +15 -3
  172. metadata +68 -38
  173. data/.ruby-gemset +0 -1
  174. data/lib/reek/examiner.rb +0 -79
  175. data/lib/reek/smell_warning.rb +0 -87
  176. data/lib/reek/source/reference_collector.rb +0 -27
  177. data/lib/reek/source/sexp_formatter.rb +0 -22
  178. data/lib/reek/source/sexp_node.rb +0 -79
  179. data/spec/reek/source/tree_dresser_spec.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e3eceb35601fc0869c63c3b45034947d62e803a
4
- data.tar.gz: bfafa8489c105d8cd9681dcd1ba640f501abf928
3
+ metadata.gz: afd9361841a4f7ae194b659bbc70c06e4bef20f2
4
+ data.tar.gz: 52e321f176aca45a3c424aff60749ad3bc11f695
5
5
  SHA512:
6
- metadata.gz: f2474b97d54de8ed1b7aa7424a706d18e0f2812b2ac9e7959be70f6b301c8a643968f7cffeff6a83a98b3f65a6aae144a9e743bfca82e6bd4832cfb226b11520
7
- data.tar.gz: e4cc1838cbefcd6cdd85f3675f64476ffb1a37ec26e541778f742855cae709ae63199e1069dca2d224eb87b00090496cf344eaef2d5e1cff74467bf25ffeb8a4
6
+ metadata.gz: 87df16e382177e9a3a2f0f6465fb3eaed25ccebf274f9ebb8f3918ba81a860f93895a780c48ee12ddcae529ac544dda89715e132880ddbeee5b001a165c38003
7
+ data.tar.gz: 82b2b6aa9cde0da91999aff5ddcf8f2b6a7096b1766294023ddc3c58b0162f3e5bb27cdc653d8d0a2521f844c5580f2459d0ea2b6d66df7c31b4d7f29ab50f87
data/.rubocop.yml CHANGED
@@ -4,18 +4,15 @@ AllCops:
4
4
  - 'tmp/**/*'
5
5
  - 'vendor/**/*'
6
6
 
7
- # FIXME: Lower the ABC size by fixing the biggest offenders
8
- Metrics/AbcSize:
9
- Max: 25
10
-
11
7
  # FIXME: Make the class shorter
12
8
  Metrics/ClassLength:
13
9
  Exclude:
14
10
  - lib/reek/core/tree_walker.rb
11
+ - lib/reek/cli/options.rb
15
12
 
16
13
  # FIXME: Lower the method length by fixing the biggest offenders
17
14
  Metrics/MethodLength:
18
- Max: 46
15
+ Max: 15
19
16
 
20
17
  # Be a little more lenient with line length
21
18
  Metrics/LineLength:
@@ -33,10 +30,6 @@ Style/SingleLineMethods:
33
30
  Style/SignalException:
34
31
  EnforcedStyle: only_raise
35
32
 
36
- # Allow multiple Hash parameters to look similar
37
- Style/BracesAroundHashParameters:
38
- EnforcedStyle: context_dependent
39
-
40
33
  # Place . on the previous line
41
34
  Style/DotPosition:
42
35
  EnforcedStyle: trailing
@@ -45,14 +38,6 @@ Style/DotPosition:
45
38
  Style/EmptyLineBetweenDefs:
46
39
  AllowAdjacentOneLineDefs: true
47
40
 
48
- # Enforce GaurdClause if there are 2 or more lines in the body
49
- Style/GuardClause:
50
- MinBodyLength: 2
51
-
52
- # Allow s()
53
- Style/MethodCallParentheses:
54
- Enabled: false
55
-
56
41
  # Allow multiline block chains
57
42
  Style/MultilineBlockChain:
58
43
  Enabled: false
@@ -60,7 +45,3 @@ Style/MultilineBlockChain:
60
45
  # Allow Perl-style references to regex matches
61
46
  Style/PerlBackrefs:
62
47
  Enabled: false
63
-
64
- # Only register TrivialAccessors offenses when the name matches
65
- Style/TrivialAccessors:
66
- ExactNameMatch: true
data/.travis.yml CHANGED
@@ -16,6 +16,7 @@ matrix:
16
16
  allow_failures:
17
17
  - rvm: jruby-head
18
18
  - rvm: ruby-head
19
+ fast_finish: true
19
20
  notifications:
20
21
  recipients:
21
22
  - timo.roessner@googlemail.com
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,9 @@
1
+ == 2.2.0
2
+
3
+ * (sauliusgrigaitis) Add support for XML reports
4
+ * (beanieboi) Don’t track private methods in the Attributes smell
5
+ * (Sebastian Boehm) Do not enable colorization if stdout is not a TTY
6
+
1
7
  == 2.1.0
2
8
 
3
9
  * (mvz) Ensure require 'reek' is enough to use reek's classes
data/CONTRIBUTING.md CHANGED
@@ -46,13 +46,18 @@ bundle exec rake
46
46
  ```
47
47
 
48
48
  Once you’re sure your copy of reek works (and that there are no
49
- failing tests on master…) create your own branch and start hacking:
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):
50
55
 
51
56
  ```
52
57
  git checkout -b your_feature_or_fix_name
53
58
  ```
54
59
 
55
- Add new tests which make sure that your new feature works or
60
+ Then start hacking and add new tests which make sure that your new feature works or
56
61
  demonstrate that your fix was needed; please also [write good commit
57
62
  messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
58
63
 
@@ -100,7 +105,7 @@ If there were any fixes to your pull request we’ll ask you to
100
105
  all of the commits into one:
101
106
 
102
107
  ```
103
- git rebase -i master
108
+ git rebase -i develop
104
109
  # squash squash squash
105
110
  git push -f origin
106
111
  ```
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,20 +26,20 @@ 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 * x}}
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
@@ -68,13 +70,13 @@ So
68
70
  reek
69
71
  ```
70
72
 
71
- is the exact same thing like being explicit:
73
+ is the exact same thing as being explicit:
72
74
 
73
75
  ```Bash
74
76
  reek .
75
77
  ```
76
78
 
77
- Additionally can you pipe code to reek like this:
79
+ Additionally you can pipe code to `reek` like this:
78
80
 
79
81
  ```Bash
80
82
  echo "class C; def m; end; end" | reek
@@ -91,11 +93,22 @@ $stdin -- 3 warnings:
91
93
 
92
94
  ## Code smells
93
95
 
94
- `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.
95
108
 
96
109
  ## Configuration
97
110
 
98
- ### Command line interface
111
+ ### Command-line interface
99
112
 
100
113
  For a basic overview, run
101
114
 
@@ -103,29 +116,45 @@ For a basic overview, run
103
116
  reek --help
104
117
  ```
105
118
 
106
- 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).
107
120
 
108
- ### Configuration files
121
+ ### Configuration file
109
122
 
110
123
  #### Configuration loading
111
124
 
112
- 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.
113
126
 
114
- There are 3 ways of passing `reek` a configuration file:
127
+ There are three ways of passing `reek` a configuration file:
115
128
 
116
- 1. Using the cli "-c" switch (see "Command line interface" above)
117
- 2. Having a file ending with .reek either in your current working directory or in a parent directory (more on that later)
118
- 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
119
132
 
120
- 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.
121
139
 
122
- 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.
123
144
 
124
145
  #### Configuration options
125
146
 
126
- 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.
127
- 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).
128
- 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).
129
158
 
130
159
  Here's an excerpt of a `reek` configuration file from a commercial project:
131
160
 
@@ -133,12 +162,14 @@ Here's an excerpt of a `reek` configuration file from a commercial project:
133
162
  ---
134
163
  IrresponsibleModule:
135
164
  enabled: false
165
+
136
166
  NestedIterators:
137
167
  exclude:
138
168
  - "ActiveModelErrorAdder#self.run" # should be refactored
139
169
  - "BookingRequests::Transfer#remote_validation"
140
170
  - "BookingRequestsController#vehicle_options" # respond_to block
141
171
  - "Content::Base#self.expose_fields" # unavoidable due to metaprogramming
172
+
142
173
  DataClump:
143
174
  max_copies: 3
144
175
  min_clump_size: 3
@@ -146,7 +177,9 @@ DataClump:
146
177
 
147
178
  ### Source code comments
148
179
 
149
- `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:
180
+ `reek` is not the police. In case you need to suppress a smell
181
+ warning and you can't or don't want to use configuration files for
182
+ whatever reasons you can also use source code comments like this:
150
183
 
151
184
  ```Ruby
152
185
  # This method smells of :reek:NestedIterators
@@ -155,7 +188,7 @@ def smelly_method foo
155
188
  end
156
189
  ```
157
190
 
158
- This is further explained [here](https://github.com/troessner/reek/wiki/Smell-Suppression)
191
+ This is further explained under [Smell Suppresion](docs/Smell-Suppression.md).
159
192
 
160
193
 
161
194
  ## Integration
@@ -166,21 +199,21 @@ Besides the obvious
166
199
  reek [options] [dir_or_source_file]*
167
200
  ```
168
201
 
169
- there are quite a few other ways how to use reek in your projects:
202
+ there are quite a few other ways how to use `reek` in your projects:
170
203
 
171
- * Use `reek`'s [Rake Task](https://github.com/troessner/reek/wiki/Rake-Task) to automate detecting code smells
172
- * Add `reek`'s custom matcher to your [RSpec examples](https://github.com/troessner/reek/wiki/RSpec-matchers)
173
- * Include `reek` using the [Developer API](https://github.com/troessner/reek/wiki/Developer-Api)
204
+ * Use `reek`'s [Rake task](docs/Rake-Task.md) to automate detecting code smells
205
+ * Add `reek`'s custom matcher to your [RSpec examples](docs/RSpec-matchers.md)
206
+ * Include `reek` using the [Developer API](docs/API.md)
174
207
 
175
- ## Developing reek / Contributing
208
+ ## Developing `reek` / Contributing
176
209
 
177
- The first thing you want to do after checking out the source code is to run bundler
210
+ The first thing you want to do after checking out the source code is to run Bundler:
178
211
 
179
212
  ```
180
213
  bundle install
181
214
  ```
182
215
 
183
- and then to run the tests:
216
+ and then run the tests:
184
217
 
185
218
  ```bash
186
219
  bundle exec rspec spec/your/file_spec.rb # Runs all tests in spec/your/file_spec.rb
@@ -189,27 +222,39 @@ bundle exec cucumber features/your_file.feature # Runs all scenarios in your
189
222
  bundle exec cucumber features/your_file.feature:23 # Runs scenario at line 23
190
223
  ```
191
224
 
192
- Or just run the whole test suite by running
225
+ Or just run the whole test suite:
193
226
 
194
227
  ```
195
228
  bundle exec rake
196
229
  ```
197
230
 
198
- From then on continue by following the establish [pull request workflow](https://help.github.com/articles/using-pull-requests/).
231
+ From then on you should check out:
232
+ * [How reek works internally](docs/How-reek-works-internally.md)
233
+ * [the contributing guide](CONTRIBUTING.md)
234
+
199
235
 
200
236
  If you don't feel like getting your hands dirty with code there are still other ways you can help us:
201
237
 
202
- * Work on the [wiki](https://github.com/troessner/reek/wiki)
203
- * Open up an [issue](https://github.com/troessner/reek/issues) and report bugs or suggest other improvements
238
+ * Open up an [issue](https://github.com/troessner/reek/issues) and report bugs
239
+ * Suggest other improvements like additional smells for instance
204
240
 
205
241
  ## Output formats
206
242
 
207
- `reek` supports 3 output formats:
243
+ `reek` supports 5 output formats:
208
244
 
209
245
  * plain text (default)
210
- * html (`--format html`)
211
- * yaml (`--format yaml`)
212
- * json (`--format json`)
246
+ * HTML (`--format html`)
247
+ * YAML (`--format yaml`, see also [YAML Reports](docs/YAML-Reports.md))
248
+ * JSON (`--format json`)
249
+ * XML (`--format xml`)
250
+
251
+ ## Working with Rails
252
+
253
+ With current versions of `reek` it's best to examine only your `app/models` folder, because `reek` raises false positives against views and controllers.
254
+
255
+ 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.
256
+
257
+ 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`.
213
258
 
214
259
  ## Additional resources
215
260
 
@@ -220,15 +265,22 @@ If you don't feel like getting your hands dirty with code there are still other
220
265
  * [Colorful output for `reek`](https://github.com/joenas/preek)
221
266
  (also with [Guard::Preek](https://github.com/joenas/guard-preek))
222
267
  * [Atom plugin for `reek`](https://atom.io/packages/linter-reek)
268
+ * [overcommit, a Git commit hook manager with support for
269
+ `reek`](https://github.com/brigade/overcommit)
270
+
271
+ ### Miscellaneous
272
+
273
+ * [Reek Driven Development](docs/Reek-Driven-Development.md)
274
+ * [Versioning policy](docs/Versioning-Policy.md)
223
275
 
224
- ### Find out more:
276
+ ### More information
225
277
 
226
278
  * [Stack Overflow](https://stackoverflow.com/questions/tagged/reek)
227
- * [RDoc](http://rdoc.info/projects/troessner/reek)
279
+ * [RubyDoc.info](http://www.rubydoc.info/gems/reek)
228
280
 
229
281
  ## Contributors
230
282
 
231
- A non exhaustive list:
283
+ A non-exhaustive list:
232
284
 
233
285
  * Kevin Rutherford
234
286
  * Matijs van Zuijlen
data/config/defaults.reek CHANGED
@@ -109,4 +109,3 @@ UnusedParameters:
109
109
  UtilityFunction:
110
110
  enabled: true
111
111
  exclude: []
112
- max_helper_calls: 0
data/docs/API.md ADDED
@@ -0,0 +1,50 @@
1
+ # API
2
+
3
+ ## Using `reek` inside your Ruby application
4
+
5
+ `reek` can be used inside another Ruby project.
6
+
7
+ ```bash
8
+ gem install reek
9
+ ```
10
+
11
+ You can use reek inside your Ruby file `check_dirty.rb`
12
+
13
+ ```ruby
14
+ require 'reek'
15
+ require 'reek/source/source_code'
16
+ require 'reek/cli/report/report'
17
+ require 'reek/core/examiner'
18
+
19
+ source =<<END
20
+ class Dirty
21
+ # This method smells of :reek:NestedIterators but ignores them
22
+ def awful(x, y, offset = 0, log = false)
23
+ puts @screen.title
24
+ @screen = widgets.map { |w| w.each { |key| key += 3 * x } }
25
+ puts @screen.contents
26
+ fail
27
+ end
28
+ end
29
+ END
30
+
31
+ source_code = Reek::Source::SourceCode.from(source)
32
+ reporter = Reek::CLI::Report::TextReport.new
33
+ reporter.add_examiner Reek::Core::Examiner.new(source_code)
34
+ puts reporter.show
35
+ ```
36
+
37
+ This will show the list of errors in variable `source`.
38
+
39
+ `reek` can take `source` as `String`, `File` or `IO`.
40
+
41
+ Also, besides normal text output, `reek` can also generate output in YAML,
42
+ JSON, HTML and XML by using the following Report types:
43
+
44
+ ```
45
+ TextReport
46
+ YAMLReport
47
+ JSONReport
48
+ HTMLReport
49
+ XMLReport
50
+ ```