Feature #21636
openProposal to Introduce a Dedicated Warning Category for Regular Expressions
Description
Hi folks,
while working on adding regex support for the marcel gem (see PR: https://github.com/rails/marcel/pull/132), I encountered regex warnings triggered by some of Tika’s regular expressions. Typically, these warnings are valid but in this case I'd like to silence them for one single call.
Currently, to suppress these warnings, I have overridden $VERBOSE
, which effectively silences all warnings but also hides potentially important ones. This feels like a blunt instrument that might mask unrelated issues.
Fortunately, Ruby already supports dedicated warning categories, as detailed in these discussions and pull requests:
- https://bugs.ruby-lang.org/issues/17122
- https://bugs.ruby-lang.org/issues/11588
- https://github.com/ruby/ruby/pull/3505
Given this existing framework, I would like to propose introducing a dedicated warning category for regular expressions. This would allow libraries and applications to suppress only regex-related warnings selectively, for example, with Warning[:regexp] = false
.
Such a feature would provide more granular control over warnings without compromising the visibility of other important warnings.