Sha256: 32ca8bdcd915751d5a065f988233fd6a40830148ecd379d5a2c7c2b372e5b32d

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

require File.join( File.dirname( File.expand_path(__FILE__)), 'smell_detector')
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'source')

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

      #
      # 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 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

6 entries across 6 versions & 1 rubygems

Version Path
reek-1.2.13 lib/reek/smells/irresponsible_module.rb
reek-1.2.12 lib/reek/smells/irresponsible_module.rb
reek-1.2.11 lib/reek/smells/irresponsible_module.rb
reek-1.2.10 lib/reek/smells/irresponsible_module.rb
reek-1.2.9 lib/reek/smells/irresponsible_module.rb
reek-1.2.8 lib/reek/smells/irresponsible_module.rb