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

Allow configuring "rubocop" enable/disable comment directive #8181

Open
twe4ked opened this issue Jun 21, 2020 · 4 comments
Open

Allow configuring "rubocop" enable/disable comment directive #8181

twe4ked opened this issue Jun 21, 2020 · 4 comments
Labels
feature request stale Issues that haven't been active in a while

Comments

@twe4ked
Copy link
Contributor

twe4ked commented Jun 21, 2020

Is your feature request related to a problem? Please describe.

I'd like to add an option to configure the comment directives (rubocop:disable Foo).

I've just submitted a PR to standardrb that monkey patches CommentConfig.

Describe the solution you'd like

Add a new configuration, something like:

# The identifier used for comment directives to enable/disable RuboCop rules.
# I.e. rubocop:disable Layout/LineLength.
CommentDirectiveIdentifier: rubocop

Change CommentConfig::COMMENT_DIRECTIVE_REGEXP into a (memoized) class method that reads the indentifier.

I had a quick go at implementing it but I'm not sure how I should go about accessing ConfigStore, any hints would be appreciated.

Describe alternatives you've considered

Monkey patching is the only alternative I've considered. It's not ideal because it would be easily broken during RuboCop upgrades.

Additional context

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 21, 2020

I'm not sure what exactly is the problem you're aiming to solve with this, so it'd be nice if we started there.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 21, 2020

I'm guessing you want standardrb to use different prefix for those, but consider the following - this way you'd break interop between people who are using RuboCop and standard on the same project (without using similar configs).

@twe4ked
Copy link
Contributor Author

twe4ked commented Jun 21, 2020

Yeah, sorry, I should have started with why. It's as you guessed though, I'd like to change the comment directive to standardrb to make it feel more natural.

but consider the following - this way you'd break interop between people who are using RuboCop and standard on the same project (without using similar configs).

Ideally you wouldn't have RuboCop set up to cover the same rules as standardrb, so you could just use the relevant comment directive for where the rule is coming from. The downside to that is it could be confusing. Although on the flip side I tried using standardrb:disable recently hoping it would just work.

@stale
Copy link

stale bot commented Dec 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale Issues that haven't been active in a while label Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request stale Issues that haven't been active in a while
Projects
None yet
Development

No branches or pull requests

2 participants