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 #8862] Fix an error for Lint/AmbiguousRegexpLiteral #8863

Merged
merged 1 commit into from Oct 9, 2020

Conversation

koic
Copy link
Member

@koic koic commented Oct 8, 2020

Fixes #8862.

This PR fixes an error for Lint/AmbiguousRegexpLiteral when using regexp without method calls in nested structure.


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.

@@ -61,6 +61,8 @@ def find_offense_node(node, regexp_receiver)
end

def method_chain_to_regexp_receiver?(node)
return false unless node.parent.receiver
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seem node.parent is not repeated 3 times in the code. Perhaps a local variable is in order.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I updated it!

@koic koic force-pushed the fix_error_for_ambiguous_regexp_literal branch from 0bc327d to 4bf83d2 Compare October 8, 2020 23:06
Fixes rubocop#8862.

This PR fixes an error for `Lint/AmbiguousRegexpLiteral`
when using regexp without method calls in nested structure.
@koic koic force-pushed the fix_error_for_ambiguous_regexp_literal branch from 4bf83d2 to e36f120 Compare October 9, 2020 09:40
@koic koic merged commit f79e1c0 into rubocop:master Oct 9, 2020
@koic koic deleted the fix_error_for_ambiguous_regexp_literal branch October 9, 2020 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint/AmbiguousRegexpLiteral: undefined method `receiver' for nil:NilClass
2 participants