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

[Fix #6738] Prevent auto-correct conflict of `Style/Next` and `Style/SafeNavigation` #7006

Conversation

Projects
None yet
2 participants
@hoshinotsuyoshi
Copy link
Contributor

commented Apr 30, 2019

Fixes #6738

Solves problem like below:

problem

until x
  if foo
    foo.some_method do
      y
    end
  end
end

auto-corrects badly;

# frozen_string_literal: true

until x
  next unless foofoo&.some_method do
    y
  end
end

( in rubocop.yml, TargetRubyVersion: 2.3 needed(2.3 or higher version). )

new behavior

auto-corrects:

# frozen_string_literal: true

until x
  next unless foo

  foo.some_method do
    y
  end
end

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

hoshinotsuyoshi and others added some commits Apr 30, 2019

[Fix #6738] Prevent auto-correct conflict of `Style/Next` and `Style/…
…SafeNavigation`

Fixes #6738

Solves problem like below:

  ```ruby
  until x
    if foo
      foo.some_method do
        y
      end
    end
  end
  ```

  auto-corrects badly;

  ```ruby
  # frozen_string_literal: true

  until x
    next unless foofoo&.some_method do
      y
    end
  end
  ```

@bbatsov bbatsov merged commit 36673f0 into rubocop-hq:master Apr 30, 2019

0 of 17 checks passed

ci/circleci: cc-setup Your tests are queued behind your running builds
Details
ci/circleci: documentation-checks Your tests are queued behind your running builds
Details
ci/circleci: jruby-9.2-ascii_spec Your tests are queued behind your running builds
Details
ci/circleci: jruby-9.2-rubocop Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.2-ascii_spec Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.2-rubocop Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.3-ascii_spec Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.3-rubocop Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.4-ascii_spec Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.4-rubocop Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.5-ascii_spec Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.5-rubocop Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.6-ascii_spec Your tests are queued behind your running builds
Details
ci/circleci: ruby-2.6-rubocop Your tests are queued behind your running builds
Details
ci/circleci: ruby-head-ascii_spec Your tests are queued behind your running builds
Details
ci/circleci: ruby-head-rubocop Your tests are queued behind your running builds
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details

@hoshinotsuyoshi hoshinotsuyoshi deleted the hoshinotsuyoshi:autocorrect_conflict_next_and_safe_navigation branch May 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.