class RuboCop::Cop::Style::OptionHash
end
# …
def fry(temperature: 300)
# good
end
# …
temperature = options.fetch(:temperature, 300)
def fry(options = {})
# bad
@example
current Ruby version supports keyword arguments.
Checks for options hashes and discourages them if the
def allowlist
def allowlist cop_config['Allowlist'] || [] end
def on_args(node)
def on_args(node) return if super_used?(node) return if allowlist.include?(node.parent.method_name.to_s) option_hash(node) { |options| add_offense(options) } end
def super_used?(node)
def super_used?(node) node.parent.each_node(:zsuper).any? end
def suspicious_name?(arg_name)
def suspicious_name?(arg_name) cop_config.key?('SuspiciousParamNames') && cop_config['SuspiciousParamNames'].include?(arg_name.to_s) end