warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
Closed this issue ยท 11 comments
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
I am also getting this on Prod
+1
+1
Glad it's not just me! Thanks for checking it out ๐
+1
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?
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
I am also getting this error on 1.0.6
Same here; I recently updated from 1.0.5 to 1.0.6 and I immediately started getting the same errors as yakschuss.
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 ?
Thanks everybody for keeping track and all your efforts. We will provide a newer version of the gem soon.