diff --git a/lib/modules/manager/buildkite/extract.ts b/lib/modules/manager/buildkite/extract.ts index 5e3d7ec14f356b657e1042608e28b18071b2a063..ac345a369d7d43689b3ebf052526d7b0c1c3d390 100644 --- a/lib/modules/manager/buildkite/extract.ts +++ b/lib/modules/manager/buildkite/extract.ts @@ -17,30 +17,31 @@ export function extractPackageFile(content: string): PackageFile | null { const pluginsSection = regEx( /^(?<pluginsIndent>\s*)(-?\s*)plugins:/ ).exec(line); - if (pluginsSection) { + if (pluginsSection?.groups) { logger.trace(`Matched plugins on line ${lineNumber}`); isPluginsSection = true; pluginsIndent = pluginsSection.groups.pluginsIndent; } else if (isPluginsSection) { logger.debug(`serviceImageLine: "${line}"`); - const { currentIndent } = regEx(/^(?<currentIndent>\s*)/).exec( - line - ).groups; + const { currentIndent } = regEx(/^(?<currentIndent>\s*)/).exec(line) + ?.groups ?? /* istanbul ignore next: should never happen */ { + currentIndent: '', + }; const depLineMatch = regEx( /^\s+(?:-\s+)?(?<depName>[^#]+)#(?<currentValue>[^:]+)/ ).exec(line); if (currentIndent.length <= pluginsIndent.length) { isPluginsSection = false; pluginsIndent = ''; - } else if (depLineMatch) { + } else if (depLineMatch?.groups) { const { depName, currentValue } = depLineMatch.groups; logger.trace('depLineMatch'); - let skipReason: SkipReason; - let repo: string; + let skipReason: SkipReason | undefined; + let repo: string | undefined; const gitPluginMatch = regEx( /(ssh:\/\/git@|https:\/\/)(?<registry>[^/]+)\/(?<gitPluginName>.*)/ ).exec(depName); - if (gitPluginMatch) { + if (gitPluginMatch?.groups) { logger.debug('Examining git plugin'); const { registry, gitPluginName } = gitPluginMatch.groups; const gitDepName = gitPluginName.replace(regEx('\\.git$'), ''); diff --git a/lib/modules/manager/cargo/artifacts.ts b/lib/modules/manager/cargo/artifacts.ts index 0a7b3015f808334ab298363d04f477e4b6c31a36..a1a05c3ce3cd14b313fedec9d09850b37f671217 100644 --- a/lib/modules/manager/cargo/artifacts.ts +++ b/lib/modules/manager/cargo/artifacts.ts @@ -57,7 +57,7 @@ export async function updateArtifacts({ const existingLockFileContent = lockFileName ? await readLocalFile(lockFileName) : null; - if (!existingLockFileContent) { + if (!existingLockFileContent || !lockFileName) { logger.debug('No Cargo.lock found'); return null; } diff --git a/lib/modules/manager/cocoapods/artifacts.ts b/lib/modules/manager/cocoapods/artifacts.ts index 9a2a60f0f27fab7ed00f1a7a134ac2c721c3c391..e36240262f9da62d1a6f74017822b25bd210cb29 100644 --- a/lib/modules/manager/cocoapods/artifacts.ts +++ b/lib/modules/manager/cocoapods/artifacts.ts @@ -21,7 +21,7 @@ function getPluginCommands(content: string): string[] { const lines: string[] = content.split(newlineRegex); lines.forEach((line) => { const match = pluginRegex.exec(line); - if (match) { + if (match?.groups) { const { plugin } = match.groups; result.add(`gem install ${quote(plugin)}`); } diff --git a/lib/modules/manager/cocoapods/extract.ts b/lib/modules/manager/cocoapods/extract.ts index eed1fb52ba8776fd94c9e67c84c79b406bba8a33..d392d7ede1dd2d79cafa60c28f9c6862fbf5c675 100644 --- a/lib/modules/manager/cocoapods/extract.ts +++ b/lib/modules/manager/cocoapods/extract.ts @@ -54,10 +54,10 @@ export function gitDep(parsedLine: ParsedLine): PackageDependency | null { const platformMatch = regEx( /[@/](?<platform>github|gitlab)\.com[:/](?<account>[^/]+)\/(?<repo>[^/]+)/ - ).exec(git); + ).exec(git ?? ''); - if (platformMatch) { - const { account, repo, platform } = platformMatch?.groups || {}; + if (platformMatch?.groups) { + const { account, repo, platform } = platformMatch.groups; if (account && repo) { const datasource = platform === 'github' diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts index 1bece70c5c8e42a700eab2d15ba4e9bcd78ab69b..260843c7693a7d455f75b4c94f73e70b7f5a4ad0 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -156,7 +156,7 @@ export interface PackageDependency<T = Record<string, any>> extends Package<T> { currentVersion?: string; lockedVersion?: string; propSource?: string; - registryUrls?: string[]; + registryUrls?: string[] | null; rangeStrategy?: RangeStrategy; skipReason?: SkipReason; sourceLine?: number; diff --git a/tsconfig.strict.json b/tsconfig.strict.json index ce4b7261c0ed975ecf16bfed113ff961ce023710..d3da5e166e63f3c8634a38819041f620b830d57b 100644 --- a/tsconfig.strict.json +++ b/tsconfig.strict.json @@ -40,16 +40,6 @@ "lib/config/validation.ts", "lib/modules/datasource/github-releases/test/index.ts", "lib/modules/manager/api.ts", - "lib/modules/manager/buildkite/extract.ts", - "lib/modules/manager/buildkite/index.ts", - "lib/modules/manager/bundler/artifacts.ts", - "lib/modules/manager/bundler/index.ts", - "lib/modules/manager/bundler/extract.ts", - "lib/modules/manager/cargo/artifacts.ts", - "lib/modules/manager/cargo/index.ts", - "lib/modules/manager/cocoapods/artifacts.ts", - "lib/modules/manager/cocoapods/extract.ts", - "lib/modules/manager/cocoapods/index.ts", "lib/modules/manager/composer/artifacts.ts", "lib/modules/manager/composer/extract.ts", "lib/modules/manager/composer/index.ts",