-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AllowParenthesesInCamelCaseMethod option #6643
Conversation
8462593
to
faf0f9b
Compare
6c239a0
to
8f8a688
Compare
spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb
Outdated
Show resolved
Hide resolved
4168467
to
be7bfae
Compare
More specifically, this is |
@Drenmi This is true. (Or I've also seen the term The naming I've chosen, however, follows the existing internal naming convention (i.e. the existing methods refer to these simply as " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with this addition. I just cut a new release, so you'll need to rebase this on the latest version of master
, and fix the CHANGELOG. 🙂
Thank you for your contribution! 🙇
be7bfae
to
1fc3eae
Compare
This option on the Style/MethodCallWithArgsParentheses cop takes effect when EnforcedStyle:omit_parentheses. If true, CamelCase methods (with names beginning with a capital letter) may be called with parentheses even when taking arguments. Even though this case isn't syntactically ambiguous, it is sometimes preferred in order to make it more obvious that a method is being called rather than a constant referenced.
1fc3eae
to
eaab0f8
Compare
Thanks much! Rebased and resolved conflicts. |
This adds the option
AllowParenthesesInCamelCaseMethod
to theStyle/MethodCallWithArgsParentheses
cop, which takes effect whenEnforcedStyle: omit_parentheses
. When this option is set totrue
, methods whose name begins with a capital letter (i.e. which look like constants/modules) may be called using parentheses even when taking arguments. When this option is set tofalse
(the default, and identical to previous behavior), such methods may be called using parentheses when taking no arguments but must omit the parentheses when taking arguments.This style (always using parens when calling such methods) is useful in the
omit_parentheses
case because even though it is not actually syntactically ambiguous when arguments are present, it still it makes it syntactically more obvious that a method is being called rather than a constant being invoked.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.