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

Force code on one line if it is possible #7977

Closed
vdhpieter opened this issue May 15, 2020 · 1 comment
Closed

Force code on one line if it is possible #7977

vdhpieter opened this issue May 15, 2020 · 1 comment
Labels
stale Issues that haven't been active in a while

Comments

@vdhpieter
Copy link

Is your feature request related to a problem? Please describe.

I would like a cop that forces ruby code as much as possible on 1 line. I am integrating RuboCop way more strictly in a long-living project. It's going pretty well but the autocorrection sometimes adds more lines than needed IMO. To go even further I would like it if I can enforce code to be on 1 line as much as possible (until the max linewidth is reached). What happens now, for instance, is this:

method_call(other_method_call(foo: "this is a verry loooooooong string", bar: 1234), foobar: 123)

is corrected to:

method_call(
  other_method_call(
    foo: "this is a verry loooooooong string",
    bar: 1234
  ),
  foobar: 123
)

And I would like:

method_call(
  other_method_call(foo: "this is a verry loooooooong string", bar: 1234),
  foobar: 123
)

both are accepted with my current config

Describe the solution you'd like

A cop with this behavior

# bad
{
  foo: 1,
  bar: 2
}

#bad
foo(
  123,
  'bar'
)

# good
{ foo: 1, bar: 2 }

# good
foo(123, 'bar')

Describe alternatives you've considered

I dug pretty deep in RuboCop docs but could not find any thing. Prettier for ruby does do it like this way but I would like to use 1 tool instead of the combination of a lot.

If possible I would be open to help write this. But I never did anything like linting/formatting so I don't think it will be an easy task

@stale
Copy link

stale bot commented Nov 14, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale Issues that haven't been active in a while label Nov 14, 2020
jonas054 added a commit to jonas054/rubocop that referenced this issue Apr 6, 2021
Support method calls and assignments.

Disable the cop by default, but enable it for RuboCop sources.
@bbatsov bbatsov closed this as completed in a7edf2f Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues that haven't been active in a while
Projects
None yet
Development

No branches or pull requests

1 participant