Sha256: 6ab83948f32f50fbaf62d9c92e1469ba09eea1f5a29157e46a011097c5439b22
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true module Reek module AST module SexpExtensions # Utility methods for :send nodes. module SendNode ATTR_DEFN_METHODS = [:attr_writer, :attr_accessor].freeze def receiver children.first end def name children[1] end def args children[2..] end def participants ([receiver] + args).compact end def module_creation_call? return true if object_creation_call? && module_creation_receiver? return true if data_definition_call? && data_definition_receiver? false end def object_creation_call? name == :new end def attribute_writer? ATTR_DEFN_METHODS.include?(name) || attr_with_writable_flag? end # Handles the case where we create an attribute writer via: # attr :foo, true def attr_with_writable_flag? name == :attr && args.any? && args.last.type == :true end private def module_creation_receiver? const_receiver? && [:Class, :Struct].include?(receiver.simple_name) end def data_definition_call? name == :define end def data_definition_receiver? const_receiver? && receiver.simple_name == :Data end def const_receiver? receiver && receiver.type == :const end end Op_AsgnNode = SendNode CSendNode = SendNode end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reek-6.4.0 | lib/reek/ast/sexp_extensions/send.rb |
reek-6.3.0 | lib/reek/ast/sexp_extensions/send.rb |
reek-6.2.0 | lib/reek/ast/sexp_extensions/send.rb |