Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Style/RedundantRegexpEscape can generate incorrect fixes for hyphens in character classes #8335
A hyphen in the middle of a character class should only be unescaped if its resulting meaning stays the same.
In at least some scenarios the hyphen can be converted to a range meaning. See below for a concrete example.
Steps to reproduce the problem
Under this version of Rubocop the regexp above is incorrectly simplified to
…xpEscape` The previous code wouldn't detect character classes that had ":" as their first element (due to a poor attempt at avoiding issues due to POSIX bracket expressions). The handling of nested character classes was also improved to avoid false-negatives.