Skip to content

Ignore lines made long by cop directive comments - #488

Merged
sambostock merged 1 commit into
mainfrom
allow-cop-directives-on-long-lines
Jan 30, 2023
Merged

Ignore lines made long by cop directive comments#488
sambostock merged 1 commit into
mainfrom
allow-cop-directives-on-long-lines

Conversation

@sambostock

@sambostock sambostock commented Jan 26, 2023

Copy link
Copy Markdown
Contributor

This resets Layout/LineLength's IgnoreCopDirectives to its default - true .

Assuming a config of Max: 20, for example purposes, this would be an offense based on our current config:

const_get(something) # rubocop:disable Sorbet/ConstantsFromStrings                                                                                                                    
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

and the author would have to resort to the more verbose

# rubocop:disable Sorbet/ConstantsFromStrings 
const_get(something)                                                                                                                    
# rubocop:enable Sorbet/ConstantsFromStrings

We already allow test descriptions to be long. I argue a similar justification applies here and that the inline version is better.

There is another alternative

const_get(something) # rubocop:disable Sorbet/ConstantsFromStrings,Layout/LineLength

but that makes the line even longer than before, so I think it makes sense to just allow directives.

@sambostock
sambostock requested a review from a team as a code owner January 26, 2023 20:32
@sambostock sambostock added the config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops label Jan 26, 2023
@sambostock
sambostock merged commit 44bc7ce into main Jan 30, 2023
@sambostock
sambostock deleted the allow-cop-directives-on-long-lines branch January 30, 2023 22:48
@shopify-shipit
shopify-shipit Bot temporarily deployed to rubygems April 11, 2023 15:04 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config change Changes the Rubocop config by enabling, disabling, or reconfiguring one or many cops

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants