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: nested repeat operator '+' and '?' was replaced with '*' in regular expression #91

Closed
yakschuss opened this issue Nov 22, 2021 · 11 comments · Fixed by #93
Closed

Comments

@yakschuss
Copy link

yakschuss commented Nov 22, 2021

Hi! This gem is currently being used as a dependency, and I noticed a gem specific warning that pops up when device_detector is initialized.

Specifically:
warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression AND
regular expression has ']' without escape

It looks like the issue is stemming from this file on line 88.

I don't know a ton about Regexp and would probably have a difficult time trying to solve this.

Thanks!

.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: regular expression has ']' without escape
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/device_detector-1.0.6/lib/device_detector/parser.rb:88: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
@yakschuss yakschuss mentioned this issue Nov 22, 2021
@Danielshow
Copy link

I am also getting this on Prod

@800a7b32
Copy link

800a7b32 commented Dec 3, 2021

+1

1 similar comment
@tylerhoran
Copy link

+1

@thinklikeadesigner
Copy link

Glad it's not just me! Thanks for checking it out 👍

@durcak
Copy link

durcak commented Jan 5, 2022

+1

@jrochkind
Copy link

jrochkind commented Jan 10, 2022

Looks like there's a fix for this at #90 , but maintainers do not want to merge it, because the regexp comes from upstream.

Maintainers, an update on this issue would be helpful!

I only started getting these warnings in my logs updating from device_detector 1.0.5 to 1.0.6. Which I don't really understand, because I don't think the relevant line flagged in the warning does seems to have changed in 1.0.6, if I'm reading git blame right, it hasn't changed in 6 years?

  • Note :This repo does not seem to have standard git tags for releases in it, which makes it really hard to see or diff exactly what is in what version! Is it possible to start tagging in the repo for releases? The standard rake release rake task included with bundler for releases will do this automatically for you.
  • Also there is no CHANGELOG.md entry for 1.0.6, although 1.0.6 was released Nov 1 2021. I'm not sure an easy way to figure out the differences between 1.0.5 and 1.0.6....

I really want to get these warnings out of my logs, they are making my build logs much harder to read, they appear many times.... anyone have any ideas for ways to suppress these lines from build logs, if maintainers of device_detector can't solve the problem?

@jrochkind
Copy link

jrochkind commented Jan 10, 2022

OK, I can't quite figure out why this warning only started appearing with device_detector 1.0.6, exactly what is triggering it, the code is a bit complicated.

We are all assuming the warnings are spurious, the regexes are actually functioning as desired, just triggering a warning that can be ignored? I haven't verified that myself, but on that assumption...

Here's a way to suppress the warnings in your logs, using the ruby-warning gem. Add that gem to your project, then in some initialization file for your project/tests:

# avoid ruby warnings in our logs related to a regular expressions in the device_detector
# gem, a known problem that is unlikely to be fixed upstream.
# https://github.com/podigee/device_detector/issues/91

if device_detector_source_path = Gem.loaded_specs['device_detector']&.full_gem_path
  parser_source_file_path = (Pathname.new(device_detector_source_path) + "lib/device_detector/parser.rb").to_s
  Warning.ignore(/regular expression/, parser_source_file_path)
end

jrochkind added a commit to sciencehistory/scihist_digicoll that referenced this issue Jan 11, 2022
@enderwiggens
Copy link

I am also getting this error on 1.0.6

@jasonpau
Copy link

Same here; I recently updated from 1.0.5 to 1.0.6 and I immediately started getting the same errors as yakschuss.

@kwent
Copy link

kwent commented Feb 17, 2022

Looks like it's been fixed upstream matomo-org/device-detector#6992. Have someone the energy to open a PR with updated YAML files in this project and bump the version ?

@spiderpug
Copy link
Contributor

Thanks everybody for keeping track and all your efforts. We will provide a newer version of the gem soon.

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.