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

More cops with parsing Regexp literals #7746

Closed
pocke opened this issue Feb 22, 2020 · 1 comment
Closed

More cops with parsing Regexp literals #7746

pocke opened this issue Feb 22, 2020 · 1 comment

Comments

@pocke
Copy link
Member

@pocke pocke commented Feb 22, 2020

RuboCop will get more power with parsing Regexp literals.
We can introduce https://github.com/ammar/regexp_parser to parse Regexp.

PoC

I already have a PoC project with the regexp_parser gem.
https://github.com/pocke/rubocop-regular_expression
Now it has only one cop, it is RegularExpression/MixedCaptureTypes cop. The cop warns if a Regexp literal has both of named/numbered captures. Because we cannot reference numbered captures if they are mixed.

And I also have other two cop ideas.
pocke/rubocop-regular_expression#1
pocke/rubocop-regular_expression#3

How release it?

I think we have two options to release the cops.

  • Merge the cops to RuboCop core
  • Release the cops as a RuboCop Plugin

And I like the first option, that merging the cops to RuboCop core.
Because the cops are useful for every RuboCop users. Regexp is used in most projects. So I think RuboCop provides the cops by default.

But the second option has an advantage. We can keep fewer dependencies of RuboCop core by separating the cops as a RuboCop plugin. Because the cops need regexp_parser gem.
But personally I think it is a small advantage.


So, I propose merging the cops to RuboCop core.
If the core team agrees with the proposal, I will merge the cop to this repository, and transfer the issues of other cop ideas.

@bbatsov
Copy link
Collaborator

@bbatsov bbatsov commented Feb 22, 2020

We can introduce https://github.com/ammar/regexp_parser to parse Regexp.

Looks pretty cool!

And I like the first option, that merging the cops to RuboCop core.
Because the cops are useful for every RuboCop users. Regexp is used in most projects. So I think RuboCop provides the cops by default.

I prefer this option as well.

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

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.