Sha256: 7ee19b5da02375b6bf0aeb353ea1608bdf705bbfa0e53150a7f8c6c920dd51f3
Contents?: true
Size: 1020 Bytes
Versions: 2
Compression:
Stored size: 1020 Bytes
Contents
# encoding: utf-8 require 'rails_best_practices/reviews/review' module RailsBestPractices module Reviews # Check if method definition has parentheses around parameters. # # Review process: # check def node in all files, # if params node with values, but not wrapped by paren node, # then it should use parentheses around parameters. class UseParenthesesInMethodDefReview < Review interesting_nodes :def interesting_files ALL_FILES # check def node to see if parameters are wrapped by parentheses. def start_def(node) if no_parentheses_around_parameters?(node) && has_parameters?(node) add_error("use parentheses around parameters in method definitions") end end protected def no_parentheses_around_parameters?(def_node) :parent != def_node[2][0] end def has_parameters?(def_node) :params == def_node[2][0] && !def_node[2][1..-1].compact.empty? end end end end
Version data entries
2 entries across 2 versions & 1 rubygems