Skip to content

regex group count issue #7013

@zyadahmed

Description

@zyadahmed

i read checker documentation
The Regex Checker validates that a legal capturing group number is passed to Matcher’s group, start and end methods.

private static final @Regex(3) Pattern REFERENCE = Pattern.compile(
            "^([a-z$][a-z\d$<>.])?(#(.))?$",
            Pattern.CASE_INSENSITIVE
    );
final Matcher matcher = REFERENCE.matcher(referenceString);
            if (matcher.matches()) {
                final int methodIndex = 3;
                final String methodPart = matcher.group(methodIndex);
                final boolean isValid = methodPart == null
                        || METHOD.matcher(methodPart).matches();
                if (isValid) {
                    validTag = Optional.of(tag);
                }
            }

it generate error

<checkerFrameworkError unstable="false">
    <specifier>group.count.unknown</specifier>
    <message>unable to verify non-literal groups parameter.</message>
    <lineContent>final String methodPart = matcher.group(methodIndex);</lineContent>
  </checkerFrameworkError>

Should it be handled correctly because the variable declaration is final and the range in the @Regex(3) , or am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions