Sha256: 2cd433255f6e5e5546d64e6084916ceaaf934678e94a884a90cbeab870ad647e

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require_relative 'smell_detector'
require_relative '../smell_warning'
require_relative '../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
      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.descriptive?
        [SmellWarning.new(self,
                          context: ctx.full_name,
                          lines: [ctx.exp.line],
                          message: 'has no descriptive comment',
                          parameters: {  name: ctx.exp.text_name })]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reek-2.1.0 lib/reek/smells/irresponsible_module.rb