Skip to content

Commit

Permalink
fix(package-rules): return early (#19768)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jan 10, 2023
1 parent 08764fa commit e8874dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 1 addition & 6 deletions lib/util/package-rules/index.ts
Expand Up @@ -29,7 +29,7 @@ function matchesRule(
matchApplied = true;

if (!is.truthy(isMatch)) {
positiveMatch = false;
return false;
}
}

Expand All @@ -38,11 +38,6 @@ function matchesRule(
positiveMatch = true;
}

// nothing has been matched
if (!positiveMatch) {
return false;
}

// excludes
for (const groupExcludes of matchers) {
const isExclude = matcherOR(
Expand Down
5 changes: 2 additions & 3 deletions lib/util/package-rules/utils.ts
Expand Up @@ -8,7 +8,6 @@ export function matcherOR(
inputConfig: PackageRuleInputConfig,
packageRule: PackageRule
): boolean | null {
let positiveMatch = false;
let matchApplied = false;
for (const matcher of groupMatchers) {
let isMatch;
Expand All @@ -29,10 +28,10 @@ export function matcherOR(
matchApplied = true;

if (is.truthy(isMatch)) {
positiveMatch = true;
return true;
}
}
return matchApplied ? positiveMatch : null;
return matchApplied ? false : null;
}

export function massagePattern(pattern: string): string {
Expand Down

0 comments on commit e8874dc

Please sign in to comment.