From e8874dca1d6787ee172d61ac4b03e5c4584eaaf4 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 10 Jan 2023 14:28:13 +0100 Subject: [PATCH] fix(package-rules): return early (#19768) --- lib/util/package-rules/index.ts | 7 +------ lib/util/package-rules/utils.ts | 5 ++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/util/package-rules/index.ts b/lib/util/package-rules/index.ts index 43c8acfcd7..9484d09dd5 100644 --- a/lib/util/package-rules/index.ts +++ b/lib/util/package-rules/index.ts @@ -29,7 +29,7 @@ function matchesRule( matchApplied = true; if (!is.truthy(isMatch)) { - positiveMatch = false; + return false; } } @@ -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( diff --git a/lib/util/package-rules/utils.ts b/lib/util/package-rules/utils.ts index 6294862715..7f48742c51 100644 --- a/lib/util/package-rules/utils.ts +++ b/lib/util/package-rules/utils.ts @@ -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; @@ -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 { -- GitLab