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

Allow backslashes for multilines in FactoryBot/ConsistentParenthesesStyle #15

Open
jcraigk opened this issue Nov 2, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@jcraigk
Copy link

jcraigk commented Nov 2, 2022

Currently from the docs:

# when method name and first argument are not on same line
create(
  :user
)
build(
  :user,
  name: 'foo'
)

It would be nice to have an option that allows backslashes even when enforcing parentheses on single-line calls. For example, the following should both be allowed:

create(:user, name: 'foo')
create \
  :user,
  name: 'foo'
@pirj
Copy link
Member

pirj commented Nov 4, 2022

Can you please elaborate?
Do you mean that the cop in omit_parentheses mode should add a backslash in its autocorrection instead of just raising an offence and skipping autocorrection?

would any other cop suggest fixing the layout after that?

@jcraigk
Copy link
Author

jcraigk commented Nov 4, 2022

See Style/MethodCallWithArgsParentheses which is a broader cop around the use of parens and backslashes. See AllowParenthesesInMultilineCall option, which allows granular control over multiline argument lists. Following the example of the broader cop, it might be best to add another option called MultilineStyle and allow values like [parentheses backslashes either]. Then if the MethodCallWithArgsParentheses cop was enabled at all, this would default to either. I'm sure there are other ways of doing this as well, including splitting this cop into two cops: one for single lines and one for multiline. The autocorrector would then know exactly what to do.

@ydah ydah transferred this issue from rubocop/rubocop-rspec May 6, 2023
@ydah ydah added the enhancement New feature or request label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants