Sha256: 3959b0042806ae85858c59157b9a84a74b6f67683cc3e19314b8c5a007378c2d

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

require 'reek/smells/smell_detector'
require 'reek/smell_warning'
require 'reek/source/code_comment'

module Reek
  module Smells

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

      SMELL_CLASS = self.name.split(/::/)[-1]
      SMELL_SUBCLASS = SMELL_CLASS

      MODULE_NAME_KEY = 'module_name'

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

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

      #
      # Checks the given class or module for a descriptive comment.
      #
      # @return [Array<SmellWarning>]
      #
      def examine_context(ctx)
        comment = Source::CodeComment.new(ctx.exp.comments)
        return [] if self.class.descriptive[ctx.full_name] ||= comment.is_descriptive?
        smell = SmellWarning.new(SMELL_CLASS, ctx.full_name, [ctx.exp.line],
          'has no descriptive comment',
          @source, SMELL_SUBCLASS, {MODULE_NAME_KEY => ctx.exp.text_name})
        [smell]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reek-1.3.8 lib/reek/smells/irresponsible_module.rb
reek-1.3.7 lib/reek/smells/irresponsible_module.rb
reek-1.3.6 lib/reek/smells/irresponsible_module.rb
reek-1.3.5 lib/reek/smells/irresponsible_module.rb
reek-1.3.4 lib/reek/smells/irresponsible_module.rb
reek-1.3.3 lib/reek/smells/irresponsible_module.rb
reek-1.3.2 lib/reek/smells/irresponsible_module.rb