Find sub-patterns that can never match after a possessive quantifier

Proprietary

Marks a regular expression in which an unbounded possessive quantifier such as *+, ++ or {2,}+ is followed by something that has to start with a character the quantifier already matches, as in \d*+\d, [a-z]++x or (a|b)*+(a). The quantifier consumes every such character and gives none back, so what follows can never match. Only a quantified single character, character class, or group of single character alternatives is considered, and what follows is traced through groups, alternatives and optional parts. Skipped: bounded possessive quantifiers such as ?+ or {1,3}+, quantifiers inside a lookaround, quantifiers followed anywhere by an anchor, lookaround, back reference or bounded repetition such as {2}, \R and \X, \p{..}, \N{..}, \h, \v and class intersections, surrogates written as \u escapes outside a class, patterns with inline or compile flags, and patterns that are not a plain string literal. Test sources are not searched.

io.moderne.staticanalysis.FindUnreachableAfterPossessiveQuantifier
mod run . --recipe=io.moderne.staticanalysis.FindUnreachableAfterPossessiveQuantifier

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.