You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
…nil check
Fixesrubocop#10926.
This PR makes `Style/SafeNavigation` aware of a redundant nil check.
IMHO, the context of this patch is a minimal update.
OTOH, a new cop like `Style/RedundantNilCheck` cop may be implemented
if it is not suitable for this `Style/SafeNavigation` cop.
(But I'm not sure if it's the best.)
Fixes#10926.
This PR makes `Style/SafeNavigation` aware of a redundant nil check.
IMHO, the context of this patch is a minimal update.
OTOH, a new cop like `Style/RedundantNilCheck` cop may be implemented
if it is not suitable for this `Style/SafeNavigation` cop.
(But I'm not sure if it's the best.)
This request came about due to an incorrectly formatted piece of code which followed the pattern:
This was correctly flagged up as an offence of
Style/SafeNavigation
, and so was manually adjusted to:which was not flagged up any further, despite the now redundant
nil
check.Describe the solution you'd like
I think in this situation there should be a further offence flagged up for the now redundant
nil
check. For example:should cause a
Style/RedundantNilCheck
flag (or something similar), which itself can be fixed with:Describe alternatives you've considered
Writing a custom cop for this, although I think it would make a good default.
The text was updated successfully, but these errors were encountered: