Class: Reek::Smells::UnusedParameters Private

Inherits:
SmellDetector show all
Defined in:
lib/reek/smells/unused_parameters.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Methods should use their parameters.

See Unused-Parameters for details.

Constant Summary

Constants inherited from SmellDetector

SmellDetector::DEFAULT_EXCLUDE_SET, SmellDetector::EXCLUDE_KEY

Instance Attribute Summary

Attributes inherited from SmellDetector

#smells_found, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SmellDetector

#config_for, #configure_with, contexts, default_config, default_smell_category, descendants, #enabled?, #enabled_for?, #examine, #exception?, #initialize, #register, #report_on, #smell_category, smell_type, #smell_type, #value

Constructor Details

This class inherits a constructor from Reek::Smells::SmellDetector

Class Method Details

.smell_categoryObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/reek/smells/unused_parameters.rb', line 12

def self.smell_category
  'UnusedCode'
end

Instance Method Details

#examine_context(method_ctx) ⇒ Array<SmellWarning>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks whether the given method has any unused parameters.

Returns:



21
22
23
24
25
26
27
28
29
30
# File 'lib/reek/smells/unused_parameters.rb', line 21

def examine_context(method_ctx)
  return [] if method_ctx.uses_super_with_implicit_arguments?
  method_ctx.unused_params.map do |param|
    SmellWarning.new(self,
                     context: method_ctx.full_name,
                     lines: [method_ctx.exp.line],
                     message: "has unused parameter '#{param.name}'",
                     parameters: { name: param.name.to_s })
  end
end