From 6dcbafe381c088d770594bcf77524df67196b1ee Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Thu, 21 Dec 2023 18:02:22 +0100 Subject: [PATCH] refactor: remove null check The `version` parameter of `tryParseEditorVersion` is nullable needlessly. Made it non-nullable in order to simplify code. Also removed corresponding test. --- src/types/editor-version.ts | 4 +--- test/test-editor-version.ts | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/types/editor-version.ts b/src/types/editor-version.ts index d475a5fb..a3972a16 100644 --- a/src/types/editor-version.ts +++ b/src/types/editor-version.ts @@ -87,7 +87,7 @@ export const compareEditorVersion = function ( * locBuild: 4 */ export const tryParseEditorVersion = function ( - version: string | null + version: string ): EditorVersion | null { type RegexMatchGroups = { major: `${number}`; @@ -98,8 +98,6 @@ export const tryParseEditorVersion = function ( loc?: "c"; locBuild?: `${number}`; }; - - if (!version) return null; const regex = /^(?\d+)\.(?\d+)(\.(?\d+)((?a|b|f|c)(?\d+)((?c)(?\d+))?)?)?/; const match = regex.exec(version); diff --git a/test/test-editor-version.ts b/test/test-editor-version.ts index 82307a2f..96327bcb 100644 --- a/test/test-editor-version.ts +++ b/test/test-editor-version.ts @@ -8,9 +8,6 @@ import assert from "assert"; describe("editor-version", function () { describe("parseEditorVersion", function () { - it("test null", function () { - (tryParseEditorVersion(null) === null).should.be.ok(); - }); it("test x.y", function () { const version = tryParseEditorVersion("2019.2"); assert(version !== null);