Skip to content

Commit

Permalink
Make sure that ** matches at least a single package part
Browse files Browse the repository at this point in the history
Fixes #76
  • Loading branch information
skuzzle committed May 31, 2023
1 parent 1436b92 commit f62a81d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
8 changes: 6 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[![Maven Central](https://img.shields.io/static/v1?label=MavenCentral&message=2.2.1-SNAPSHOT&color=blue)](https://search.maven.org/artifact/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.2.1-SNAPSHOT/jar) [![JavaDoc](https://img.shields.io/static/v1?label=JavaDoc&message=2.2.1-SNAPSHOT&color=orange)](http://www.javadoc.io/doc/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.2.1-SNAPSHOT)

### Features
* [#60](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/60) Fall back to _line-by-line_ parsing if _full-compilation-unit_ parsing failed.
### Bug fixes
* [#73](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/73) Classloader issues while locating LanguageSupport instances
* [#76](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/76) `**` wildcard must match at least a single package part

### Misc
* Updated various dependencies



Expand Down
3 changes: 2 additions & 1 deletion readme/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![Maven Central](https://img.shields.io/static/v1?label=MavenCentral&message=${project.version}&color=blue)](https://search.maven.org/artifact/${project.groupId}/${project.artifactId}/${project.version}/jar) [![JavaDoc](https://img.shields.io/static/v1?label=JavaDoc&message=${project.version}&color=orange)](http://www.javadoc.io/doc/${project.groupId}/${project.artifactId}/${project.version})

### Bug fixes
* [#73](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/73) Classloader issues while locating LanguageSupport instances #73
* [#73](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/73) Classloader issues while locating LanguageSupport instances
* [#76](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/76) `**` wildcard must match at least a single package part

### Misc
* Updated various dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ private static boolean matchesInternal(boolean matchIsStatic, String[] matchPart

if ("**".equals(patternPart)) {
if (patternIndex + 1 < patternParts.length) {

// See #76
// https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/76
// ** is supposed to match at least one package. So we eagerly skip
// one package
matchIndex++;

final String nextPatternPart = patternParts[patternIndex + 1];
while (matchIndex < matchParts.length
&& !matchParts(nextPatternPart, matchParts[matchIndex])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

public class PackagePatternTest {

@Test
void testMatchWildcardPrefix() {
// See #76
// https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/76
assertThat(PackagePattern.parse("**.com.google.common.annotations.VisibleForTesting")
.matches("com.couchbase.client.core.deps.com.google.common.annotations.VisibleForTesting")).isTrue();
}

@Test
void testMatchLiteralAsterisk() {
final PackagePattern pattern = PackagePattern.parse("java.util.'*'");
Expand Down

0 comments on commit f62a81d

Please sign in to comment.