Reek follows standard Unix convention for passing arguments.
Check out
reek -hfor details.
In case your configuration file is not in the standard location (that would be your project directory or
whatever directory you're running Reek from) you can specify a configuration file with the -c option
like this:
reek -c /somewhere/on/your/filesystem/reek_config.yml lib/Probably the most standard use case would be to check all Ruby files in the lib directory:
reek lib/*.rbIn general, if any command-line argument is a directory, Reek searches that directory and all sub-directories for Ruby source files. Thus
reek libwould be equivalent to
reek lib/**/*.rbOccasionally you may want to quickly check a code snippet without going to the trouble of creating a file to hold it. You can pass the snippet directly to Reek's standard input:
echo "def x() true end" | reekTo just check all Ruby files in the current directory, you can simply run it with no parameters:
reekYou can tell Reek to only check particular smells by using the --smell
option and passing in the smell name.
For example, to only check for Utility Function, you would use:
reek --smell UtilityFunctionYou can select several smells by repeating the --smell option like so:
reek --smell UtilityFunction --smell UncommunicativeMethodNameBy passing in a "-n" flag to the reek command, the output will suppress the line numbers:
$ reek -n mess.rbmess.rb -- 2 warnings:
x doesn't depend on instance state (UtilityFunction)
x has the name 'x' (UncommunicativeMethodName)
Otherwise line numbers will be shown as default at the beginning of each warning in square brackets:
$ reek mess.rbmess.rb -- 2 warnings:
[2]:x doesn't depend on instance state (UtilityFunction)
[2]:x has the name 'x' (UncommunicativeMethodName)
reek has a verbose mode which you might find helpful as a beginner. "verbose" just means that behind each warning a helpful link will be displayed which leads directly to the corresponding reek documentation page. This mode can be enabled via the "-U" or "--documentation" flag.
So for instance, if your test file would smell of ClassVariable, this is what the reek output would look like:
reek -U test.rbtest.rb -- 1 warning:
[2]:Dummy declares the class variable @@class_variable (ClassVariable) [https://github.com/troessner/reek/blob/master/docs/Class-Variable.md]
Note the link at the end.