Class: Reek::Smells::IrresponsibleModule

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

Overview

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

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

Constructor Details

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

Class Method Details

.contextsObject

:nodoc:


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

def self.contexts # :nodoc:
  [:class]
end

.descriptiveObject

:nodoc:


16
17
18
# File 'lib/reek/smells/irresponsible_module.rb', line 16

def self.descriptive   # :nodoc:
  @descriptive ||= {}
end

Instance Method Details

#examine_context(ctx) ⇒ Array<SmellWarning>

Checks the given class or module for a descriptive comment.


25
26
27
28
29
30
31
32
33
# File 'lib/reek/smells/irresponsible_module.rb', line 25

def examine_context(ctx)
  comment = Source::CodeComment.new(ctx.exp.comments)
  return [] if self.class.descriptive[ctx.full_name] ||= comment.descriptive?
  [SmellWarning.new(self,
                    context: ctx.full_name,
                    lines: [ctx.exp.line],
                    message: 'has no descriptive comment',
                    parameters: {  name: ctx.exp.text_name })]
end