Sha256: a38ccbbc80ce62891a156546300f28b2eef5de3e3d4c784dd88352d0637a7915

Contents?: true

Size: 933 Bytes

Versions: 7

Compression:

Stored size: 933 Bytes

Contents

require_relative 'code_context'
require_relative '../ast/sexp_formatter'

module Reek
  module Context
    #
    # A context wrapper for any module found in a syntax tree.
    #
    class ModuleContext < CodeContext
      def node_instance_methods
        local_nodes(:def)
      end

      def descriptively_commented?
        CodeComment.new(exp.leading_comment).descriptive?
      end

      # A namespace module is a module (or class) that is only there for namespacing
      # purposes, and thus contains only nested constants, modules or classes.
      #
      # However, if the module is empty, it is not considered a namespace module.
      #
      # @return true if the module is a namespace module
      def namespace_module?
        return false if exp.type == :casgn
        contents = exp.children.last
        contents && contents.find_nodes([:def, :defs], [:casgn, :class, :module]).empty?
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reek-3.7.1 lib/reek/context/module_context.rb
reek-3.7.0 lib/reek/context/module_context.rb
reek-3.6.1 lib/reek/context/module_context.rb
reek-3.6.0 lib/reek/context/module_context.rb
reek-3.5.0 lib/reek/context/module_context.rb
reek-3.4.1 lib/reek/context/module_context.rb
reek-3.4.0 lib/reek/context/module_context.rb