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
data/docs/Attribute.md
CHANGED
data/docs/Basic-Smell-Options.md
CHANGED
@@ -9,7 +9,8 @@ Every smell detector in Reek offers at least the following configuration options
|
|
9
9
|
| `enabled` | Boolean | Determines whether the smell detector is active. Defaults to `true` |
|
10
10
|
| `exclude` | an array of strings or regular expressions | Ignores any context whose full description (see <strong>%c</strong> in [Command-Line Options](Command-Line-Options.md)) matches any element of this array. |
|
11
11
|
|
12
|
-
The file `
|
12
|
+
The file `defaults.reek` (shipped with the Reek gem) lists any default
|
13
|
+
exclusions for each smell.
|
13
14
|
|
14
15
|
## Examples
|
15
16
|
|
data/docs/Boolean-Parameter.md
CHANGED
data/docs/Class-Variable.md
CHANGED
@@ -16,10 +16,10 @@ class Dummy
|
|
16
16
|
end
|
17
17
|
```
|
18
18
|
|
19
|
-
|
19
|
+
Reek would emit the following warning:
|
20
20
|
|
21
21
|
```
|
22
|
-
reek test.rb
|
22
|
+
reek test.rb
|
23
23
|
|
24
24
|
test.rb -- 1 warning:
|
25
25
|
[2]:Dummy declares the class variable @@class_variable (ClassVariable)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Introduction
|
4
4
|
|
5
|
-
reek follows standard Unix convention for passing arguments.
|
5
|
+
`reek` follows standard Unix convention for passing arguments.
|
6
6
|
|
7
7
|
Check out
|
8
8
|
|
@@ -74,7 +74,7 @@ This mode can be enabled via the "-U" or "--ultra-verbose" flag.
|
|
74
74
|
So for instance, if your test file would smell of _ClassVariable_, this is what the _reek_ output would look like:
|
75
75
|
|
76
76
|
```Bash
|
77
|
-
reek -U test.rb
|
77
|
+
reek -U test.rb
|
78
78
|
```
|
79
79
|
```
|
80
80
|
test.rb -- 1 warning:
|
data/docs/Control-Couple.md
CHANGED
@@ -10,13 +10,13 @@ Control Coupling reduces the code's flexibility by creating a dependency between
|
|
10
10
|
|
11
11
|
You can find a good write-up regarding this problem [here](http://solnic.eu/2012/04/11/get-rid-of-that-code-smell-control-couple.html).
|
12
12
|
|
13
|
-
## Current Support in
|
13
|
+
## Current Support in Reek
|
14
14
|
|
15
|
-
|
15
|
+
Reek warns about control coupling when:
|
16
16
|
|
17
17
|
* [Control-Parameter](Control-Parameter.md) - a method parameter or block parameter is the tested value in a conditional statement (as in the example below); or
|
18
18
|
* [Boolean-Parameter](Boolean-Parameter.md) - a method parameter is defaulted to `true` or `false`.
|
19
19
|
|
20
20
|
## Configuration
|
21
21
|
|
22
|
-
Control Couple supports the [Basic Smell Options](Basic-Smell-Options.md).
|
22
|
+
Control Couple supports the [Basic Smell Options](Basic-Smell-Options.md).
|
data/docs/Control-Parameter.md
CHANGED
@@ -20,9 +20,9 @@ end
|
|
20
20
|
|
21
21
|
Fixing those problems is out of the scope of this document but an easy solution could be to remove the "write" method alltogether and to move the calls to "write_quoted" / "write_unquoted" in the initial caller of "write".
|
22
22
|
|
23
|
-
## Current Support in
|
23
|
+
## Current Support in Reek
|
24
24
|
|
25
|
-
|
25
|
+
Reek warns about control coupling when a method parameter or block parameter is the tested value in a conditional statement.
|
26
26
|
|
27
27
|
## Configuration
|
28
28
|
|
data/docs/Data-Clump.md
CHANGED
@@ -18,7 +18,7 @@ class Dummy
|
|
18
18
|
end
|
19
19
|
```
|
20
20
|
|
21
|
-
|
21
|
+
Reek would emit the following warning:
|
22
22
|
|
23
23
|
```
|
24
24
|
test.rb -- 1 warning:
|
@@ -31,7 +31,7 @@ A possible way to fix this problem (quoting from [Martin Fowler](http://martinfo
|
|
31
31
|
|
32
32
|
## Current Support in Reek
|
33
33
|
|
34
|
-
|
34
|
+
Reek looks for a group of two or more parameters with the same names that are expected by three or more methods of a class.
|
35
35
|
|
36
36
|
## Configuration
|
37
37
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
## Introduction
|
4
4
|
|
5
5
|
Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.
|
6
|
-
|
6
|
+
Reek implements a check for _Duplicate Method Call_.
|
7
7
|
|
8
8
|
## Example
|
9
9
|
|
@@ -36,9 +36,9 @@ end
|
|
36
36
|
|
37
37
|
The approach you take will depend on balancing other factors in your code.
|
38
38
|
|
39
|
-
## Current support in
|
39
|
+
## Current support in Reek
|
40
40
|
|
41
|
-
|
41
|
+
Reek's Duplicate Method Call detector checks for repeated identical method calls within any one method definition. This is intended to complement the checks performed by tools such as [Flay](http://ruby.sadi.st/Flay.html) and [Simian](http://www.redhillconsulting.com.au/products/simian/).
|
42
42
|
|
43
43
|
## Configuration
|
44
44
|
|
@@ -46,4 +46,4 @@ Reek's Duplication detector currently offers the [Basic Smell Options](Basic-Sme
|
|
46
46
|
|
47
47
|
Option | Value | Effect
|
48
48
|
-------|-------|-------
|
49
|
-
`max_calls` | integer | The maximum number of duplicate calls allowed within a method. Defaults to 1.
|
49
|
+
`max_calls` | integer | The maximum number of duplicate calls allowed within a method. Defaults to 1.
|
data/docs/Feature-Envy.md
CHANGED
@@ -12,7 +12,7 @@ _Feature Envy_ often arises because it must manipulate other objects (usually it
|
|
12
12
|
|
13
13
|
## Example
|
14
14
|
|
15
|
-
Running
|
15
|
+
Running Reek on:
|
16
16
|
|
17
17
|
```Ruby
|
18
18
|
class Warehouse
|
@@ -36,7 +36,7 @@ since this:
|
|
36
36
|
|
37
37
|
belongs to the Item class, not the Warehouse.
|
38
38
|
|
39
|
-
## Current Support in
|
39
|
+
## Current Support in Reek
|
40
40
|
|
41
41
|
_Feature Envy_ reports any method that refers to self less often than it refers to (ie. send messages to) some other object.
|
42
42
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# How
|
1
|
+
# How Reek works internally
|
2
2
|
|
3
3
|
|
4
4
|
## The big picture
|
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
## A closer look at how an Examiner works
|
60
60
|
|
61
|
-
The core foundation of
|
61
|
+
The core foundation of Reek and its API is the Examiner.
|
62
62
|
As you can see above, the Examiner is run for every source it gets passed and then runs the configured SmellDetectors.
|
63
63
|
The overall workflow is like this:
|
64
64
|
|
@@ -14,7 +14,7 @@ class Dummy
|
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
-
|
17
|
+
Reek would emit the following warning:
|
18
18
|
|
19
19
|
```
|
20
20
|
test.rb -- 1 warning:
|
@@ -30,7 +30,7 @@ class Dummy
|
|
30
30
|
end
|
31
31
|
```
|
32
32
|
|
33
|
-
## Current Support in
|
33
|
+
## Current Support in Reek
|
34
34
|
|
35
35
|
`Irresponsible Module` currently checks classes, but not modules.
|
36
36
|
|
data/docs/Large-Class.md
CHANGED
@@ -10,11 +10,11 @@ A `Large Class` is a class or module that has a large number of instance variabl
|
|
10
10
|
|
11
11
|
## Configuration
|
12
12
|
|
13
|
-
|
13
|
+
Reek's Large Class detector supports the [Basic Smell Options](Basic-Smell-Options.md), plus:
|
14
14
|
|
15
15
|
| Option | Value | Effect |
|
16
16
|
| ---------------|-------------|---------|
|
17
17
|
| max_methods | integer | The maximum number of methods allowed in a class before a warning is issued. Defaults to 25. |
|
18
18
|
| max_instance_variables | integer | The maximum number of instance variables allowed in a class before a warning is issued. Defaults to 9. |
|
19
19
|
|
20
|
-
The `Large Class` detector is enabled whenever
|
20
|
+
The `Large Class` detector is enabled whenever Reek is asked to check an instance of `Class` or `Module`.
|
data/docs/Long-Parameter-List.md
CHANGED
data/docs/Long-Yield-List.md
CHANGED
@@ -14,7 +14,7 @@ class Dummy
|
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
-
|
17
|
+
Reek would report the following warning:
|
18
18
|
|
19
19
|
```
|
20
20
|
test.rb -- 1 warning:
|
@@ -33,4 +33,4 @@ Reek's Long Parameter List detector supports the [Basic Smell Options](Basic-Sme
|
|
33
33
|
|
34
34
|
| Option | Value | Effect |
|
35
35
|
| ---------------|-------------|---------|
|
36
|
-
| max_params | integer | The maximum number of parameters allowed in a method or block before a warning is issued. Defaults to 3. |
|
36
|
+
| max_params | integer | The maximum number of parameters allowed in a method or block before a warning is issued. Defaults to 3. |
|
data/docs/Module-Initialize.md
CHANGED
@@ -53,10 +53,10 @@ class B < A
|
|
53
53
|
end
|
54
54
|
```
|
55
55
|
|
56
|
-
## Current Support in
|
56
|
+
## Current Support in Reek
|
57
57
|
|
58
|
-
|
58
|
+
Reek warns about module initialize when an instance method named `initialize` is present in a module.
|
59
59
|
|
60
60
|
## Configuration
|
61
61
|
|
62
|
-
Module Initialize supports the [Basic Smell Options](Basic-Smell-Options.md).
|
62
|
+
Module Initialize supports the [Basic Smell Options](Basic-Smell-Options.md).
|
data/docs/Nested-Iterators.md
CHANGED
data/docs/Nil-Check.md
CHANGED
@@ -19,7 +19,7 @@ class Klass
|
|
19
19
|
end
|
20
20
|
```
|
21
21
|
|
22
|
-
|
22
|
+
Reek would emit the following warning:
|
23
23
|
|
24
24
|
```
|
25
25
|
test.rb -- 1 warning:
|
@@ -36,4 +36,4 @@ test.rb -- 1 warning:
|
|
36
36
|
|
37
37
|
## Configuration
|
38
38
|
|
39
|
-
`Nil Check` offers the [Basic Smell Options](Basic-Smell-Options.md).
|
39
|
+
`Nil Check` offers the [Basic Smell Options](Basic-Smell-Options.md).
|
data/docs/Prima-Donna-Method.md
CHANGED
@@ -24,9 +24,9 @@ class C
|
|
24
24
|
end
|
25
25
|
```
|
26
26
|
|
27
|
-
|
27
|
+
Reek would report `bar!` as `prima donna method` smell but not `foo!`.
|
28
28
|
|
29
|
-
|
29
|
+
Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:
|
30
30
|
|
31
31
|
|
32
32
|
```Ruby
|
@@ -46,8 +46,8 @@ class Daughter < Parent
|
|
46
46
|
end
|
47
47
|
```
|
48
48
|
|
49
|
-
In this example,
|
49
|
+
In this example, Reek would not report the `prima donna method` smell for the method `foo` of the `Dangerous` module.
|
50
50
|
|
51
51
|
## Configuration
|
52
52
|
|
53
|
-
`Prima Donna Method` offers the [Basic Smell Options](Basic-Smell-Options.md).
|
53
|
+
`Prima Donna Method` offers the [Basic Smell Options](Basic-Smell-Options.md).
|
data/docs/RSpec-matchers.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Introduction
|
4
4
|
|
5
|
-
|
5
|
+
Reek offers matchers for RSpec you can easily include into your project.
|
6
6
|
|
7
7
|
There are 3 matchers available:
|
8
8
|
|
@@ -27,7 +27,7 @@ require 'reek/spec'
|
|
27
27
|
require 'rspec'
|
28
28
|
|
29
29
|
RSpec.describe 'Reek Integration' do
|
30
|
-
it 'works with
|
30
|
+
it 'works with Reek' do
|
31
31
|
smelly_class = 'class C; def m; end; end'
|
32
32
|
expect(smelly_class).not_to reek
|
33
33
|
end
|
@@ -45,7 +45,7 @@ would give you:
|
|
45
45
|
```
|
46
46
|
Failures:
|
47
47
|
|
48
|
-
1) Reek Integration works with
|
48
|
+
1) Reek Integration works with Reek
|
49
49
|
Failure/Error: expect(smelly_class).not_to reek
|
50
50
|
Expected no smells, but got:
|
51
51
|
C has no descriptive comment (IrresponsibleModule)
|
@@ -58,7 +58,7 @@ Finished in 0.00284 seconds (files took 0.28815 seconds to load)
|
|
58
58
|
|
59
59
|
Failed examples:
|
60
60
|
|
61
|
-
rspec ./reek-integration-spec.rb:6 # Reek Integration works with
|
61
|
+
rspec ./reek-integration-spec.rb:6 # Reek Integration works with Reek
|
62
62
|
```
|
63
63
|
|
64
64
|
## The matchers explained
|
@@ -76,7 +76,7 @@ and returns true only if it can find one of them that matches.
|
|
76
76
|
|
77
77
|
Remember that this includes our "smell types" as well. So it could be the
|
78
78
|
"smell type" UtilityFunction, which is represented as a concrete class
|
79
|
-
in
|
79
|
+
in Reek but it could also be "Duplication" which is a "smell categgory".
|
80
80
|
|
81
81
|
In theory you could pass many different types of input here:
|
82
82
|
- `:UtilityFunction`
|
@@ -95,7 +95,7 @@ check for as well e.g. "name" or "count" (see the examples below). The
|
|
95
95
|
parameters you can check for are depending on the smell you are checking for.
|
96
96
|
For instance "count" doesn't make sense everywhere whereas "name" does in most
|
97
97
|
cases. If you pass in a parameter that doesn't exist (e.g. you make a typo like
|
98
|
-
"namme")
|
98
|
+
"namme") Reek will raise an ArgumentError to give you a hint that you passed
|
99
99
|
something that doesn't make much sense.
|
100
100
|
|
101
101
|
So in a nutshell `reek_of` takes the following two arguments:
|
@@ -129,7 +129,7 @@ With smell_details:
|
|
129
129
|
|
130
130
|
See the documentaton for `reek_of`.
|
131
131
|
|
132
|
-
**Notable differences to reek_of
|
132
|
+
**Notable differences to `reek_of`:**
|
133
133
|
|
134
134
|
1. `reek_of` doesn't mind if there are other smells of a different category.
|
135
135
|
"reek_only_of" will fail in that case.
|
data/docs/Rake-Task.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Introduction
|
4
4
|
|
5
|
-
|
5
|
+
Reek provides a Rake task that runs Reek on a set of source files. In its most simple form you just include something like that in your Rakefile:
|
6
6
|
|
7
7
|
```Ruby
|
8
8
|
require 'reek/rake/task'
|
@@ -55,4 +55,4 @@ An example rake call using environment variables could look like this:
|
|
55
55
|
REEK_CFG="config/custom.reek" REEK_OPTS="-s" rake reek
|
56
56
|
```
|
57
57
|
|
58
|
-
See also: [Reek-Driven-Development](Reek-Driven-Development.md)
|
58
|
+
See also: [Reek-Driven-Development](Reek-Driven-Development.md)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## rake
|
4
4
|
|
5
|
-
One way to drive quality into your code from the very beginning of a project is to run
|
5
|
+
One way to drive quality into your code from the very beginning of a project is to run Reek as a part of your testing process. For example, you could do that by adding a [Rake Task](Rake-Task.md) to your rakefile, which will make it easy to run Reek on all your source files whenever you need to.
|
6
6
|
|
7
7
|
```Ruby
|
8
8
|
require 'reek/rake/task'
|
@@ -14,11 +14,11 @@ Reek::Rake::Task.new do |t|
|
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
-
Now the command `reek` will run
|
17
|
+
Now the command `reek` will run Reek on your source code (and in this case, it fails if it finds any smells). For more detailed information about Reek's integration with Rake, see [Rake Task](Rake-Task.md) in this wiki.
|
18
18
|
|
19
19
|
## reek/spec
|
20
20
|
|
21
|
-
But there's another way; a much more effective "Reek-driven" approach: add
|
21
|
+
But there's another way; a much more effective "Reek-driven" approach: add Reek expectations directly into your Rspec specs. Here's an example taken directly from Reek's own source code:
|
22
22
|
|
23
23
|
```Ruby
|
24
24
|
it 'contains no code smells' do
|
@@ -26,7 +26,7 @@ it 'contains no code smells' do
|
|
26
26
|
end
|
27
27
|
```
|
28
28
|
|
29
|
-
By requiring "reek/spec":http://reek.rubyforge.org/rdoc/classes/Reek/Spec.html you gain access to the `reek` matcher, which returns true if and only if
|
29
|
+
By requiring "reek/spec":http://reek.rubyforge.org/rdoc/classes/Reek/Spec.html you gain access to the `reek` matcher, which returns true if and only if Reek finds smells in your code. And if the test fails, the matcher produces an error message that includes details of all the smells it found.
|
30
30
|
|
31
31
|
## assert
|
32
32
|
|
@@ -26,7 +26,7 @@ class RepeatedConditionals
|
|
26
26
|
end
|
27
27
|
```
|
28
28
|
|
29
|
-
|
29
|
+
Reek would emit the following warning:
|
30
30
|
|
31
31
|
```
|
32
32
|
test.rb -- 4 warnings:
|
@@ -37,7 +37,7 @@ If you get this warning then you are probably not using the right abstraction or
|
|
37
37
|
|
38
38
|
## Configuration
|
39
39
|
|
40
|
-
|
40
|
+
Reek's `Repeated Conditional` detector offers the [Basic Smell Options](Basic-Smell-Options.md), plus:
|
41
41
|
|
42
42
|
| Option | Value | Effect |
|
43
43
|
| ---------------|-------------|---------|
|
@@ -11,6 +11,6 @@ Simulated Polymorphism occurs when
|
|
11
11
|
|
12
12
|
Conditional code is hard to read and understand, because the reader must hold more state in his head. When the same value is tested in multiple places throughout an application, any change to the set of possible values will require many methods and classes to change. Tests for the type of an object may indicate that the abstraction represented by that type is not completely defined (or understood).
|
13
13
|
|
14
|
-
## Current Support in
|
14
|
+
## Current Support in Reek
|
15
15
|
|
16
|
-
|
16
|
+
Reek checks for [Repeated Conditional](Repeated-Conditional.md) and for [Nil Check](Nil-Check.md).
|
data/docs/Smell-Suppression.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
## Introduction
|
2
2
|
|
3
|
-
In some cases, it might be necessary to suppress one or more of
|
3
|
+
In some cases, it might be necessary to suppress one or more of Reek's smell
|
4
4
|
warnings for a particular method or class.
|
5
5
|
|
6
6
|
Possible reasons for this could be:
|
7
7
|
|
8
8
|
* The code is outside of your control and you can't fix it
|
9
|
-
*
|
9
|
+
* Reek is not the police. You might have legit reasons why your source code
|
10
10
|
is good as it is.
|
11
11
|
|
12
12
|
## How to disable smell detection
|
@@ -93,4 +93,4 @@ end
|
|
93
93
|
```
|
94
94
|
|
95
95
|
To see what smell detector takes what special configuration just check out the
|
96
|
-
dedicated documentation for this smell detector.
|
96
|
+
dedicated documentation for this smell detector.
|