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

Support autocorrect for `Lint/Loop` cop #8383

Merged
merged 1 commit into from Aug 5, 2020

Conversation

@fatkodima
Copy link
Contributor

@fatkodima fatkodima commented Jul 22, 2020

No description provided.

@marcandre
Copy link
Contributor

@marcandre marcandre commented Jul 22, 2020

I think you might be loosing comments in this case:

begin
  something
end while # don't remove me
   test

May not be worth the worry.

@fatkodima
Copy link
Contributor Author

@fatkodima fatkodima commented Jul 22, 2020

I hope it is impossible to find the code like that 😄

This is much more possible:

begin
  something
end while test # don't remove me

And it will be correctly handled.

@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Jul 23, 2020

I wonder why we made this a lint cop, as I definitely don't remember it today. Seems we could have written better documentation. 😆

@marcandre
Copy link
Contributor

@marcandre marcandre commented Jul 23, 2020

Am I weird?

I prefer

loop do
  # ...
  break if condition
end

But I'd rather have

begin
   # ...
end while condition
# than
loop do
   # ...

  break unless condition
end

The answer is probably "yeah". I'm glad it's rare that there's a reason to loop

@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Jul 23, 2020

You're weird for sure, but then again - I've never had to use loop in my entire Ruby career. 😆

@fatkodima
Copy link
Contributor Author

@fatkodima fatkodima commented Jul 23, 2020

I've never had to use loop in my entire Ruby career. 😆

I have used loop, but I would say I have never used for loop (but I do not see it that bad as everybody talks), do not remember if I ever really used protected keyword with its intended purpose and never found the case where I really needed to made the choice between proc and lambda because of their differences.

@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Aug 5, 2020

The changes look good, but your branch has to be rebased on top of the current master branch due to merge conflicts.

@fatkodima fatkodima force-pushed the fatkodima:loop-cop-autocorrection branch from c8d5ed6 to 714b13d Aug 5, 2020
@fatkodima
Copy link
Contributor Author

@fatkodima fatkodima commented Aug 5, 2020

Rebased.

@bbatsov bbatsov merged commit 426814e into rubocop-hq:master Aug 5, 2020
26 checks passed
26 checks passed
windows 2.4
Details
windows 2.5
Details
windows 2.6
Details
windows 2.7
Details
windows mingw
Details
ci/circleci: cc-setup Your tests passed on CircleCI!
Details
ci/circleci: cc-upload-coverage Your tests passed on CircleCI!
Details
ci/circleci: documentation-checks Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.6-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.7-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-head-spec Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.