Skip to content
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

Enable Rubocop cop to omit parentheses from one-line method calls #2778

Merged
merged 18 commits into from Feb 15, 2019

Conversation

quartzmo
Copy link
Member

@quartzmo quartzmo commented Jan 7, 2019

This PR currently applies this change only to google-cloud-logging. If the style is acceptable, please approve and I will apply to all manual gems, then request a full review.

Enable Style/MethodCallWithArgsParentheses omit_parentheses

[closes #2716]

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 7, 2019
@quartzmo quartzmo self-assigned this Jan 7, 2019
@quartzmo quartzmo requested a review from dazuma January 7, 2019 23:36
@quartzmo quartzmo assigned blowmage and unassigned blowmage Jan 7, 2019
@quartzmo quartzmo requested a review from blowmage January 7, 2019 23:36
@quartzmo quartzmo added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 7, 2019
@blowmage
Copy link
Contributor

blowmage commented Jan 7, 2019

This reads fine to me but I'm sure others will disagree. @dazuma @TheRoyalTnetennba can you weigh in on this?

@quartzmo
Copy link
Member Author

quartzmo commented Jan 7, 2019

I'm OK with whatever style we agree on, but it seems to me it should be enforced.

Copy link
Contributor

@TheRoyalTnetennba TheRoyalTnetennba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -473,7 +473,7 @@ def labels_grpc
return {} if labels.nil?
# Coerce symbols to strings
Hash[labels.map do |k, v|
v = String(v) if v.is_a? Symbol
v = String v if v.is_a? Symbol

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@quartzmo
Copy link
Member Author

It looks like rubocop/rubocop#6643 is likely to be merged, so I'm leaving this PR open. Will check again on Rubocop progress next week.

@dazuma
Copy link
Member

dazuma commented Jan 22, 2019

rubocop/rubocop#6643 is merged. As it is a new feature, it will likely get released in rubocop version 0.64.0.

@quartzmo
Copy link
Member Author

@blowmage @dazuma I temporarily switched the Rubocop dependency to get @dazuma's new feature from rubocop/rubocop#6643:

gem "rubocop", git: "git@github.com:rubocop-hq/rubocop.git", branch: "master"

I then reverted the Kernel method calls to their original style, with parentheses.

PTAL at the current style and let me know if it looks good. I'd be happy to do an additional gem such as BigQuery if it helps.

@quartzmo
Copy link
Member Author

@dazuma Your new feature AllowParenthesesInCamelCaseMethod works, and rubocop succeeds. If I remove AllowParenthesesInCamelCaseMethod, it fails on the Kernel methods. However, when I run rubocop I see this warning:

Using rubocop 0.63.1 from git@github.com:rubocop-hq/rubocop.git (at master@d6e7a16)
...
Running RuboCop...
Warning: Style/MethodCallWithArgsParentheses does not support AllowParenthesesInCamelCaseMethod parameter.

Supported parameters are:

  - Enabled
  - IgnoreMacros
  - IgnoredMethods
  - AllowParenthesesInMultilineCall
  - AllowParenthesesInChaining
  - EnforcedStyle
  - SupportedStyles

Inspecting 26 files
..........................

26 files inspected, no offenses detected

@dazuma
Copy link
Member

dazuma commented Jan 22, 2019

@quartzmo Ah crap. That check slipped through while testing. Fix: rubocop/rubocop#6697

@dazuma
Copy link
Member

dazuma commented Jan 22, 2019

@quartzmo If you run against my branch, does the warning go away?

gem "rubocop", git: "git@github.com:dazuma/rubocop.git", branch: "paren-param"

@quartzmo
Copy link
Member Author

@dazuma Looks good!

Using rubocop 0.63.1 from git@github.com:dazuma/rubocop.git (at paren-param@a5a471a)
...
Chriss-iMac:google-cloud-logging quartzmo$ b rake rubocop
Running RuboCop...
Inspecting 26 files
..........................

26 files inspected, no offenses detected

@dazuma
Copy link
Member

dazuma commented Jan 23, 2019

FYI the fix is now on rubocop master.

@quartzmo
Copy link
Member Author

@blowmage @dazuma Does the style in this PR now look good? Should I add another gem (for example, google-cloud-bigquery) to the PR to be sure?

@blowmage
Copy link
Contributor

The style looks good to me. 👍 for applying it to more gems.

@JustinBeckwith JustinBeckwith added the 🚨 This issue needs some love. label Feb 7, 2019
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Feb 7, 2019
@quartzmo
Copy link
Member Author

quartzmo commented Feb 8, 2019

Added google-cloud-bigquery.

@quartzmo
Copy link
Member Author

Good news, Rubocop 0.64.0 was released with @dazuma's change.

Enable Style/MethodCallWithArgsParentheses omit_parentheses

[closes googleapis#2716]
Update .rubocop.yml to use AllowParenthesesInCamelCaseMethod
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
@quartzmo
Copy link
Member Author

Rebased to use rubocop 0.64.0 from master.

Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
Add Style/MethodCallWithArgsParentheses.
@quartzmo quartzmo removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 15, 2019
@quartzmo quartzmo merged commit 736989e into googleapis:master Feb 15, 2019
@quartzmo quartzmo deleted the rubocop-parens branch February 15, 2019 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement. 🚨 This issue needs some love.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should Rubocop enforce omitting parentheses in method calls?
7 participants