-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Lint/SafeNavigationChain and try
#3915
Comments
I see no reason why someone should write code like this. Some rationale would be useful... |
Here:
|
This cop detected a lot of problems in our code, however some of them are false-positives due to this issue. |
Also, it's just perfectly fine to write something like |
It would be nice if more folks contributed their thoughts on this. I'm not convinced the change requested improves the code. In the particular case presented: |
it is reasonable.
We can use Rails/SafeNavigation cop for the purpose.
Yeah, however, I think it is out of scope for this cop. |
I agree.
…On Tue, Jan 17, 2017 at 11:21 Masataka Kuwabara ***@***.***> wrote:
it is reasonable.
Idea for a cop btw: use &. instead of .try!(...) where possible.
We can use Rails/SafeNavigation cop for the purpose.
https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/cop/rails/safe_navigation.rb
In the particular case presented: property&.params.try(:purpose)&.code. I
think defining the purpose method on all the objects params might return is
a better approach.
Yeah, however, I think it is out of scope for this cop.
The refactoring should be suggested by other cop or other analyser.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3915 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGVyl3tFP3pNc5Sc1y9PG9bvpnUMt7Rks5rTEG4gaJpZM4LkhbT>
.
|
… with `try` Fix rubocop#3915 . See the issue for details.
…try` Fix #3915 . See the issue for details.
Does it make sense to add more exceptions? for example:
|
I guess so. Any method that can be used in |
The following methods are added by RoR into
However, the cop supports only Should the cop support the above all methods? |
Maybe we should just make this configurable and let people add there whatever they want. I myself hate a style of programming that assumes |
At any rate - I wouldn't go overboard with this... |
I agree. It's currently almost impossible to deduce a set of methods that are allowed to be called after |
…onChain` cop See. rubocop#3915
Could you please push release to rubygems? |
I don't plan to issue a new release soon. This is a tiny issue that doesn't
warrant a special release. Just build the gem from master in the mean time.
…On Fri, Jan 20, 2017 at 18:59 MOZGIII ***@***.***> wrote:
Could you please push release to rubygems?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#3915 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGVyu5oPcePwmnm45QtmG1fckgnYck8ks5rUKGWgaJpZM4LkhbT>
.
|
P.S. My decision might change if more bugs get fixed in the next couple of days. |
Cop
Lint/SafeNavigationChain
does not allowtry
andtry!
.Expected behavior
try
andtry!
should be allowed after&.
in Rails.Actual behavior
Cop does not allow
try
andtry!
after&.
in Rails.Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: