Class: ImproveYourCode::SmellDetectors::UnusedPrivateMethod

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

Defined Under Namespace

Classes: Hit

Constant Summary

Constants inherited from BaseDetector

BaseDetector::EXCLUDE_KEY

Instance Attribute Summary

Attributes inherited from BaseDetector

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseDetector

configuration_keys, 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

Class Method Details

.contextsObject



21
22
23
# File 'lib/improve_your_code/smell_detectors/unused_private_method.rb', line 21

def self.contexts
  [:class]
end

.default_configObject



8
9
10
# File 'lib/improve_your_code/smell_detectors/unused_private_method.rb', line 8

def self.default_config
  super.merge(SmellConfiguration::ENABLED_KEY => false)
end

Instance Method Details

#sniffObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/improve_your_code/smell_detectors/unused_private_method.rb', line 25

def sniff
  hits.map do |hit|
    name = hit.name

    smell_warning(
      context: context,
      lines: [hit.line],
      message: "has the unused private instance method '#{name}'",
      parameters: { name: name.to_s }
    )
  end
end