Class: Reek::SmellDetectors::IrresponsibleModule

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

Overview

It is considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

See Irresponsible-Module for details.

Constant Summary

Constants inherited from BaseDetector

BaseDetector::DEFAULT_EXCLUDE_SET, BaseDetector::EXCLUDE_KEY

Instance Attribute Summary

Attributes inherited from BaseDetector

#config, #context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseDetector

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

Class Method Details

.contextsObject



13
14
15
# File 'lib/reek/smell_detectors/irresponsible_module.rb', line 13

def self.contexts
  [:casgn, :class, :module]
end

Instance Method Details

#descriptive_context?Boolean (private)

Returns:

  • (Boolean)


32
33
34
# File 'lib/reek/smell_detectors/irresponsible_module.rb', line 32

def descriptive_context?
  context.descriptively_commented?
end

#sniffArray<SmellWarning>

Checks the given class or module for a descriptive comment.

Returns:



22
23
24
25
26
27
28
# File 'lib/reek/smell_detectors/irresponsible_module.rb', line 22

def sniff
  return [] if descriptive_context? || context.namespace_module?

  [smell_warning(
    lines: [source_line],
    message: 'has no descriptive comment')]
end