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 Style/SafeNavigation for negated method call with a safe navigation #10946

Merged
merged 1 commit into from Aug 21, 2022

Conversation

fatkodima
Copy link
Contributor

Running rubocop on

link && !link&.persisted?
Scanning foobar.rb
An error occurred while Style/SafeNavigation cop was inspecting foobar.rb:11:54.
Expected a Parser::Source::Range, Comment or RuboCop::AST::Node, got NilClass
/Users/fatkodima/Desktop/oss/rubocop/lib/rubocop/cop/corrector.rb:91:in `to_range'
/Users/fatkodima/Desktop/oss/rubocop/lib/rubocop/cop/corrector.rb:100:in `check_range_validity'
/Users/fatkodima/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter.rb:398:in `combine'
/Users/fatkodima/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter.rb:207:in `wrap'
/Users/fatkodima/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/parser-3.1.2.1/lib/parser/source/tree_rewriter.rb:231:in `insert_before'
/Users/fatkodima/Desktop/oss/rubocop/lib/rubocop/cop/style/safe_navigation.rb:283:in `block in add_safe_nav_to_all_methods_in_chain'
/Users/fatkodima/Desktop/oss/rubocop-ast/lib/rubocop/ast/node.rb:588:in `visit_ancestors'
/Users/fatkodima/Desktop/oss/rubocop-ast/lib/rubocop/ast/node.rb:228:in `each_ancestor'
.....

It started to fail after #10929.

@@ -0,0 +1 @@
* [#10946](https://github.com/rubocop/rubocop/pull/10946): Fix `Style/SafeNavigation` for negated method call with a safe navigation. ([@fatkodima][])
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the catchup and fixing!
This changelog entry is unneeded because the patch to changes that have not yet been released.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, sure 🤦

@koic koic merged commit 0048f70 into rubocop:master Aug 21, 2022
@koic
Copy link
Member

koic commented Aug 21, 2022

Thanks!

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.

None yet

2 participants