Class: Reek::Smells::UnusedParameters

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

Overview

Methods should use their parameters.

Constant Summary

Constants inherited from SmellDetector

SmellDetector::DEFAULT_EXCLUDE_SET, SmellDetector::EXCLUDE_KEY

Instance Attribute Summary

Attributes inherited from SmellDetector

#smell_category, #smell_type, #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, #enabled?, #enabled_for?, #examine, #exception?, #initialize, #register, #report_on, smell_type, #value

Constructor Details

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

Class Method Details

.smell_categoryObject


10
11
12
# File 'lib/reek/smells/unused_parameters.rb', line 10

def self.smell_category
  'UnusedCode'
end

Instance Method Details

#examine_context(method_ctx) ⇒ Array<SmellWarning>

Checks whether the given method has any unused parameters.


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

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