Skip to content

Files

Latest commit

 

History

History
35 lines (24 loc) · 578 Bytes

Lint-SafeNavigationChain.md

File metadata and controls

35 lines (24 loc) · 578 Bytes

Pattern: Unsafe method navigation chain

Issue: -

Description

The safe navigation operator returns nil if the receiver is nil. If you chain an ordinary method call after a safe navigation operator, it raises NoMethodError.

Examples

# bad

x&.foo.bar
x&.foo + bar
x&.foo[bar]
# good

x&.foo&.bar
x&.foo || bar

Default configuration

Attribute Value
Whitelist present?, blank?, presence, try

Further Reading