Class: Roodi::Checks::MethodNameCheck

Inherits:
NameCheck show all
Defined in:
lib/roodi/checks/method_name_check.rb

Overview

Checks a method name to make sure it matches the specified pattern.

Keeping to a consistent nameing convention makes your code easier to read.

Constant Summary collapse

DEFAULT_PATTERN =
/^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/

Constants inherited from Check

Check::NODE_TYPES

Instance Attribute Summary

Attributes inherited from NameCheck

#pattern

Instance Method Summary collapse

Methods inherited from NameCheck

#evaluate_start

Methods inherited from Check

#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #evaluate_start, make, #position, #start_file

Constructor Details

#initializeMethodNameCheck

Returns a new instance of MethodNameCheck.



12
13
14
15
# File 'lib/roodi/checks/method_name_check.rb', line 12

def initialize
  super()
  self.pattern = DEFAULT_PATTERN
end

Instance Method Details

#find_name(node) ⇒ Object



25
26
27
# File 'lib/roodi/checks/method_name_check.rb', line 25

def find_name(node)
  node[1]
end

#interesting_nodesObject



17
18
19
# File 'lib/roodi/checks/method_name_check.rb', line 17

def interesting_nodes
  [:defn]
end

#message_prefixObject



21
22
23
# File 'lib/roodi/checks/method_name_check.rb', line 21

def message_prefix
  'Method'
end