Skip to content
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

false positive RuboCop: Style/RedundantLineContinuation: Redundant line continuation. #163

Open
wrmk opened this issue Dec 25, 2023 · 6 comments

Comments

@wrmk
Copy link

wrmk commented Dec 25, 2023

I am faced with a strange problem, not sure that this is related to this gem, but I'd like to describe it.
Near 2 weeks ago the command slim-lint . started to return false positive results:
RuboCop: Style/RedundantLineContinuation: Redundant line continuation.

examples:

  = card_edit( \
      card_name: "header",
      target_model: @object,
      target_url: update_header_object_path(@object),
    ) do |form|
    = form.text_field :display_name, label: t(".object_name")
= select_tag :status,
              options_for_select(Object::STATUSES.map do |status| \
                [t(".statuses.#{status}"), status] \
              end),
              class: "form-control form-select text-truncate",
              autocomplete: "off",
              prompt: ""
- href = tab_very_long_helper_path_name_object_url( \
    object.id, object.very_long_method_name, tab: :info)
@jwilsjustin
Copy link

I'm seeing this too and I think I narrowed down the source to something introduced in RuboCop v1.58. When I manually set the rubocop gem to v1.57.2, the warning doesn't appear.

Here's the full diff of all changes between v1.57.2 and 1.58.0. This change sticks out: rubocop/rubocop#12403 Maybe that change introduced a bug for those who use slim-lint?

@jwilsjustin
Copy link

 1| = simple_form_for @coupon do |f|
 2|  = f.input :strategy,
 3|    as: :radio_buttons,
 4|    collection: [%w[Amount amount], %w[Percentage percent]],
 5|    input_html: { \
 6|      data: { controller: 'uniform', action: 'toggle#toggle', toggle_target: 'actor' } }
 7|  = f.input :amount_off,
 8|    wrapper_html: { \
 9|    class: 'amount-off-area',
10|    data: { toggle_target: 'section', toggle_show: 'amount' } } do
11|      .input-prepend
12|        span.add-on = current_currency.symbol
13|        = f.input_field :amount_off

With gem "rubocop", "1.57.2" in my Gemfile, slim-lint does not issue a violation for the above code. With gem "rubocop", "1.59" in my Gemfile, here is the violation:

app/views/coupons/_form.html.slim:8 [W] RuboCop: Style/RedundantLineContinuation: Redundant line continuation.

Removing the trailing \ on line 8 makes for invalid slim.

app/views/coupons/_form.html.slim:9 [E] Expected tag

I've tried several different tweaks, but to no satisfactory avail.

@jwilsjustin
Copy link

What's also interesting is that the trailing \ on line 5 presents no problem ¯\_(ツ)_/¯

@borama
Copy link
Contributor

borama commented Mar 25, 2024

In my case, Rubocop (1.62.1) reports both places:

app/views/shared/_hello.html.slim:5 [W] RuboCop: Style/RedundantLineContinuation: Redundant line continuation.
app/views/shared/_hello.html.slim:8 [W] RuboCop: Style/RedundantLineContinuation: Redundant line continuation.

We are going to switch this cop off in our configuration.

@davidvazteixeira
Copy link

I converted the file _links.html.erb from Devise gem. As the line is to long, I came with:

- if devise_mapping.lockable? && \
     resource_class.unlock_strategy_enabled?(:email) && \
     controller_name != 'unlocks'

and corfirm the bug:

app/views/devise/shared/_links.html.slim:12 [W] RuboCop: Style/RedundantLineContinuation: Redundant line continuation.

I'll just wait for the fix with:

# .rubocop.yml
Style/RedundantLineContinuation:
  Enabled: false
  • Setup:
    • Ruby 3.2.2
    • Rails 7.1.3.2
    • Rubocop: 1.62.1
    • slim-lint 0.27.0

@davidvazteixeira
Copy link

Opened just a month before this issue:

rubocop/rubocop#12430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants