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

use Style/RegexpLiteral correctly #168

Closed
bastelfreak opened this issue May 26, 2016 · 8 comments
Closed

use Style/RegexpLiteral correctly #168

bastelfreak opened this issue May 26, 2016 · 8 comments

Comments

@bastelfreak
Copy link
Member

we enable Style/RegexpLiteral in our rubocop config. this cop has a few possible stlyes that you have to enfoce with EnforcedStyle which we don't do. this often results in a cop loop. I prefer EnforcedStyle: percent_r, any other opinions?

documentation at http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/RegexpLiteral

@rnelson0
Copy link
Member

While I personally prefer percent_r, I think most every other developer I've met prefers slashes. Also, why doesn't mixed work with both? sigh Rubocop.

@bastelfreak
Copy link
Member Author

I prefed slashes some time ago, but escaping changed my mind, thats why I vote for percent_r.

@rnelson0
Copy link
Member

I am concerned how it might affect those contributing to us, they'll need to do more rebases likely and it could put some people off.

@jyaworski
Copy link
Member

I vote for percent_r for the same reasons, although // is more pleasant.

@juniorsysadmin
Copy link
Member

I prefer percent_r

@bastelfreak
Copy link
Member Author

We got a few opinions here and it seems to tend to percent_r. I created a PR for that.

@Sharpie
Copy link

Sharpie commented May 4, 2020

Way late to this party. But, I personally prefer slashes because the Puppet language syntax has no percent_r equivalent. Preferring slashes results in regex literals that are consistent between both the Ruby and Puppet code in a module --- which can help newcomers that have a contribution that involves both languages.

percent_r is useful in situations where it avoids escaping.

@op-ct
Copy link

op-ct commented Sep 2, 2020

Retroactive 👍 for percent_r. Forward slashes are common in Puppet-related code, and escaping URLs or file paths usually makes a regex look like an extra-hard excite bike stage.

It's unfortunate the Puppet language itself doesn't support %r, because it provides a lot of clarity in Ruby.

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

No branches or pull requests

7 participants