Reek now uses a schema to validate your configuration against on start up and will faily loudly in case you misspelled an option or used the wrong data type for a value like this:
Error: We found some problems with your configuration file: [/detectors/DetectorWithTypo] key 'DetectorWithTypo:' is undefined.
Obviously this might affect existing configuration files that until now contained an error nobody noticed.
In Reek 4 you could just configure your detectors on top level like this:
UncommunicativeMethodName:
accept:
- foobar
UnusedPrivateMethod:
exclude:
- app/controllers
In Reek 5 you have to scope your detector configurations under the detectors
key:
detectors:
UncommunicativeMethodName:
accept:
- foobar
UnusedPrivateMethod:
exclude:
- app/controllers
In Reek 4 you could apply directory specific directives like this:
---
"web_app/app/controllers":
NestedIterators:
enabled: false
"web_app/app/helpers":
UtilityFunction:
enabled: false
which was nice and easy but also quite messy. With Reek 5 you'll have to scope this under a directories
key like this:
---
directories:
"web_app/app/controllers":
NestedIterators:
enabled: false
"web_app/app/helpers":
UtilityFunction:
enabled: false
In Reek 4 you could pass regular expressions to the accept
or reject
settings of
- Uncommunicative Method Name
- Uncommunicative Module Name
- Uncommunicative Parameter Name
- Uncommunicative Variable Name
and to the exclude
settings which are part of our Basic Smell Options.
This means that this configuration was perfectly valid:
detectors:
UncommunicativeMethodName:
accept:
- !ruby/regexp /foobar/
UnusedPrivateMethod:
exclude:
- !ruby/regexp /i am(.*)unused/
Support for this has been scrapped with Reek 5 to make the Reek configuration more yaml standard compliant. You can still pass in regexes, you just have to wrap them into a string using a forward slash at the beginning and at the end of the string like this:
---
UncommunicativeMethodName:
accept:
- "/^foobar$/"
UnusedPrivateMethod:
exclude:
- "/i am(.*)unused/"
Everything within the forward slashes will be loaded as a regex.
You cant use a configuration option that is supposed to be a list with a single element like this anymore:
---
UncommunicativeMethodName:
accept: foobar
UnusedPrivateMethod:
exclude: omg
You'll have to use a proper list here like this:
---
UncommunicativeMethodName:
accept:
- foobar
UnusedPrivateMethod:
exclude:
- omg
Previously Reek would just continue on syntax errors in source files which might have been convenient but not necessarily fitting for a tool that's all about code quality. With Reek 5, Reek will fail hard on invalid source files.
This is something that will only affect very advanced users. In case you have no idea what this might be about you can just skip it or check out our Developer API.
In Reek 4 you could build your configuration like this:
config_hash = { Reek::SmellDetectors::IrresponsibleModule => { 'enabled' => false } }
or like this:
config_hash = { 'IrresponsibleModule' => { 'enabled' => false } }
Starting with Reek 5, the first way is not working anymore and the latter one is what you'll have to use.
In the same vein as the change above you also can't use fully qualified detector names like this:
reek_of(Reek::SmellDetectors::DuplicateMethodCall)
The only supported way now is either as symbol or string:
reek_of(:DuplicateMethodCall)
reek_of('DuplicateMethodCall')
PrimaDonnaMethod
has been given the better nameMissingSafeMethod
wiki-links
flag has been renamed todocumentation
flag- Reek assumes the default configuration file to be named ".reek.yml" and will ignore all other files. You can
still use any name you want though by passing in a name via the
-c
flag - We have dropped the legacy code comment separator ":" at the end of a detector name. If you wanted to configure a smell detector via comment before this release you had to use g like this:
# :reek:UnusedPrivateMethod: { exclude: [ bravo ] }
Mind the ":" at the end of "UnusedPrivateMethod". This syntax is disallowed with Reek 5 - you have to drop the ":" at the end now like this:
# :reek:UnusedPrivateMethod { exclude: [ bravo ] }
- We have dropped support for Ruby 2.1 and 2.2 since they are officially not supported by the Ruby core team anymore