reek 2.1.0 → 2.2.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 +2 -21
- data/.travis.yml +1 -0
- data/.yardopts +3 -6
- data/CHANGELOG +6 -0
- data/CONTRIBUTING.md +8 -3
- data/README.md +94 -42
- data/config/defaults.reek +0 -1
- data/docs/API.md +50 -0
- data/docs/Attribute.md +43 -0
- data/docs/Basic-Smell-Options.md +44 -0
- data/docs/Boolean-Parameter.md +52 -0
- data/docs/Class-Variable.md +40 -0
- data/docs/Code-Smells.md +34 -0
- data/docs/Command-Line-Options.md +84 -0
- data/docs/Configuration-Files.md +38 -0
- data/docs/Control-Couple.md +22 -0
- data/docs/Control-Parameter.md +29 -0
- data/docs/Data-Clump.md +44 -0
- data/docs/Duplicate-Method-Call.md +49 -0
- data/docs/Feature-Envy.md +29 -0
- data/docs/How-reek-works-internally.md +44 -0
- data/docs/Irresponsible-Module.md +39 -0
- data/docs/Large-Class.md +20 -0
- data/docs/Long-Parameter-List.md +38 -0
- data/docs/Long-Yield-List.md +36 -0
- data/docs/Module-Initialize.md +62 -0
- data/docs/Nested-Iterators.md +38 -0
- data/docs/Nil-Check.md +39 -0
- data/docs/Prima-Donna-Method.md +53 -0
- data/docs/RSpec-matchers.md +133 -0
- data/docs/Rake-Task.md +58 -0
- data/docs/Reek-Driven-Development.md +45 -0
- data/docs/Repeated-Conditional.md +44 -0
- data/docs/Simulated-Polymorphism.md +16 -0
- data/docs/Smell-Suppression.md +32 -0
- data/docs/Too-Many-Instance-Variables.md +43 -0
- data/docs/Too-Many-Methods.md +55 -0
- data/docs/Too-Many-Statements.md +50 -0
- data/docs/Uncommunicative-Method-Name.md +24 -0
- data/docs/Uncommunicative-Module-Name.md +23 -0
- data/docs/Uncommunicative-Name.md +16 -0
- data/docs/Uncommunicative-Parameter-Name.md +24 -0
- data/docs/Uncommunicative-Variable-Name.md +24 -0
- data/docs/Unused-Parameters.md +27 -0
- data/docs/Utility-Function.md +46 -0
- data/docs/Versioning-Policy.md +7 -0
- data/docs/YAML-Reports.md +111 -0
- data/docs/yard_plugin.rb +14 -0
- data/features/command_line_interface/options.feature +1 -0
- data/features/programmatic_access.feature +1 -1
- data/features/samples.feature +3 -3
- data/lib/reek.rb +2 -2
- data/lib/reek/cli/input.rb +2 -2
- data/lib/reek/cli/option_interpreter.rb +2 -0
- data/lib/reek/cli/options.rb +10 -4
- data/lib/reek/cli/reek_command.rb +2 -2
- data/lib/reek/cli/report/report.rb +60 -0
- data/lib/reek/cli/silencer.rb +13 -0
- data/lib/reek/{source → core}/ast_node.rb +1 -1
- data/lib/reek/{source → core}/ast_node_class_map.rb +10 -11
- data/lib/reek/{source → core}/code_comment.rb +1 -1
- data/lib/reek/core/code_context.rb +1 -1
- data/lib/reek/core/examiner.rb +85 -0
- data/lib/reek/core/method_context.rb +1 -1
- data/lib/reek/core/module_context.rb +2 -2
- data/lib/reek/core/reference_collector.rb +31 -0
- data/lib/reek/core/singleton_method_context.rb +0 -4
- data/lib/reek/core/smell_repository.rb +4 -2
- data/lib/reek/{source → core}/tree_dresser.rb +1 -1
- data/lib/reek/{source → sexp}/sexp_extensions.rb +5 -5
- data/lib/reek/sexp/sexp_formatter.rb +29 -0
- data/lib/reek/sexp/sexp_node.rb +91 -0
- data/lib/reek/smells.rb +4 -2
- data/lib/reek/smells/attribute.rb +35 -7
- data/lib/reek/smells/boolean_parameter.rb +1 -1
- data/lib/reek/smells/class_variable.rb +1 -1
- data/lib/reek/smells/control_parameter.rb +1 -1
- data/lib/reek/smells/data_clump.rb +1 -1
- data/lib/reek/smells/duplicate_method_call.rb +12 -4
- data/lib/reek/smells/feature_envy.rb +1 -1
- data/lib/reek/smells/irresponsible_module.rb +3 -3
- data/lib/reek/smells/long_parameter_list.rb +1 -1
- data/lib/reek/smells/long_yield_list.rb +1 -1
- data/lib/reek/smells/module_initialize.rb +1 -1
- data/lib/reek/smells/nested_iterators.rb +1 -1
- data/lib/reek/smells/nil_check.rb +3 -2
- data/lib/reek/smells/prima_donna_method.rb +18 -11
- data/lib/reek/smells/repeated_conditional.rb +3 -3
- data/lib/reek/smells/smell_detector.rb +5 -1
- data/lib/reek/smells/smell_warning.rb +99 -0
- data/lib/reek/smells/too_many_instance_variables.rb +1 -1
- data/lib/reek/smells/too_many_methods.rb +1 -1
- data/lib/reek/smells/too_many_statements.rb +1 -1
- data/lib/reek/smells/uncommunicative_method_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_module_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_parameter_name.rb +1 -1
- data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
- data/lib/reek/smells/unused_parameters.rb +1 -1
- data/lib/reek/smells/utility_function.rb +3 -16
- data/lib/reek/source/source_code.rb +31 -13
- data/lib/reek/source/source_locator.rb +16 -17
- data/lib/reek/source/source_repository.rb +10 -11
- data/lib/reek/spec/should_reek.rb +2 -2
- data/lib/reek/spec/should_reek_of.rb +2 -2
- data/lib/reek/spec/should_reek_only_of.rb +2 -2
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +3 -4
- data/spec/factories/factories.rb +1 -1
- data/spec/gem/yard_spec.rb +1 -1
- data/spec/quality/reek_source_spec.rb +2 -2
- data/spec/reek/cli/html_report_spec.rb +3 -3
- data/spec/reek/cli/json_report_spec.rb +3 -3
- data/spec/reek/cli/{option_interperter_spec.rb → option_interpreter_spec.rb} +1 -1
- data/spec/reek/cli/options_spec.rb +19 -0
- data/spec/reek/cli/text_report_spec.rb +7 -7
- data/spec/reek/cli/xml_report_spec.rb +34 -0
- data/spec/reek/cli/yaml_report_spec.rb +3 -3
- data/spec/reek/configuration/app_configuration_spec.rb +1 -1
- data/spec/reek/configuration/configuration_file_finder_spec.rb +22 -1
- data/spec/reek/{source → core}/code_comment_spec.rb +14 -14
- data/spec/reek/core/code_context_spec.rb +1 -1
- data/spec/reek/{examiner_spec.rb → core/examiner_spec.rb} +12 -12
- data/spec/reek/core/method_context_spec.rb +27 -22
- data/spec/reek/core/module_context_spec.rb +2 -2
- data/spec/reek/core/object_refs_spec.rb +1 -1
- data/spec/reek/{source → core}/object_source_spec.rb +1 -1
- data/spec/reek/{source → core}/reference_collector_spec.rb +25 -16
- data/spec/reek/core/singleton_method_context_spec.rb +12 -2
- data/spec/reek/core/smell_configuration_spec.rb +1 -1
- data/spec/reek/core/smell_repository_spec.rb +12 -1
- data/spec/reek/core/stop_context_spec.rb +1 -1
- data/spec/reek/core/tree_dresser_spec.rb +16 -0
- data/spec/reek/core/tree_walker_spec.rb +3 -3
- data/spec/reek/core/warning_collector_spec.rb +6 -6
- data/spec/reek/{source → sexp}/sexp_extensions_spec.rb +8 -8
- data/spec/reek/{source → sexp}/sexp_formatter_spec.rb +11 -5
- data/spec/reek/{source → sexp}/sexp_node_spec.rb +3 -3
- data/spec/reek/smells/attribute_spec.rb +89 -85
- data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
- data/spec/reek/smells/boolean_parameter_spec.rb +1 -1
- data/spec/reek/smells/class_variable_spec.rb +1 -1
- data/spec/reek/smells/control_parameter_spec.rb +1 -1
- data/spec/reek/smells/data_clump_spec.rb +2 -2
- data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
- data/spec/reek/smells/feature_envy_spec.rb +2 -2
- data/spec/reek/smells/irresponsible_module_spec.rb +1 -1
- data/spec/reek/smells/long_parameter_list_spec.rb +2 -2
- data/spec/reek/smells/long_yield_list_spec.rb +1 -1
- data/spec/reek/smells/module_initialize_spec.rb +1 -1
- data/spec/reek/smells/nested_iterators_spec.rb +2 -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 -1
- data/spec/reek/smells/smell_detector_shared.rb +2 -2
- data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -7
- data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
- data/spec/reek/smells/too_many_methods_spec.rb +1 -1
- data/spec/reek/smells/too_many_statements_spec.rb +4 -4
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +1 -1
- data/spec/reek/smells/unused_parameters_spec.rb +1 -1
- data/spec/reek/smells/utility_function_spec.rb +1 -1
- data/spec/reek/source/source_code_spec.rb +1 -1
- data/spec/reek/spec/should_reek_of_spec.rb +1 -1
- data/spec/reek/spec/should_reek_only_of_spec.rb +1 -1
- data/spec/reek/spec/should_reek_spec.rb +1 -1
- data/spec/samples/checkstyle.xml +2 -0
- data/spec/spec_helper.rb +15 -3
- metadata +68 -38
- data/.ruby-gemset +0 -1
- data/lib/reek/examiner.rb +0 -79
- data/lib/reek/smell_warning.rb +0 -87
- data/lib/reek/source/reference_collector.rb +0 -27
- data/lib/reek/source/sexp_formatter.rb +0 -22
- data/lib/reek/source/sexp_node.rb +0 -79
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afd9361841a4f7ae194b659bbc70c06e4bef20f2
|
4
|
+
data.tar.gz: 52e321f176aca45a3c424aff60749ad3bc11f695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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
data/.yardopts
CHANGED
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
|
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
|
-
|
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
|
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
|
-
#
|
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.
|
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
|
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
|
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
|
-
|
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
|
73
|
+
is the exact same thing as being explicit:
|
72
74
|
|
73
75
|
```Bash
|
74
76
|
reek .
|
75
77
|
```
|
76
78
|
|
77
|
-
Additionally can
|
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
|
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
|
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](
|
119
|
+
For a summary of those CLI options see [Command-Line Options](docs/Command-Line-Options.md).
|
107
120
|
|
108
|
-
### Configuration
|
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
|
127
|
+
There are three ways of passing `reek` a configuration file:
|
115
128
|
|
116
|
-
1. Using the
|
117
|
-
2. Having a file ending with
|
118
|
-
3. Having a file ending with
|
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
|
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
|
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
|
127
|
-
|
128
|
-
|
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
|
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 [
|
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
|
172
|
-
* Add `reek`'s custom matcher to your [RSpec examples](
|
173
|
-
* Include `reek` using the [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
|
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
|
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
|
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
|
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
|
-
*
|
203
|
-
*
|
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
|
243
|
+
`reek` supports 5 output formats:
|
208
244
|
|
209
245
|
* plain text (default)
|
210
|
-
*
|
211
|
-
*
|
212
|
-
*
|
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
|
-
###
|
276
|
+
### More information
|
225
277
|
|
226
278
|
* [Stack Overflow](https://stackoverflow.com/questions/tagged/reek)
|
227
|
-
* [
|
279
|
+
* [RubyDoc.info](http://www.rubydoc.info/gems/reek)
|
228
280
|
|
229
281
|
## Contributors
|
230
282
|
|
231
|
-
A non
|
283
|
+
A non-exhaustive list:
|
232
284
|
|
233
285
|
* Kevin Rutherford
|
234
286
|
* Matijs van Zuijlen
|
data/config/defaults.reek
CHANGED
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
|
+
```
|