Skip to content

Let Rails/LinkToBlank also catch cases where link_to_if++ is used #1288

@fwolfst

Description

@fwolfst

Is your feature request related to a problem?

While the cop catches instances where link_to is used, it doesnt catch its sister implementations link_to_if and link_to_unless.

# Bad
link_to_if config.url.present?, config.url, config.url, target: '_blank'

# Good
link_to_if config.url.present?, config.url, config.url, target: '_blank', rel: 'noopener noreferrer'

Describe the solution you'd like

The same cop should catch link_to_ifs and link_to_unlesss matching the conditions

Describe alternatives you've considered

Implementing a separate cop of a configuration value for the given cop.

Additional context

There is also link_to_unless_current which might be more difficult to implement a check against.

https://www.rubydoc.info/gems/rubocop-rails/RuboCop/Cop/Rails/LinkToBlank
https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy