Enforce parentheses on method calls with arguments - #761
Merged
Conversation
anakinj
force-pushed
the
style/method-call-parentheses
branch
from
September 5, 2026 19:44
c5f053b to
5568365
Compare
Style/MethodCallWithArgsParentheses is off by default, so the codebase had drifted both ways: JWT.encode payload, nil, alg next to JWT.encode(payload, nil, alg), with the paren-less form concentrated in the older specs. Exempted rather than normalised: raise and fail, because raise Foo, 'msg' is about as idiomatic as paren-less Ruby gets, and enforcing parentheses there accounted for 67 of the 100 changed lines in lib, all of it in the claims and crypto files. The codebase is already mixed on this and stays that way. yield, which is a keyword and reads like one. The gemspec, because add_dependency 'base64' is the universal form and the whole file is a DSL. Metrics/BlockLength already excludes it. The RSpec matcher DSL, so expect(x).to eq(y) does not become expect(x).to(eq(y)). What is left in lib is four calls: three include? k and one unpack. Everything is rubocop -a output apart from five arrays in readme_examples_spec, where the added parentheses pushed the elements out to a 36 column hanging indent; those are collapsed onto one line.
anakinj
force-pushed
the
style/method-call-parentheses
branch
from
September 5, 2026 19:47
5568365 to
44fec9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Style/MethodCallWithArgsParenthesesis off by default, so the codebase had drifted both ways —JWT.encode payload, nil, algsitting next toJWT.encode(payload, nil, alg), with the paren-less form concentrated in the older specs. This enables the cop and applies it.What is deliberately left alone
raiseandfail.raise Foo, 'msg'is about as idiomatic as paren-less Ruby gets, and enforcing parentheses on it accounted for 67 of the 100 changed lines inlib/— all of it in the claims and crypto files, for a style nobody asked for. The codebase is already mixed here (crit.rbandjwt_id.rbuse parentheses,audience.rbandexpiration.rbdo not) and stays that way, unenforced. Exempting these is what takeslib/from 100 changed lines down to 7.yield. A keyword that reads like one;yield('msg')is no clearer thanyield 'msg'.The gemspec.
spec.add_dependency 'base64'is the universal form and the whole file is a DSL.Metrics/BlockLengthalready excludes it.The RSpec matcher DSL. Without the exemptions the autocorrect produces
RSpec.describe(JWT)andexpect(x).to(eq(y)), which is worse than what it replaces.Scope
21 files, 226 insertions / 225 deletions.
lib/is down to four calls:The one hand-written part
Everything else is
rubocop -aoutput, except five arrays inspec/integration/readme_examples_spec.rb. Adding parentheses there madeLayout/FirstArrayElementIndentationpush the elements out to a 36 column hanging indent:They are collapsed onto one line instead. Switching
Layout/FirstArrayElementIndentationtoconsistentwas the other way to fix that, but it restyles 14 places to fix 5.Verification
Checklist
Before the PR can be merged be sure the following are checked: