Skip to content

Commit

Permalink
refactor(ubuntu): Enable strict null checks (#12849)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
zharinov and viceice committed Nov 28, 2021
1 parent f4dbff9 commit 177cae8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/versioning/ubuntu/index.ts
Expand Up @@ -72,30 +72,30 @@ 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;
}
if (xMajor < yMajor) {
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;
}
if (xMinor < yMinor) {
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;
}

Expand Down
2 changes: 2 additions & 0 deletions tsconfig.strict.json
Expand Up @@ -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",
Expand Down

0 comments on commit 177cae8

Please sign in to comment.