reek 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +19 -12
- data/CONTRIBUTING.md +7 -7
- data/README.md +91 -28
- data/ataru_setup.rb +13 -0
- data/{config/defaults.reek → defaults.reek} +0 -0
- data/docs/API.md +32 -31
- data/docs/Attribute.md +1 -1
- data/docs/Basic-Smell-Options.md +2 -1
- data/docs/Boolean-Parameter.md +1 -1
- data/docs/Class-Variable.md +2 -2
- data/docs/Command-Line-Options.md +2 -2
- data/docs/Control-Couple.md +3 -3
- data/docs/Control-Parameter.md +2 -2
- data/docs/Data-Clump.md +2 -2
- data/docs/Duplicate-Method-Call.md +4 -4
- data/docs/Feature-Envy.md +2 -2
- data/docs/How-reek-works-internally.md +2 -2
- data/docs/Irresponsible-Module.md +2 -2
- data/docs/Large-Class.md +2 -2
- data/docs/Long-Parameter-List.md +1 -1
- data/docs/Long-Yield-List.md +2 -2
- data/docs/Module-Initialize.md +3 -3
- data/docs/Nested-Iterators.md +1 -1
- data/docs/Nil-Check.md +2 -2
- data/docs/Prima-Donna-Method.md +4 -4
- data/docs/RSpec-matchers.md +7 -7
- data/docs/Rake-Task.md +2 -2
- data/docs/Reek-Driven-Development.md +4 -4
- data/docs/Repeated-Conditional.md +2 -2
- data/docs/Simulated-Polymorphism.md +2 -2
- data/docs/Smell-Suppression.md +3 -3
- data/docs/Too-Many-Instance-Variables.md +4 -4
- data/docs/Too-Many-Methods.md +5 -5
- data/docs/Too-Many-Statements.md +2 -2
- data/docs/Uncommunicative-Method-Name.md +4 -4
- data/docs/Uncommunicative-Module-Name.md +4 -4
- data/docs/Uncommunicative-Name.md +2 -2
- data/docs/Uncommunicative-Parameter-Name.md +4 -4
- data/docs/Uncommunicative-Variable-Name.md +3 -3
- data/docs/Unused-Parameters.md +2 -2
- data/docs/Utility-Function.md +4 -4
- data/docs/Versioning-Policy.md +2 -2
- data/features/command_line_interface/options.feature +1 -1
- data/features/configuration_files/directory_specific_directives.feature +4 -4
- data/features/configuration_loading.feature +10 -24
- data/features/programmatic_access.feature +3 -3
- data/features/reports/json.feature +1 -1
- data/features/reports/reports.feature +2 -2
- data/features/reports/yaml.feature +1 -1
- data/lib/reek/ast/sexp_extensions.rb +17 -498
- data/lib/reek/ast/sexp_extensions/arguments.rb +101 -0
- data/lib/reek/ast/sexp_extensions/attribute_assignments.rb +12 -0
- data/lib/reek/ast/sexp_extensions/block.rb +36 -0
- data/lib/reek/ast/sexp_extensions/case.rb +20 -0
- data/lib/reek/ast/sexp_extensions/constant.rb +12 -0
- data/lib/reek/ast/sexp_extensions/if.rb +16 -0
- data/lib/reek/ast/sexp_extensions/literal.rb +12 -0
- data/lib/reek/ast/sexp_extensions/logical_operators.rb +26 -0
- data/lib/reek/ast/sexp_extensions/methods.rb +114 -0
- data/lib/reek/ast/sexp_extensions/module.rb +85 -0
- data/lib/reek/ast/sexp_extensions/nested_assignables.rb +23 -0
- data/lib/reek/ast/sexp_extensions/send.rb +60 -0
- data/lib/reek/ast/sexp_extensions/super.rb +14 -0
- data/lib/reek/ast/sexp_extensions/symbols.rb +16 -0
- data/lib/reek/ast/sexp_extensions/variables.rb +38 -0
- data/lib/reek/ast/sexp_extensions/when.rb +16 -0
- data/lib/reek/ast/sexp_extensions/yield.rb +16 -0
- data/lib/reek/cli/application.rb +0 -4
- data/lib/reek/cli/options.rb +2 -4
- data/lib/reek/configuration/app_configuration.rb +37 -9
- data/lib/reek/configuration/configuration_file_finder.rb +8 -5
- data/lib/reek/configuration/directory_directives.rb +2 -2
- data/lib/reek/context/attribute_context.rb +21 -0
- data/lib/reek/context/code_context.rb +5 -9
- data/lib/reek/rake/task.rb +5 -5
- data/lib/reek/smells/nested_iterators.rb +73 -26
- data/lib/reek/smells/smell_warning.rb +1 -38
- data/lib/reek/source/source_code.rb +1 -1
- data/lib/reek/spec.rb +2 -2
- data/lib/reek/spec/should_reek_of.rb +8 -3
- data/lib/reek/spec/should_reek_only_of.rb +2 -1
- data/lib/reek/spec/smell_matcher.rb +59 -0
- data/lib/reek/tree_walker.rb +4 -3
- data/lib/reek/version.rb +1 -1
- data/logo/reek.bw.png +0 -0
- data/logo/reek.bw.svg +77 -0
- data/logo/reek.png +0 -0
- data/logo/reek.svg +621 -0
- data/logo/reek.text.png +0 -0
- data/logo/reek.text.svg +628 -0
- data/reek.gemspec +1 -1
- data/spec/factories/factories.rb +0 -1
- data/spec/reek/ast/sexp_extensions_spec.rb +0 -7
- data/spec/reek/cli/options_spec.rb +1 -2
- data/spec/reek/configuration/app_configuration_spec.rb +30 -14
- data/spec/reek/configuration/configuration_file_finder_spec.rb +23 -5
- data/spec/reek/smells/attribute_spec.rb +11 -2
- data/spec/reek/smells/boolean_parameter_spec.rb +14 -12
- data/spec/reek/smells/class_variable_spec.rb +18 -15
- data/spec/reek/smells/control_parameter_spec.rb +1 -2
- data/spec/reek/smells/duplicate_method_call_spec.rb +1 -2
- data/spec/reek/smells/feature_envy_spec.rb +8 -29
- data/spec/reek/smells/irresponsible_module_spec.rb +1 -2
- data/spec/reek/smells/long_parameter_list_spec.rb +1 -2
- data/spec/reek/smells/long_yield_list_spec.rb +1 -2
- data/spec/reek/smells/nested_iterators_spec.rb +1 -2
- data/spec/reek/smells/nil_check_spec.rb +1 -1
- data/spec/reek/smells/prima_donna_method_spec.rb +1 -1
- data/spec/reek/smells/repeated_conditional_spec.rb +1 -2
- data/spec/reek/smells/smell_detector_shared.rb +1 -1
- data/spec/reek/smells/smell_warning_spec.rb +2 -4
- data/spec/reek/smells/too_many_instance_variables_spec.rb +20 -19
- data/spec/reek/smells/too_many_statements_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -4
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +1 -4
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +1 -4
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +3 -3
- data/spec/reek/smells/utility_function_spec.rb +1 -3
- data/spec/reek/spec/should_reek_of_spec.rb +5 -5
- data/spec/reek/spec/smell_matcher_spec.rb +92 -0
- data/tasks/configuration.rake +15 -0
- metadata +37 -5
- data/config/cucumber.yml +0 -3
- data/tasks/develop.rake +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dcff37dc4ddba77bf578314779a49fab1fcd0e7
|
4
|
+
data.tar.gz: d3a82f168438222a7a5bbab73a491b877cbd8144
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccc8992f22bda5b7be9d68ee269fb454db74f179dd2ebe05c42d78b4b0c779af0202e511f43c337507187e411c03be58ab740a8383b79844c04f64d11c4e7ffc
|
7
|
+
data.tar.gz: b11c75c4d4ebf103cb97355b3688049ba275165783fba752b5c9cefe5c94cbeaa6f2a38dd0b1c5f6ab2faf0368c4e7548da42b56685acbf1f7f71a7cf9b8cf1d
|
data/.rubocop.yml
CHANGED
@@ -53,3 +53,9 @@ Style/MultilineBlockChain:
|
|
53
53
|
# Allow Perl-style references to regex matches
|
54
54
|
Style/PerlBackrefs:
|
55
55
|
Enabled: false
|
56
|
+
|
57
|
+
Style/Documentation:
|
58
|
+
Exclude:
|
59
|
+
- 'lib/reek/ast/sexp_extensions/send.rb'
|
60
|
+
- 'lib/reek/ast/sexp_extensions/super.rb'
|
61
|
+
- 'lib/reek/ast/sexp_extensions/variables.rb'
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 3.6 (2015-10-30)
|
6
|
+
|
7
|
+
* (mvz) Make Attribute respect suppressing comments
|
8
|
+
* (chastell) Adjust parser dependency to allow versions 2.2.3+ (and even 2.3+)
|
9
|
+
* (tansaku + mvz) Allow matches in reek_of for message, lines, context and source.
|
10
|
+
* (mvz) Deprecate AppConfiguration.from_map in favor of AppConfiguration.from_hash.
|
11
|
+
|
5
12
|
## 3.5.0 (2015-09-28)
|
6
13
|
|
7
14
|
* (troessner) Ignore iterators without block arguments for NestedIterators
|
@@ -66,7 +73,7 @@
|
|
66
73
|
|
67
74
|
## 3.0.1 (2015-07-03)
|
68
75
|
|
69
|
-
* (troessner) Fix
|
76
|
+
* (troessner) Fix Reek descending into hidden directories
|
70
77
|
|
71
78
|
## 3.0.0 (2015-06-30)
|
72
79
|
|
@@ -88,7 +95,7 @@
|
|
88
95
|
|
89
96
|
## 2.1.0 (2015-04-17)
|
90
97
|
|
91
|
-
* (mvz) Ensure require 'reek' is enough to use
|
98
|
+
* (mvz) Ensure require 'reek' is enough to use Reek's classes
|
92
99
|
* (mvz) Pick config file that comes first alphabetically
|
93
100
|
* (mvz) Separate FeatureEnvy and UtilityFunction
|
94
101
|
|
@@ -137,17 +144,17 @@
|
|
137
144
|
## 1.6.0 (2014-12-27)
|
138
145
|
|
139
146
|
* (troessner) Revise configuration handling:
|
140
|
-
Now there are 3 ways of passing
|
147
|
+
Now there are 3 ways of passing Reek a configuration file:
|
141
148
|
- Using the cli "-c" switch
|
142
149
|
- Having a file ending with .reek either in your current working directory or in a parent directory (more on that later)
|
143
150
|
- Having a file ending with .reek in your HOME directory
|
144
151
|
|
145
|
-
The order in which
|
146
|
-
like above: First
|
152
|
+
The order in which Reek tries to find such a configuration file is exactly
|
153
|
+
like above: First Reek checks if we have given it a configuration file
|
147
154
|
explicitly via CLI. Then it checks the current working directory for a file and
|
148
155
|
if it can't find one, it traverses up the directories until it hits the root
|
149
|
-
directory. And lastly, it checks your HOME directory. As soon as
|
150
|
-
configuration file it stops searching immediately, meaning that from
|
156
|
+
directory. And lastly, it checks your HOME directory. As soon as Reek detects a
|
157
|
+
configuration file it stops searching immediately, meaning that from Reek's
|
151
158
|
point of view there exists one configuration file and one configuration only
|
152
159
|
regardless of how many ".reek" files you might have on your filesystem.
|
153
160
|
* (chastell) Add keyword arguments support after switching to 'parser'
|
@@ -177,7 +184,7 @@
|
|
177
184
|
|
178
185
|
## 1.3.7 (2014-03-25)
|
179
186
|
|
180
|
-
* (gilles-leblanc) Add color to
|
187
|
+
* (gilles-leblanc) Add color to Reek's output
|
181
188
|
* (mvz) Ignore unused parameters if method calls super in nested context
|
182
189
|
* (mvz) Only mark parameters uncommunicative if used
|
183
190
|
|
@@ -227,7 +234,7 @@
|
|
227
234
|
|
228
235
|
## 1.2.12 (2012-06-09)
|
229
236
|
|
230
|
-
* (mvz) Use ripper_ruby_parser on Ruby 1.9.3 and up (thus making
|
237
|
+
* (mvz) Use ripper_ruby_parser on Ruby 1.9.3 and up (thus making Reek able
|
231
238
|
to parse the new 1.9 hash syntax).
|
232
239
|
|
233
240
|
## 1.2.11 (2012-06-08)
|
@@ -446,10 +453,10 @@ See http://wiki.github.com/kevinrutherford/reek for details
|
|
446
453
|
|
447
454
|
### Minor enhancements
|
448
455
|
* New smell: first naive checks for Control Couple
|
449
|
-
*
|
456
|
+
* Reek now only checks sources passed on the command line
|
450
457
|
* Code snippets can be supplied on the commandline
|
451
458
|
* Added headings and warnings count when smells in multiple files
|
452
|
-
* Added Reek::RakeTask to run
|
459
|
+
* Added Reek::RakeTask to run Reek from rakefiles
|
453
460
|
|
454
461
|
### Fixes
|
455
462
|
* Fixed: Returns exit status 2 when smells are reported
|
@@ -475,7 +482,7 @@ See http://wiki.github.com/kevinrutherford/reek for details
|
|
475
482
|
|
476
483
|
* Tweaks:
|
477
484
|
* Now works from the source code, instead of requiring each named file
|
478
|
-
* Added integration tests that run
|
485
|
+
* Added integration tests that run Reek on a couple of gems
|
479
486
|
|
480
487
|
## 0.2.0 2008-09-10
|
481
488
|
|
data/CONTRIBUTING.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Contributing to
|
1
|
+
# Contributing to Reek
|
2
2
|
|
3
|
-
We welcome any and all contributions to
|
3
|
+
We welcome any and all contributions to Reek!
|
4
4
|
|
5
5
|
If what you’re proposing requires significant work discuss it beforehand
|
6
6
|
as an issue – it’s much easier for us to guide you towards a good
|
@@ -22,8 +22,8 @@ actually resolved properly or you have any additional information.
|
|
22
22
|
Include the steps to reproduce the issue,
|
23
23
|
the expected outcome and the actual outcome.
|
24
24
|
|
25
|
-
Include as much information as possible: the exact
|
26
|
-
invocation that you use,
|
25
|
+
Include as much information as possible: the exact Reek
|
26
|
+
invocation that you use, Reek’s config and version, Ruby
|
27
27
|
version, Ruby platform (MRI, JRuby, etc.), operating system.
|
28
28
|
|
29
29
|
Try to provide a minimal example that reproduces the issue.
|
@@ -33,7 +33,7 @@ Extra kudos if you can write it as a failing test. :)
|
|
33
33
|
|
34
34
|
## Setup and Pull Request Basics
|
35
35
|
|
36
|
-
Fork
|
36
|
+
Fork Reek, then clone it, make sure you have
|
37
37
|
[Bundler](http://bundler.io) installed, install dependencies
|
38
38
|
and make sure all of the existing tests pass:
|
39
39
|
|
@@ -45,7 +45,7 @@ bundle
|
|
45
45
|
bundle exec rake
|
46
46
|
```
|
47
47
|
|
48
|
-
Once you’re sure your copy of
|
48
|
+
Once you’re sure your copy of Reek works create your own feature branch from our "master" branch:
|
49
49
|
|
50
50
|
```
|
51
51
|
git checkout -b your_feature_or_fix_name
|
@@ -84,7 +84,7 @@ Try to gauge and let us know in the pull request whether what
|
|
84
84
|
you propose is a backward-compatible bugfix and should go into the
|
85
85
|
next patch release, is a backward-compatible feature and should go
|
86
86
|
into the next minor release, or has to break backward-compatibility
|
87
|
-
and so needs to wait for the next major release of
|
87
|
+
and so needs to wait for the next major release of Reek.
|
88
88
|
|
89
89
|
Once your PR is open someone will review it, discuss the details (if
|
90
90
|
needed) and either merge right away or ask for some further fixes.
|
data/README.md
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
|
1
|
+
![reek logo](logo/reek.text.png)
|
2
|
+
|
3
|
+
# Code smell detector for Ruby
|
2
4
|
|
3
5
|
## Overview
|
4
6
|
|
5
7
|
|
6
|
-
[![Build Status](https://secure.travis-ci.org/troessner/reek.
|
8
|
+
[![Build Status](https://secure.travis-ci.org/troessner/reek.svg?branch=master)](https://travis-ci.org/troessner/reek?branch=master)
|
7
9
|
[![Gem Version](https://badge.fury.io/rb/reek.svg)](https://badge.fury.io/rb/reek)
|
8
10
|
[![Dependency Status](https://gemnasium.com/troessner/reek.png)](https://gemnasium.com/troessner/reek)
|
9
11
|
[![Inline docs](https://inch-ci.org/github/troessner/reek.png)](https://inch-ci.org/github/troessner/reek)
|
10
12
|
|
11
13
|
## Quickstart
|
12
14
|
|
13
|
-
|
15
|
+
Reek is a tool that examines Ruby classes, modules and methods and reports any
|
14
16
|
[Code Smells](docs/Code-Smells.md) it finds.
|
15
17
|
Install it like this:
|
16
18
|
|
@@ -39,7 +41,7 @@ class Dirty
|
|
39
41
|
end
|
40
42
|
```
|
41
43
|
|
42
|
-
|
44
|
+
Reek will report the following code smells in this file:
|
43
45
|
|
44
46
|
```
|
45
47
|
$ reek demo.rb
|
@@ -54,6 +56,65 @@ demo.rb -- 8 warnings:
|
|
54
56
|
[3]:Dirty#awful has unused parameter 'y' (UnusedParameters)
|
55
57
|
```
|
56
58
|
|
59
|
+
## Fixing Smell Warnings
|
60
|
+
|
61
|
+
Reek focuses on high-level code smells, so we can't tell you how to fix warnings in
|
62
|
+
a generic fashion; this is and will always be completely dependent on your domain
|
63
|
+
language and bussiness logic.
|
64
|
+
|
65
|
+
That said, an example might help you get going. Have a look at this sample of a
|
66
|
+
Ruby on Rails model (be aware that this is truncated, not working code):
|
67
|
+
|
68
|
+
```Ruby
|
69
|
+
class ShoppingCart < ActiveRecord::Base
|
70
|
+
has_many :items
|
71
|
+
|
72
|
+
def gross_price
|
73
|
+
items.sum { |item| item.net + item.tax }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class Item < ActiveRecord::Base
|
78
|
+
belongs_to :shopping_cart
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
Running `reek` on this file like this:
|
83
|
+
|
84
|
+
```
|
85
|
+
reek app/models/shopping_cart.rb
|
86
|
+
```
|
87
|
+
|
88
|
+
would report:
|
89
|
+
|
90
|
+
```
|
91
|
+
[5, 5]:ShoppingCart#gross_price refers to item more than self (FeatureEnvy)
|
92
|
+
```
|
93
|
+
|
94
|
+
Fixing this is pretty straightforward. Put the gross price calculation for a single item
|
95
|
+
where it belongs, which would be the `Item` class:
|
96
|
+
|
97
|
+
```Ruby
|
98
|
+
class ShoppingCart < ActiveRecord::Base
|
99
|
+
has_many :items
|
100
|
+
|
101
|
+
def gross_price
|
102
|
+
items.sum { |item| item.gross_price }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Item < ActiveRecord::Base
|
107
|
+
belongs_to :shopping_cart
|
108
|
+
|
109
|
+
def gross_price
|
110
|
+
net + tax
|
111
|
+
end
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
The [Code Smells](docs/Code-Smells.md) docs may give you further hints - be sure to check out
|
116
|
+
those first when you have a warning that you don't know how to deal with.
|
117
|
+
|
57
118
|
## Sources
|
58
119
|
|
59
120
|
There are multiple ways you can have `reek` work on sources, the most common one just being
|
@@ -93,7 +154,7 @@ $stdin -- 3 warnings:
|
|
93
154
|
|
94
155
|
## Code smells
|
95
156
|
|
96
|
-
|
157
|
+
Reek currently includes checks for some aspects of
|
97
158
|
[Control Couple](docs/Control-Couple.md),
|
98
159
|
[Data Clump](docs/Data-Clump.md),
|
99
160
|
[Feature Envy](docs/Feature-Envy.md),
|
@@ -104,7 +165,7 @@ $stdin -- 3 warnings:
|
|
104
165
|
[Uncommunicative Name](docs/Uncommunicative-Name.md),
|
105
166
|
[Unused Parameters](docs/Unused-Parameters.md)
|
106
167
|
and more. See the [Code Smells](docs/Code-Smells.md)
|
107
|
-
for up to date details of exactly what
|
168
|
+
for up to date details of exactly what Reek will check in your code.
|
108
169
|
|
109
170
|
## Configuration
|
110
171
|
|
@@ -122,7 +183,7 @@ For a summary of those CLI options see [Command-Line Options](docs/Command-Line-
|
|
122
183
|
|
123
184
|
#### Configuration loading
|
124
185
|
|
125
|
-
Configuring
|
186
|
+
Configuring Reek via a configuration file is by far the most powerful way.
|
126
187
|
|
127
188
|
There are three ways of passing `reek` a configuration file:
|
128
189
|
|
@@ -130,21 +191,21 @@ There are three ways of passing `reek` a configuration file:
|
|
130
191
|
2. Having a file ending with `.reek` either in your current working directory or in a parent directory (more on that later)
|
131
192
|
3. Having a file ending with `.reek` in your home directory
|
132
193
|
|
133
|
-
The order in which
|
194
|
+
The order in which Reek tries to find such a configuration
|
134
195
|
file is exactly the above: first it checks if we have given
|
135
196
|
it a configuration file explicitly via CLI; then it checks
|
136
197
|
the current working directory for a file and if it can't
|
137
198
|
find one, it traverses up the directories until it hits the
|
138
199
|
root directory; lastly, it checks your home directory.
|
139
200
|
|
140
|
-
As soon as
|
141
|
-
immediately, meaning that from
|
201
|
+
As soon as Reek detects a configuration file it stops searching
|
202
|
+
immediately, meaning that from Reek's point of view there exists
|
142
203
|
exactly one configuration file and one configuration, regardless
|
143
204
|
of how many `*.reek` files you might have on your filesystem.
|
144
205
|
|
145
206
|
#### Configuration options
|
146
207
|
|
147
|
-
We put a lot of effort into making
|
208
|
+
We put a lot of effort into making Reek's configuration as self explanatory as possible so the
|
148
209
|
best way to understand it is by looking at a simple
|
149
210
|
example (e.g. `config.reek` in your project directory):
|
150
211
|
|
@@ -157,8 +218,8 @@ example (e.g. `config.reek` in your project directory):
|
|
157
218
|
IrresponsibleModule:
|
158
219
|
enabled: false
|
159
220
|
|
160
|
-
# You can use filters to silence
|
161
|
-
# Either because you simply disagree with
|
221
|
+
# You can use filters to silence Reek warnings.
|
222
|
+
# Either because you simply disagree with Reek (we are not the police) or
|
162
223
|
# because you want to fix this at a later point in time.
|
163
224
|
NestedIterators:
|
164
225
|
exclude:
|
@@ -167,7 +228,7 @@ NestedIterators:
|
|
167
228
|
|
168
229
|
# A lot of smells allow fine tuning their configuration. You can look up all available options
|
169
230
|
# in the corresponding smell documentation in /docs. In most cases you probably can just go
|
170
|
-
# with the defaults
|
231
|
+
# with the defaults as documented in defaults.reek.
|
171
232
|
DataClump:
|
172
233
|
max_copies: 3
|
173
234
|
min_clump_size: 3
|
@@ -192,7 +253,7 @@ exclude_paths:
|
|
192
253
|
- lib/rake/legacy_tasks
|
193
254
|
```
|
194
255
|
|
195
|
-
Note you do not need a configuration file at all. If you're fine with all the [defaults](
|
256
|
+
Note you do not need a configuration file at all. If you're fine with all the [defaults](defaults.reek) we set you can skip this completely.
|
196
257
|
|
197
258
|
For more details please check out the [Basic Smell Options](docs/Basic-Smell-Options.md)
|
198
259
|
which are supported by every smell type. As you can see above, certain smell
|
@@ -200,7 +261,7 @@ types offer a configuration that goes beyond that of the basic smell options, fo
|
|
200
261
|
[Data Clump](docs/Data-Clump.md).
|
201
262
|
All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md)
|
202
263
|
are documented in the corresponding smell type /docs page (if you want to get a quick overview over all possible
|
203
|
-
configurations you can also check out [the `
|
264
|
+
configurations you can also check out [the `default.reek` file in this repository](defaults.reek).
|
204
265
|
|
205
266
|
### Source code comments
|
206
267
|
|
@@ -234,13 +295,13 @@ Besides the obvious
|
|
234
295
|
reek [options] [dir_or_source_file]*
|
235
296
|
```
|
236
297
|
|
237
|
-
there are quite a few other ways how to use
|
298
|
+
there are quite a few other ways how to use Reek in your projects:
|
238
299
|
|
239
|
-
* Use
|
240
|
-
* Add
|
241
|
-
* Include
|
300
|
+
* Use Reek's [Rake task](docs/Rake-Task.md) to automate detecting code smells
|
301
|
+
* Add Reek's custom matcher to your [RSpec examples](docs/RSpec-matchers.md)
|
302
|
+
* Include Reek using the [Developer API](docs/API.md)
|
242
303
|
|
243
|
-
## Developing
|
304
|
+
## Developing Reek / Contributing
|
244
305
|
|
245
306
|
The first thing you want to do after checking out the source code is to run Bundler:
|
246
307
|
|
@@ -264,7 +325,7 @@ bundle exec rake
|
|
264
325
|
```
|
265
326
|
|
266
327
|
From then on you should check out:
|
267
|
-
* [How
|
328
|
+
* [How Reek works internally](docs/How-reek-works-internally.md)
|
268
329
|
* [the contributing guide](CONTRIBUTING.md)
|
269
330
|
|
270
331
|
|
@@ -285,7 +346,7 @@ If you don't feel like getting your hands dirty with code there are still other
|
|
285
346
|
|
286
347
|
## Working with Rails
|
287
348
|
|
288
|
-
Making
|
349
|
+
Making Reek "Rails"-friendly is fairly simple since we support directory specific configurations (`directory directives` in Reek talk).
|
289
350
|
Just add this to your configuration file:
|
290
351
|
|
291
352
|
```Yaml
|
@@ -301,7 +362,7 @@ Just add this to your configuration file:
|
|
301
362
|
enabled: false
|
302
363
|
```
|
303
364
|
|
304
|
-
Be careful though,
|
365
|
+
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.
|
305
366
|
|
306
367
|
## Integrations
|
307
368
|
|
@@ -314,9 +375,9 @@ Be careful though, `reek` does not merge your configuration entries, so if you a
|
|
314
375
|
### Projects that use or support us
|
315
376
|
|
316
377
|
* [overcommit](https://github.com/brigade/overcommit) - a Git commit hook manager with support for
|
317
|
-
|
378
|
+
Reek
|
318
379
|
* [ruby-critic](https://github.com/whitesmith/rubycritic) - gem that wraps around static analysis gems such as `reek`, [flay](https://github.com/seattlerb/flay) and [flog](https://github.com/seattlerb/flog)
|
319
|
-
* [pronto-reek](https://github.com/mmozuras/pronto-reek) -
|
380
|
+
* [pronto-reek](https://github.com/mmozuras/pronto-reek) - Reek integration for [pronto](https://github.com/mmozuras/pronto)
|
320
381
|
|
321
382
|
### Misc
|
322
383
|
|
@@ -337,13 +398,15 @@ report
|
|
337
398
|
|
338
399
|
## Contributors
|
339
400
|
|
340
|
-
The
|
401
|
+
The Reek core team consists of:
|
341
402
|
|
342
403
|
* [Matijs van Zuijlen](https://github.com/mvz)
|
343
404
|
* [Piotr Szotkowski](https://github.com/chastell)
|
344
405
|
* [Timo Rößner](https://github.com/troessner)
|
345
406
|
|
346
|
-
The original author of
|
407
|
+
The original author of Reek is [Kevin Rutherford](https://github.com/kevinrutherford).
|
408
|
+
|
409
|
+
The author of Reek’s logo is [Sonja Heinen](http://yippee.io).
|
347
410
|
|
348
411
|
Notable contributions came from:
|
349
412
|
|
data/ataru_setup.rb
ADDED
File without changes
|
data/docs/API.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Using
|
1
|
+
# Using Reek inside your Ruby application
|
2
2
|
|
3
3
|
## Installation
|
4
4
|
|
@@ -52,7 +52,7 @@ Note that `Reek::Examiner.new` can take `source` as `String`, `Pathname`, `File`
|
|
52
52
|
|
53
53
|
## Choosing your output format
|
54
54
|
|
55
|
-
Besides normal text output,
|
55
|
+
Besides normal text output, Reek can generate output in YAML,
|
56
56
|
JSON, HTML and XML by using the following Report types:
|
57
57
|
|
58
58
|
```
|
@@ -73,44 +73,25 @@ IrresponsibleModule:
|
|
73
73
|
enabled: false
|
74
74
|
```
|
75
75
|
|
76
|
+
Reek will load this file automatically by default. If you want to load the
|
77
|
+
configuration explicitely, you can use one of the methods below.
|
78
|
+
|
76
79
|
You can now use either
|
77
80
|
|
78
81
|
```Ruby
|
79
82
|
Reek::Configuration::AppConfiguration.from_path Pathname.new('config.reek')
|
80
83
|
```
|
81
84
|
|
82
|
-
but you can also pass a hash
|
83
|
-
|
84
|
-
This hash can have the following 3 keys:
|
85
|
-
|
86
|
-
1.) directory_directives [Hash] for instance:
|
87
|
-
|
88
|
-
```Ruby
|
89
|
-
{ Pathname("spec/samples/three_clean_files/") =>
|
90
|
-
{ Reek::Smells::UtilityFunction => { "enabled" => false } } }
|
91
|
-
```
|
92
|
-
|
93
|
-
2.) default_directive [Hash] for instance:
|
94
|
-
|
95
|
-
```Ruby
|
96
|
-
{ Reek::Smells::IrresponsibleModule => { "enabled" => false } }
|
97
|
-
```
|
98
|
-
|
99
|
-
3.) excluded_paths [Array] for instance:
|
85
|
+
but you can also pass a hash with the contents of the `config.reek` YAML file
|
86
|
+
to `Reek::Configuration::AppConfiguration.from_hash`.
|
100
87
|
|
101
|
-
|
102
|
-
[ Pathname('spec/samples/two_smelly_files') ]
|
103
|
-
```
|
104
|
-
|
105
|
-
Given the example above you should load that as "default directive" which means that it will
|
106
|
-
be the default configuration for smell types for which there is
|
107
|
-
no "directory directive" (so a directory-specific configuration):
|
88
|
+
Given the example above you would load that as follows:
|
108
89
|
|
109
90
|
```Ruby
|
110
91
|
require 'reek'
|
111
92
|
|
112
|
-
|
113
|
-
configuration = Reek::Configuration::AppConfiguration.
|
93
|
+
config_hash = { 'IrresponsibleModule' => { 'enabled' => false } }
|
94
|
+
configuration = Reek::Configuration::AppConfiguration.from_hash config_hash
|
114
95
|
|
115
96
|
source = <<-EOS
|
116
97
|
class Dirty
|
@@ -126,8 +107,8 @@ reporter.add_examiner examiner; nil
|
|
126
107
|
reporter.show
|
127
108
|
```
|
128
109
|
|
129
|
-
This would now only report
|
130
|
-
for the `Dirty` class:
|
110
|
+
This would now only report `UncommunicativeParameterName` but not
|
111
|
+
`IrresponsibleModule` for the `Dirty` class:
|
131
112
|
|
132
113
|
```
|
133
114
|
string -- 2 warnings:
|
@@ -135,6 +116,26 @@ string -- 2 warnings:
|
|
135
116
|
Dirty#call_me has the parameter name 'b' (UncommunicativeParameterName)
|
136
117
|
```
|
137
118
|
|
119
|
+
Instead of the smell detector names you can also use the full detector class in
|
120
|
+
your configuration hash, for example:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
config_hash = { Reek::Smells::IrresponsibleModule => { 'enabled' => false } }
|
124
|
+
```
|
125
|
+
|
126
|
+
Of course, directory specific configuration and excluded paths are supported as
|
127
|
+
well:
|
128
|
+
|
129
|
+
```
|
130
|
+
config_hash = {
|
131
|
+
'IrresponsibleModule' => { 'enabled' => false }
|
132
|
+
'spec/samples/three_clean_files/' =>
|
133
|
+
{ 'UtilityFunction' => { "enabled" => false } }
|
134
|
+
'exclude_paths' =>
|
135
|
+
[ 'spec/samples/two_smelly_files' ]
|
136
|
+
}
|
137
|
+
```
|
138
|
+
|
138
139
|
## Accessing the smell warnings directly
|
139
140
|
|
140
141
|
You can also access the smells detected by an examiner directly:
|