Class: ImproveYourCode::SmellDetectors::UnusedParameters

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

Constant Summary

Constants inherited from BaseDetector

BaseDetector::EXCLUDE_KEY

Instance Attribute Summary

Attributes inherited from BaseDetector

#config

Instance Method Summary collapse

Methods inherited from BaseDetector

configuration_keys, contexts, default_config, descendants, inherited, #initialize, #run, #smell_type, smell_type, to_detector, todo_configuration_for, valid_detector?

Constructor Details

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

Instance Method Details

#sniffObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/improve_your_code/smell_detectors/unused_parameters.rb', line 8

def sniff
  return [] if context.uses_super_with_implicit_arguments?

  context.unused_params.map do |param|
    name = param.name.to_s

    smell_warning(
      context: context,
      lines: [source_line],
      message: "has unused parameter '#{name}'",
      parameters: { name: name }
    )
  end
end