Sha256: e1675f52e7b3920ebbb6f9cad9c3a6cca5d497a46304f357b4d501b2ecefb674

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true
require_relative 'base_detector'

module Reek
  module SmellDetectors
    #
    # It is considered good practice to annotate every class and module
    # with a brief comment outlining its responsibilities.
    #
    # See {file:docs/Irresponsible-Module.md} for details.
    class IrresponsibleModule < BaseDetector
      def self.contexts
        [:casgn, :class, :module]
      end

      #
      # Checks the given class or module for a descriptive comment.
      #
      # @return [Array<SmellWarning>]
      #
      def sniff(ctx)
        return [] if descriptive?(ctx) || ctx.namespace_module?
        expression = ctx.exp
        [smell_warning(
          context: ctx,
          lines: [expression.line],
          message: 'has no descriptive comment')]
      end

      private

      def descriptive
        @descriptive ||= {}
      end

      # :reek:FeatureEnvy
      def descriptive?(ctx)
        descriptive[ctx.full_name] ||= ctx.descriptively_commented?
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reek-4.6.1 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.6.0 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.5.6 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.5.5 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.5.4 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.5.3 lib/reek/smell_detectors/irresponsible_module.rb