Sha256: d543f19283238a2d92aa4d5dc29e32c02b4404543e3f060e89091e2af3e72285

Contents?: true

Size: 1.01 KB

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
reek-4.7.2 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.7.1 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.7.0 lib/reek/smell_detectors/irresponsible_module.rb
reek-4.6.2 lib/reek/smell_detectors/irresponsible_module.rb