Sha256: d064ef3bafc0b427288ed168dad2ab287c4c7197381d0cb91f7cf65c4c80c2cf

Contents?: true

Size: 1.08 KB

Versions: 13

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true
require_relative 'smell_detector'
require_relative 'smell_warning'

module Reek
  module Smells
    #
    # 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 < SmellDetector
      def self.contexts
        [:casgn, :class, :module]
      end

      #
      # Checks the given class or module for a descriptive comment.
      #
      # @return [Array<SmellWarning>]
      #
      def inspect(ctx)
        return [] if descriptive?(ctx) || ctx.namespace_module?
        expression = ctx.exp
        [smell_warning(
          context: ctx,
          lines: [expression.line],
          message: 'has no descriptive comment',
          parameters: { name: expression.name })]
      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

13 entries across 13 versions & 1 rubygems

Version Path
reek-4.2.3 lib/reek/smells/irresponsible_module.rb
reek-4.2.2 lib/reek/smells/irresponsible_module.rb
reek-4.2.1 lib/reek/smells/irresponsible_module.rb
reek-4.2.0 lib/reek/smells/irresponsible_module.rb
reek-4.1.1 lib/reek/smells/irresponsible_module.rb
reek-4.1.0 lib/reek/smells/irresponsible_module.rb
reek-4.0.5 lib/reek/smells/irresponsible_module.rb
reek-4.0.4 lib/reek/smells/irresponsible_module.rb
reek-4.0.3 lib/reek/smells/irresponsible_module.rb
reek-4.0.2 lib/reek/smells/irresponsible_module.rb
reek-4.0.1 lib/reek/smells/irresponsible_module.rb
reek-4.0.0 lib/reek/smells/irresponsible_module.rb
reek-4.0.0.pre1 lib/reek/smells/irresponsible_module.rb