Skip to content

Commit

Permalink
Fix our documentation until we release Reek 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
troessner committed Jun 10, 2018
1 parent ebbd23b commit 0d65c1f
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 49 deletions.
53 changes: 23 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ demo.rb -- 2 warnings:

Reek is officially supported for the following CRuby versions:

- 2.2 (EOL)
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
Expand Down Expand Up @@ -252,13 +253,12 @@ For a summary of those CLI options see [Command-Line Options](docs/Command-Line-
#### Configuration loading

Configuring Reek via a configuration file is by far the most powerful way.
Reek expects this filename to be `.reek.yml` but you can override this via the CLI `-c` switch (see below).

There are three ways of passing Reek the configuration file:
There are three ways of passing Reek a configuration file:

1. Using the CLI `-c` switch (see [_Command-line interface_](#command-line-interface) above)
2. Having the configuration file either in your current working directory or in a parent directory (more on that later)
3. Having the configuration file in your home directory
2. Having a file ending with `.reek` either in your current working directory or in a parent directory (more on that later)
3. Having a file ending with `.reek` in your home directory

The order in which Reek tries to find such a configuration
file is exactly the above: first it checks if we have given
Expand All @@ -276,7 +276,7 @@ of how many `*.reek` files you might have on your filesystem.

We put a lot of effort into making Reek's configuration as self explanatory as possible so the
best way to understand it is by looking at a simple
example (e.g. `.reek.yml` in your project directory):
example (e.g. `config.reek` in your project directory):

```yaml
---
Expand All @@ -297,7 +297,7 @@ NestedIterators:

# A lot of smells allow fine tuning their configuration. You can look up all available options
# in the corresponding smell documentation in /docs. In most cases you probably can just go
# with the defaults as documented in defaults.reek.yml.
# with the defaults as documented in defaults.reek.
DataClump:
max_copies: 3
min_clump_size: 3
Expand All @@ -308,21 +308,12 @@ DataClump:
# E.g. the classic Rails case: controllers smell of NestedIterators (see /docs/Nested-Iterators.md) and
# helpers smell of UtilityFunction (see docs/Utility-Function.md)
# Note that we only allow configuration on a directory level, not a file level, so all paths have to point to directories.
directories:
"web_app/app/controllers":
NestedIterators:
enabled: false
"web_app/app/helpers":
UtilityFunction:
enabled: false
# In case you're still running Reek 4 you have to omit the "directories" key and place the directory directives on top
# level like this:
# "web_app/app/controllers":
# NestedIterators:
# enabled: false
# "web_app/app/helpers":
# UtilityFunction:
# enabled: false
"web_app/app/controllers":
NestedIterators:
enabled: false
"web_app/app/helpers":
UtilityFunction:
enabled: false

### Excluding directories

Expand All @@ -345,11 +336,9 @@ IrresponsibleModule:
TooManyStatements:
max_statements: 5

# In case you're still running Reek 4 you have to omit the "directories" key, see the example config above.
directories:
"app/controllers":
TooManyStatements:
max_statements: 10
"app/controllers":
TooManyStatements:
max_statements: 10
```
translates to:
Expand All @@ -364,10 +353,10 @@ types offer a configuration that goes beyond that of the basic smell options, fo
[Data Clump](docs/Data-Clump.md).
All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md)
are documented in the corresponding smell type /docs page (if you want to get a quick overview over all possible
configurations you can also check out [the `default.reek.yml` file in this repository](defaults.reek.yml).
configurations you can also check out [the `default.reek` file in this repository](defaults.reek).

Note that you do not need a configuration file at all.
If you're fine with all the [defaults](defaults.reek.yml) we set you can skip this completely.
If you're fine with all the [defaults](defaults.reek) we set you can skip this completely.

### Generating a 'todo' list

Expand Down Expand Up @@ -417,7 +406,11 @@ is supposed to have one configuration file and one file only).

### Beware of multiple configuration files

Reek takes one configuration file and one configuration file only with `.reek.yml` being the default name.
Reek takes one configuration file and one configuration file only.

If you have more than one configuration file in the same directory Reek
will not know what configuration file to use. If this happens Reek will
print a warning on STDERR and exit with the failure exit status 1.

In case you have to have one or more configuration files in the directory (e.g. you're
toying around with different, mutually exclusive settings) you need to tell Reek
Expand Down
11 changes: 9 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ XMLReport

## Configuration

Given you have the following configuration file called `.reek.yml` in your root directory:
Given you have the following configuration file called `config.reek` in your root directory:

```Yaml
---
Expand All @@ -106,7 +106,7 @@ You can now use either
Reek::Configuration::AppConfiguration.from_path Pathname.new('config.reek')
```

but you can also pass a hash with the contents of the `.reek.yml` YAML file
but you can also pass a hash with the contents of the `config.reek` YAML file
to `Reek::Configuration::AppConfiguration.from_hash`.

Given the example above you would load that as follows:
Expand Down Expand Up @@ -140,6 +140,13 @@ string -- 2 warnings:
Dirty#call_me has the parameter name 'b' (UncommunicativeParameterName)
```

Instead of the smell detector names you can also use the full detector class in
your configuration hash, for example:

```ruby
config_hash = { Reek::SmellDetectors::IrresponsibleModule => { 'enabled' => false } }
```

Of course, directory specific configuration and excluded paths are supported as
well:

Expand Down
2 changes: 1 addition & 1 deletion docs/Basic-Smell-Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Every smell detector in Reek offers at least the following configuration options
| `enabled` | Boolean | Determines whether the smell detector is active. Defaults to `true` |
| `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. |

The file `defaults.reek.yml` (shipped with the Reek gem) lists any default
The file `defaults.reek` (shipped with the Reek gem) lists any default
exclusions for each smell.

## Examples
Expand Down
2 changes: 1 addition & 1 deletion docs/Code-Smells.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Reek currently includes checks for the following smells:
* Low Cohesion, including
* [Feature Envy](Feature-Envy.md)
* [Utility Function](Utility-Function.md)
* [Missing Safe Method](Missing-Safe-Method.md), formerly known as Prima Donna Method
* [Module Initialize](Module-Initialize.md)
* [Nested Iterators](Nested-Iterators.md)
* [Prima-Donna-Method](Prima-Donna-Method.md)
* [Simulated Polymorphism](Simulated-Polymorphism.md), including
* [Manual Dispatch](Manual-Dispatch.md)
* [Nil Check](Nil-Check.md)
Expand Down
4 changes: 2 additions & 2 deletions docs/How-To-Write-New-Detectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ end

For your detector to be properly loaded you need to require it in `lib/reek/smell_detectors.rb` as well.

### defaults.reek.yml
### defaults.reek

After you ran

```
bundle exec rake
```

for the first time with your shiny new detector in place the `defaults.reek.yml`
for the first time with your shiny new detector in place the `defaults.reek`
file should have been updated automatically. Make sure you don't forget to check
in those changes as well.

Expand Down
22 changes: 10 additions & 12 deletions docs/Missing-Safe-Method.md → docs/Prima-Donna-Method.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Missing Safe Method
# Prima Donna Method

## Introduction

Candidate methods for the _Missing Safe Method_ smell are methods whose names
end with an exclamation mark.
Candidate methods for the _Prima Donna Method_ smell are methods whose names
end with an exclamation mark (note that this smell will soon be renamed to "Missing Safe Method" in Reek 5).

An exclamation mark in method names means (the explanation below is taken from
[here](http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist)):
Expand All @@ -13,16 +13,14 @@ An exclamation mark in method names means (the explanation below is taken from
> equivalent method, with the same name minus the !. “Danger” is relative; the
> ! doesn’t mean anything at all unless the method name it’s in corresponds to
> a similar but bang-less method name.
>
>
> So, for example, gsub! is the dangerous version of gsub. exit! is the
> dangerous version of exit. flatten! is the dangerous version of flatten. And
> so forth.
Such a method is called _Missing Safe Method_ if and only if the non-bang
Such a method is called _Prima Donna Method_ if and only if her non-bang
version does not exist and this method is reported as a smell.

Missing Safe Method was formerly known as Prima Donna Method.

## Example

Given
Expand All @@ -35,7 +33,7 @@ class C
end
```

Reek would report the _Missing Safe Method_ smell for `bar!`, but not for `foo!`.
Reek would report the _Prima Donna Method_ smell for `bar!`, but not for `foo!`.

Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

Expand All @@ -57,12 +55,12 @@ class Daughter < Parent
end
```

In this example, Reek would not report the _Missing Safe Method_ smell for the
In this example, Reek would not report the _Prima Donna Method_ smell for the
method `foo` of the `Dangerous` module.

## Configuration

_Missing Safe Method_ offers the [Basic Smell Options](Basic-Smell-Options.md).
_Prima Donna Method_ offers the [Basic Smell Options](Basic-Smell-Options.md).

## Example configuration via source comment

Expand All @@ -79,12 +77,12 @@ This would report:

>>
ruby.rb -- 1 warning:
[1]:MissingSafeMethod: Alfa has missing safe method 'bravo!'
[1]:PrimaDonnaMethod: Alfa has prima donna method 'bravo!'

If you want to suppress this warning you can do this via source comment like this:

```Ruby
# :reek:MissingSafeMethod { exclude: [ bravo! ] }
# :reek:PrimaDonnaMethod { exclude: [ bravo! ] }
class Alfa
def bravo!
end
Expand Down
2 changes: 1 addition & 1 deletion docs/Rake-Task.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ An more sophisticated rake task that would make use of all available configurati
```Ruby
Reek::Rake::Task.new do |t|
t.name = 'custom_rake' # Whatever name you want. Defaults to "reek".
t.config_file = 'config/.reek.yml' # Defaults to nothing.
t.config_file = 'config/config.reek' # Defaults to nothing.
t.source_files = 'vendor/**/*.rb' # Glob pattern to match source files. Defaults to lib/**/*.rb
t.reek_opts = '-U' # Defaults to ''. You can pass all the options here in that are shown by "reek -h"
t.fail_on_error = false # Defaults to true
Expand Down

0 comments on commit 0d65c1f

Please sign in to comment.