lib/rubocop/cop/style/method_def_parentheses.rb in rubocop-0.52.0 vs lib/rubocop/cop/style/method_def_parentheses.rb in rubocop-0.52.1
- old
+ new
@@ -3,9 +3,88 @@
module RuboCop
module Cop
module Style
# This cops checks for parentheses around the arguments in method
# definitions. Both instance and class/singleton methods are checked.
+ #
+ # @example EnforcedStyle: require_parentheses (default)
+ # # The `require_parentheses` style requires method definitions
+ # # to always use parentheses
+ #
+ # # bad
+ # def bar num1, num2
+ # num1 + num2
+ # end
+ #
+ # def foo descriptive_var_name,
+ # another_descriptive_var_name,
+ # last_descriptive_var_name
+ # do_something
+ # end
+ #
+ # # good
+ # def bar(num1, num2)
+ # num1 + num2
+ # end
+ #
+ # def foo(descriptive_var_name,
+ # another_descriptive_var_name,
+ # last_descriptive_var_name)
+ # do_something
+ # end
+ #
+ # @example EnforcedStyle: require_no_parentheses
+ # # The `require_no_parentheses` style requires method definitions
+ # # to never use parentheses
+ #
+ # # bad
+ # def bar(num1, num2)
+ # num1 + num2
+ # end
+ #
+ # def foo(descriptive_var_name,
+ # another_descriptive_var_name,
+ # last_descriptive_var_name)
+ # do_something
+ # end
+ #
+ # # good
+ # def bar num1, num2
+ # num1 + num2
+ # end
+ #
+ # def foo descriptive_var_name,
+ # another_descriptive_var_name,
+ # last_descriptive_var_name
+ # do_something
+ # end
+ #
+ # @example EnforcedStyle: require_no_parentheses_except_multiline
+ # # The `require_no_parentheses_except_multiline` style prefers no
+ # # parantheses when method definition arguments fit on single line,
+ # # but prefers parantheses when arguments span multiple lines.
+ #
+ # # bad
+ # def bar(num1, num2)
+ # num1 + num2
+ # end
+ #
+ # def foo descriptive_var_name,
+ # another_descriptive_var_name,
+ # last_descriptive_var_name
+ # do_something
+ # end
+ #
+ # # good
+ # def bar num1, num2
+ # num1 + num2
+ # end
+ #
+ # def foo(descriptive_var_name,
+ # another_descriptive_var_name,
+ # last_descriptive_var_name)
+ # do_something
+ # end
class MethodDefParentheses < Cop
include ConfigurableEnforcedStyle
MSG_PRESENT = 'Use def without parentheses.'.freeze
MSG_MISSING = 'Use def with parentheses when there are ' \