Control Parameter
October 18, 2023 ยท View on GitHub
Introduction
Control Parameter is a case of Control Couple.
Example
A simple example would be the quoted parameter in the following method:
def write(quoted)
if quoted
write_quoted @value
else
write_unquoted @value
end
end
Fixing those problems is out of the scope of this document but an easy solution
could be to remove the write method altogether and to move the calls to
write_quoted and write_unquoted to the caller of write.
Current Support in Reek
Reek warns about Control Parameter when a method parameter or block parameter is the tested value in a conditional statement.
Configuration
Control Parameter supports the Basic Smell Options.