From 177cae82fb12e0d6136d7a844b5fe971832934c7 Mon Sep 17 00:00:00 2001
From: Sergei Zharinov <zharinov@users.noreply.github.com>
Date: Sun, 28 Nov 2021 18:45:13 +0300
Subject: [PATCH] refactor(ubuntu): Enable strict null checks (#12849)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
---
 lib/versioning/ubuntu/index.ts | 14 +++++++-------
 tsconfig.strict.json           |  2 ++
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/versioning/ubuntu/index.ts b/lib/versioning/ubuntu/index.ts
index d875e52aed..07e470eedf 100644
--- a/lib/versioning/ubuntu/index.ts
+++ b/lib/versioning/ubuntu/index.ts
@@ -72,12 +72,12 @@ function getPatch(version: string): null | number {
 // comparison
 
 function equals(version: string, other: string): boolean {
-  return isVersion(version) && isVersion(other) && version === other;
+  return !!isVersion(version) && !!isVersion(other) && version === other;
 }
 
 function isGreaterThan(version: string, other: string): boolean {
-  const xMajor = getMajor(version);
-  const yMajor = getMajor(other);
+  const xMajor = getMajor(version) ?? 0;
+  const yMajor = getMajor(other) ?? 0;
   if (xMajor > yMajor) {
     return true;
   }
@@ -85,8 +85,8 @@ function isGreaterThan(version: string, other: string): boolean {
     return false;
   }
 
-  const xMinor = getMinor(version);
-  const yMinor = getMinor(other);
+  const xMinor = getMinor(version) ?? 0;
+  const yMinor = getMinor(other) ?? 0;
   if (xMinor > yMinor) {
     return true;
   }
@@ -94,8 +94,8 @@ function isGreaterThan(version: string, other: string): boolean {
     return false;
   }
 
-  const xPatch = getPatch(version) || 0;
-  const yPatch = getPatch(other) || 0;
+  const xPatch = getPatch(version) ?? 0;
+  const yPatch = getPatch(other) ?? 0;
   return xPatch > yPatch;
 }
 
diff --git a/tsconfig.strict.json b/tsconfig.strict.json
index 61ba5f4a39..7a93df971d 100644
--- a/tsconfig.strict.json
+++ b/tsconfig.strict.json
@@ -134,6 +134,8 @@
     "./lib/util/sanitize.ts",
     "./lib/util/split.ts",
     "./lib/util/url.ts",
+    "./lib/versioning/ubuntu/index.spec.ts",
+    "./lib/versioning/ubuntu/index.ts",
     "./lib/workers/pr/changelog/hbs-template.ts",
     "./lib/workers/pr/changelog/types.ts",
     "./lib/workers/repository/init/types.ts",
-- 
GitLab