sds / slim-lint

Configurable tool for analyzing Slim templates
Other
204 stars 58 forks source link

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

Open wrmk opened 7 months ago

wrmk commented 7 months ago

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 commented 6 months ago

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: https://github.com/rubocop/rubocop/pull/12403 Maybe that change introduced a bug for those who use slim-lint?

jwilsjustin commented 6 months ago
 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 commented 6 months ago

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

borama commented 4 months ago

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 commented 3 months ago

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
davidvazteixeira commented 3 months ago

Opened just a month before this issue:

https://github.com/rubocop/rubocop/issues/12430