Sha256: 464db57c363ae21efffeb5ad19e8d5134f2aefb6f0f51f9dffa2c800e171aae5

Contents?: true

Size: 1.79 KB

Versions: 26

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true
module Reek
  module AST
    module SexpExtensions
      # Base module for utility methods for argument nodes.
      module ArgNodeBase
        def name
          children.first
        end

        # Other is a symbol?
        def ==(other)
          name == other
        end

        def marked_unused?
          plain_name.start_with?('_')
        end

        def plain_name
          name.to_s
        end

        def block?
          false
        end

        def optional_argument?
          false
        end

        def anonymous_splat?
          false
        end

        def components
          [self]
        end
      end

      # Utility methods for :arg nodes.
      module ArgNode
        include ArgNodeBase
      end

      # Utility methods for :kwarg nodes.
      module KwargNode
        include ArgNodeBase
      end

      # Utility methods for :optarg nodes.
      module OptargNode
        include ArgNodeBase

        def optional_argument?
          true
        end
      end

      # Utility methods for :kwoptarg nodes.
      module KwoptargNode
        include ArgNodeBase

        def optional_argument?
          true
        end
      end

      # Utility methods for :blockarg nodes.
      module BlockargNode
        include ArgNodeBase

        def block?
          true
        end
      end

      # Utility methods for :restarg nodes.
      module RestargNode
        include ArgNodeBase

        def anonymous_splat?
          !name
        end
      end

      # Utility methods for :kwrestarg nodes.
      module KwrestargNode
        include ArgNodeBase

        def anonymous_splat?
          !name
        end
      end

      # Utility methods for :shadowarg nodes.
      module ShadowargNode
        include ArgNodeBase
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
reek-4.5.6 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.5.5 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.5.4 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.5.3 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.5.2 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.5.1 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.5.0 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.4.2 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.4.1 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.4.0 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.3.0 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.2.5 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.2.4 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.2.3 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.2.2 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.2.1 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.2.0 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.1.1 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.1.0 lib/reek/ast/sexp_extensions/arguments.rb
reek-4.0.5 lib/reek/ast/sexp_extensions/arguments.rb