From 06f8802c5428fa5ca82eeb8b76a382ed42ad3e13 Mon Sep 17 00:00:00 2001
From: Sergei Zharinov <zharinov@users.noreply.github.com>
Date: Mon, 7 Mar 2022 08:12:48 +0300
Subject: [PATCH] refactor(datasource/pod): Enable strict null checks (#14542)

---
 lib/modules/datasource/pod/index.ts | 11 ++++++++---
 tsconfig.strict.json                |  1 -
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/modules/datasource/pod/index.ts b/lib/modules/datasource/pod/index.ts
index 7fd676b237..946af80dd8 100644
--- a/lib/modules/datasource/pod/index.ts
+++ b/lib/modules/datasource/pod/index.ts
@@ -59,7 +59,7 @@ function releasesGithubUrl(
 function handleError(packageName: string, err: HttpError): void {
   const errorData = { packageName, err };
 
-  const statusCode = err.response?.statusCode;
+  const statusCode = err.response?.statusCode ?? 0;
   if (statusCode === 429 || (statusCode >= 500 && statusCode < 600)) {
     logger.warn({ packageName, err }, `CocoaPods registry failure`);
     throw new ExternalHostError(err);
@@ -80,7 +80,7 @@ function handleError(packageName: string, err: HttpError): void {
 function isDefaultRepo(url: string): boolean {
   const match = githubRegex.exec(url);
   if (match) {
-    const { account, repo } = match.groups || {};
+    const { account, repo } = match.groups ?? {};
     return (
       account.toLowerCase() === 'cocoapods' && repo.toLowerCase() === 'specs'
     ); // https://github.com/CocoaPods/Specs.git
@@ -215,6 +215,11 @@ export class PodDatasource extends Datasource {
     packageName,
     registryUrl,
   }: GetReleasesConfig): Promise<ReleaseResult | null> {
+    // istanbul ignore if
+    if (!registryUrl) {
+      return null;
+    }
+
     const podName = packageName.replace(regEx(/\/.*$/), '');
     let baseUrl = registryUrl.replace(regEx(/\/+$/), '');
     baseUrl = massageGithubUrl(baseUrl);
@@ -226,7 +231,7 @@ export class PodDatasource extends Datasource {
     let result: ReleaseResult | null = null;
     const match = githubRegex.exec(baseUrl);
     if (match) {
-      const { hostURL, account, repo } = match?.groups || {};
+      const { hostURL, account, repo } = match?.groups ?? {};
       const opts = { hostURL, account, repo };
       result = await this.getReleasesFromGithub(podName, opts);
     } else {
diff --git a/tsconfig.strict.json b/tsconfig.strict.json
index 4325b24990..ac14c1e98e 100644
--- a/tsconfig.strict.json
+++ b/tsconfig.strict.json
@@ -77,7 +77,6 @@
     "lib/modules/datasource/nuget/v2.ts",
     "lib/modules/datasource/nuget/v3.ts",
     "lib/modules/datasource/packagist/index.ts",
-    "lib/modules/datasource/pod/index.ts",
     "lib/modules/datasource/pypi/index.ts",
     "lib/modules/datasource/repology/index.ts",
     "lib/modules/datasource/ruby-version/index.ts",
-- 
GitLab