r7kamura / rubocop-slim

RuboCop plugin for Slim template.
MIT License
6 stars 1 forks source link

Problem caused by `Exclude` overwrites #14

Closed owen2345 closed 3 months ago

owen2345 commented 3 months ago

Having the following

.menus
  - if item.nested.any?
     = menu_item(
        size: :xxs,
        class: 'something',
        ....)

The lister expects the following:

.menus
  - if item.nested.any?
     = menu_item(
size: :xxs,
class: 'something',
....)

Lint observations:

something.slim: C: [Correctable] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line. (https://rubystyle.guide#no-double-indent)
                                    size: :xxs,

something.slim: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
                      = menu_item(

Ruby version: ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [aarch64-linux] Rails version: 6.1

Is this correct? Thanks in advance!

r7kamura commented 3 months ago

I don't have enough information to understand the situation. Can you be more specific, such as which cop is reporting the offense?

owen2345 commented 3 months ago

Sorry for the lack of info. Updated the issue details

r7kamura commented 3 months ago

Okay, I understand the situation.

As it turns out, it is an unintended behavior and should not happen that way: when rubocop-slim is loaded, those cops will be disabled for files with the extension .slim as follows:

https://github.com/r7kamura/rubocop-slim/blob/2944237030668da81e360b63c487b94df05a7721/config/default.yml#L10-L12 https://github.com/r7kamura/rubocop-slim/blob/2944237030668da81e360b63c487b94df05a7721/config/default.yml#L150-L152

However, if, for example, you subsequently override these Excludes in your configuration file, they will be re-enabled. Are you doing that in your .rucobop.yml?

owen2345 commented 3 months ago

Ohhh, I think that is the problem. Will review it. Thanks for your quick anwers

r7kamura commented 3 months ago

However, if, for example, you subsequently override these Excludes in your configuration file, they will be re-enabled. Are you doing that in your .rucobop.yml?

If this is the case, you may improve it by adding the following code:

# .rubocop.yml
inherit_mode:
  merge:
    - Exclude
owen2345 commented 3 months ago
# .rubocop.yml
inherit_mode:
  merge:
    - Exclude

Solved the problem, thank you again