Class: Hashira::Smells::MethodContext

Inherits:
Data
  • Object
show all
Defined in:
lib/hashira/smells/contexts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



34
35
36
# File 'lib/hashira/smells/contexts.rb', line 34

def file
  @file
end

#nodeObject (readonly)

Returns the value of attribute node

Returns:

  • (Object)

    the current value of node



34
35
36
# File 'lib/hashira/smells/contexts.rb', line 34

def node
  @node
end

#ownerObject (readonly)

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



34
35
36
# File 'lib/hashira/smells/contexts.rb', line 34

def owner
  @owner
end

#sectionObject (readonly)

Returns the value of attribute section

Returns:

  • (Object)

    the current value of section



34
35
36
# File 'lib/hashira/smells/contexts.rb', line 34

def section
  @section
end

Instance Method Details

#argumentsObject



48
# File 'lib/hashira/smells/contexts.rb', line 48

def arguments = Parameters.arguments(node)

#lineObject



38
# File 'lib/hashira/smells/contexts.rb', line 38

def line = node.location.start_line

#mixin?Boolean

Returns:

  • (Boolean)


42
# File 'lib/hashira/smells/contexts.rb', line 42

def mixin? = section == :module_function

#parametersObject



46
# File 'lib/hashira/smells/contexts.rb', line 46

def parameters = Parameters.names(node)

#public?Boolean

Returns:

  • (Boolean)


44
# File 'lib/hashira/smells/contexts.rb', line 44

def public? = section == :public && !singleton?

#singleton?Boolean

Returns:

  • (Boolean)


40
# File 'lib/hashira/smells/contexts.rb', line 40

def singleton? = node.receiver.is_a?(Prism::Node) || section == :singleton

#siteObject



50
# File 'lib/hashira/smells/contexts.rb', line 50

def site = "#{file}:#{line}"

#subjectObject



36
# File 'lib/hashira/smells/contexts.rb', line 36

def subject = "#{owner}#{singleton? ? "." : "#"}#{node.name}"