Configuration loading

Having a file ending with .reek either in your current working directory or in a parent directory (more on that later)

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
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; lastly, it checks your home directory.

As soon as Reek detects a configuration file it stops searching
immediately, meaning that from Reek's point of view there exists
exactly one configuration file and one configuration, regardless
of how many *.reek files you might have on your filesystem.

Configuration options

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. config.reek in your project directory):

---
### Generic smell configuration# You can disable smells completelyIrresponsibleModule:enabled:false# You can use filters to silence Reek warnings.# Either because you simply disagree with Reek (we are not the police) or# because you want to fix this at a later point in time.NestedIterators:exclude:
- "MyWorker#self.class_method"# should be refactored
- "AnotherWorker#instance_method"# should be refactored as well# 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.DataClump:max_copies:3min_clump_size:3### Directory specific configuration# You can configure smells on a per-directory base.# 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)"web_app/app/controllers":
NestedIterators:enabled:false"web_app/app/helpers":
UtilityFunction:enabled:false### Excluding directories# Directories below will not be scanned at allexclude_paths:
- lib/legacy
- lib/rake/legacy_tasks

If you have a directory directive for which a default directive exists, the more specific
one (which is the directory directive) will take precedence.

For more details please check out the Basic Smell Options
which are supported by every smell type. As you can see above, certain smell
types offer a configuration that goes beyond that of the basic smell options, for instance
Data Clump.
All options that go beyond the Basic Smell Options
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 file in this repository.

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

Generating a 'todo' list

Integrating tools like Reek into an existing larger codebase can be daunting when you have to fix
possibly hundreds or thousands of smell warnings first.
Sure you could manually disable smell warnings like shown above but depending on the size of your
codebase this might not be an option.
Fortunately Reek provides a 'todo' flag which you can use to generate a configuration that will
suppress all smell warnings for the current codebase:

reek --todo lib/

This will create the file '.todo.reek' in your current working directory.

You can then use this as your configuration - since your working directory
probably is your project root in most cases you don't have to tell Reek
explicitly to use '.todo.reek' because Reek will automatically pick it up
and use it as configuration file. See Configuration Loading above.

If for whatever reasons you decide to put '.todo.reek' somewhere else where
Reek won't pick it up automatically you need to tell Reek explicitly to do so
via:

reek -c whatever/.todo.reek lib/

It's important to understand that the number one use case of the --todo flag
is to be run once at the beginning of the introduction of Reek to ease the transition.
If you find yourself re-running Reek with the --todo flag in order to silence new warnings
you're defeating the purpose of both the --todo flag and of Reek itself.

As a consequence, running Reek with the --todo flag again will overwrite '.todo.reek' without
asking (should not be a problem since this file is supposed to be versioned) and
without taking any other configuration file you might have into account.

This means that when you run

reek -c other_configuration.reek --todo lib/

other_configuration.reek will simply be ignored (as outlined before, Reek
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.

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
explicitly which file to use via reek -c config.reek.

Source code comments

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 special
source code comments like this:

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.