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

warning: character class has duplicated range #1

Open
mikosullivan opened this issue Oct 25, 2017 · 1 comment
Open

warning: character class has duplicated range #1

mikosullivan opened this issue Oct 25, 2017 · 1 comment

Comments

@mikosullivan
Copy link

mikosullivan commented Oct 25, 2017

Hi. I'd like to submit back a small modification to pattern.rb in the json/next gem.

When I was using JSONX.parse I kept getting this warning:

/var/lib/gems/2.3.0/gems/json-next-1.2.1/lib/json/next/parser/jsonx.rb: warning: character class has duplicated range
/var/lib/gems/2.3.0/gems/json-next-1.2.1/lib/json/next/parser/jsonx.rb:77: warning: character class has duplicated range

That warning is pointing out that in regular expressions, \w already covers _, so you don't need to have both in the pattern. Personally, it seems silly to make a whole warning about that - a little regex redundancy is hardly worth taking up anybody's time. But warnings can be annoying. I edited pattern.rb so that the three instances of this:

\\w_

are changed to just this:

\\w

That made the warning go away. Of course, I don't know if it will make other warnings or errors appear. But hopefully this can fix this small problem.

:-)
Miko

@geraldb
Copy link
Member

geraldb commented Oct 25, 2017

@mikosullivan Thanks for the detailed report on JSONX.parse. Will try your suggestion. Keep it up.

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

2 participants