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

Missing Cop for constant regexp? #151

Closed
marcandre opened this issue Jul 13, 2020 · 1 comment · Fixed by #174
Closed

Missing Cop for constant regexp? #151

marcandre opened this issue Jul 13, 2020 · 1 comment · Fixed by #174

Comments

@marcandre
Copy link
Contributor

The following code has 3 anti-patterns:

def self.tokens(pattern)
   pattern.scan(TOKEN).reject { |token| token =~ /\A#{SEPARATORS}\Z/ }
end

This issue is to identify that /\A#{SEPARATORS}\Z/ should be isolated as a constant, since all it's dynamic components are constants.

See: rubocop/rubocop-ast#65

@marcandre marcandre transferred this issue from rubocop/rubocop Jul 13, 2020
@marcandre
Copy link
Contributor Author

Alternative solution (easy auto-correct but much less known) is to correct to /\A#{SEPARATORS}\Z/o

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

Successfully merging a pull request may close this issue.

1 participant