Skip to content

Wrong nil case handling for .include? #525

@OskarEichler

Description

@OskarEichler

I have the following snippet of code:

if uri.host =~ /tiktok\.com/

And rubocop-performance auto-fixes it like so:

if uri.host.include?('tiktok.com')

However, this doesn't handle the nil case correctly. It should fix like so:

if uri.host&.include?('tiktok.com')


Using latest versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions