Class: Reek::SmellDetectors::UnusedParameters

Inherits:
BaseDetector
  • Object
show all
Defined in:
lib/reek/smell_detectors/unused_parameters.rb

Overview

Methods should use their parameters.

See Unused-Parameters for details.

Constant Summary

Constants inherited from BaseDetector

BaseDetector::DEFAULT_EXCLUDE_SET, BaseDetector::EXCLUDE_KEY

Instance Attribute Summary

Attributes inherited from BaseDetector

#config, #context

Instance Method Summary collapse

Methods inherited from BaseDetector

#config_for, configuration_keys, contexts, default_config, descendants, #enabled?, #exception?, #expression, inherited, #initialize, #run, #smell_type, smell_type, #smell_warning, #source_line, to_detector, todo_configuration_for, #value

Constructor Details

This class inherits a constructor from Reek::SmellDetectors::BaseDetector

Instance Method Details

#sniffArray<SmellWarning>

Checks whether the given method has any unused parameters.

Returns:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/reek/smell_detectors/unused_parameters.rb', line 17

def sniff
  return [] if context.uses_super_with_implicit_arguments?

  context.unused_params.map do |param|
    name = param.name.to_s
    smell_warning(
      lines: [source_line],
      message: "has unused parameter '#{name}'",
      parameters: { name: name })
  end
end