apache / apache/maven-mapping

Unused empty capture group in regex pattern

Open
#67 0 comments 0 reactions 1 assignee Claimed by @elharo View on GitHub
Dominant language
Java
Stars
2
Forks
7
Avg merge
11h 11m
Merged PRs (30d)
4

Description

## Description

In `MappingUtils.java:90`, the `RegexBasedInterpolator` is constructed with:

```java
new RegexBasedInterpolator("\\@\\{(", ")?([^}]+)\\}@");
```

The prefix contains an opening `(` and the suffix starts with `)?`, forming an empty optional capture group `()?` that spans across the interpolator's internal key capture pattern. This group is never used for anything and is functionally dead regex.

The same result could be achieved with the simpler:

```java
new RegexBasedInterpolator("\\@\\{", "\\}@");
```

## Impact

No functional impact, but the unnecessary complexity obscures the intent and may confuse future contributors.

## Relevant code

`src/main/java/org/apache/maven/shared/mapping/MappingUtils.java:90`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.