From 86e540cec67c357491d5080ec7d676baf08c12c8 Mon Sep 17 00:00:00 2001 From: eduard Date: Mon, 20 Mar 2023 10:25:20 +0100 Subject: [PATCH] chore: fix sonar issues --- lib/Action.js | 4 +-- lib/ArtifactGlobber.js | 2 +- lib/ArtifactPathValidator.js | 2 +- lib/GithubError.js | 4 +-- lib/Inputs.js | 50 ++++++++++++++++++++---------------- lib/Releases.js | 4 +-- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/lib/Action.js b/lib/Action.js index 771dbfff..62c1c80e 100644 --- a/lib/Action.js +++ b/lib/Action.js @@ -102,7 +102,7 @@ class Action { } static noPublishedRelease(error) { const githubError = new GithubError_1.GithubError(error); - return githubError.status == 404; + return githubError.status === 404; } updateDraftOrCreateRelease() { return __awaiter(this, void 0, void 0, function* () { @@ -120,7 +120,7 @@ class Action { const tag = this.inputs.tag; const response = yield this.releases.listReleases(); const releases = response.data; - const draftRelease = releases.find(release => release.draft && release.tag_name == tag); + const draftRelease = releases.find(release => release.draft && release.tag_name === tag); return draftRelease === null || draftRelease === void 0 ? void 0 : draftRelease.id; }); } diff --git a/lib/ArtifactGlobber.js b/lib/ArtifactGlobber.js index 1650b3f9..d4f58ee0 100644 --- a/lib/ArtifactGlobber.js +++ b/lib/ArtifactGlobber.js @@ -50,7 +50,7 @@ class FileArtifactGlobber { } globPattern(pattern, errorsFailBuild) { const paths = this.globber.glob(pattern); - if (paths.length == 0) { + if (paths.length === 0) { if (errorsFailBuild) { FileArtifactGlobber.throwGlobError(pattern); } diff --git a/lib/ArtifactPathValidator.js b/lib/ArtifactPathValidator.js index 8e820d8d..b5911be3 100644 --- a/lib/ArtifactPathValidator.js +++ b/lib/ArtifactPathValidator.js @@ -37,7 +37,7 @@ class ArtifactPathValidator { return this.paths.filter((path) => this.verifyNotDirectory(path)); } verifyPathsNotEmpty() { - if (this.paths.length == 0) { + if (this.paths.length === 0) { const message = `Artifact pattern:${this.pattern} did not match any files`; this.reportError(message); } diff --git a/lib/GithubError.js b/lib/GithubError.js index e57647c4..545c23fd 100644 --- a/lib/GithubError.js +++ b/lib/GithubError.js @@ -20,7 +20,7 @@ class GithubError { return this.error.status; } hasErrorWithCode(code) { - return this.githubErrors.some((err) => err.code == code); + return this.githubErrors.some((err) => err.code === code); } toString() { const message = this.error.message; @@ -37,7 +37,7 @@ class GithubError { return errors.map((err) => `- ${err}`).join("\n"); } remediation() { - if (this.status == 404) { + if (this.status === 404) { return "\nMake sure your github token has access to the repo and has permission to author releases"; } return ""; diff --git a/lib/Inputs.js b/lib/Inputs.js index 75ddf4d4..72a8c812 100644 --- a/lib/Inputs.js +++ b/lib/Inputs.js @@ -33,7 +33,7 @@ class CoreInputs { } get allowUpdates() { const allow = core.getInput('allowUpdates'); - return allow == 'true'; + return allow === 'true'; } get artifacts() { let artifacts = core.getInput('artifacts'); @@ -52,7 +52,7 @@ class CoreInputs { } get artifactErrorsFailBuild() { const allow = core.getInput('artifactErrorsFailBuild'); - return allow == 'true'; + return allow === 'true'; } get body() { const body = core.getInput('body'); @@ -67,27 +67,29 @@ class CoreInputs { } get createdDraft() { const draft = core.getInput('draft'); - return draft == 'true'; + return draft === 'true'; } get createdPrerelease() { const preRelease = core.getInput('prerelease'); - return preRelease == 'true'; + return preRelease === 'true'; } get createdReleaseBody() { - if (CoreInputs.omitBody) + if (CoreInputs.omitBody) { return undefined; + } return this.body; } static get omitBody() { - return core.getInput('omitBody') == 'true'; + return core.getInput('omitBody') === 'true'; } get createdReleaseName() { - if (CoreInputs.omitName) + if (CoreInputs.omitName) { return undefined; + } return this.name; } static get omitName() { - return core.getInput('omitName') == 'true'; + return core.getInput('omitName') === 'true'; } get commit() { const commit = core.getInput('commit'); @@ -112,13 +114,13 @@ class CoreInputs { } get generateReleaseNotes() { const generate = core.getInput('generateReleaseNotes'); - return generate == 'true'; + return generate === 'true'; } get makeLatest() { return core.getInput('makeLatest'); } get owner() { - let owner = core.getInput('owner'); + const owner = core.getInput('owner'); if (owner) { return owner; } @@ -126,14 +128,14 @@ class CoreInputs { } get removeArtifacts() { const removes = core.getInput('removeArtifacts'); - return removes == 'true'; + return removes === 'true'; } get replacesArtifacts() { const replaces = core.getInput('replacesArtifacts'); - return replaces == 'true'; + return replaces === 'true'; } get repo() { - let repo = core.getInput('repo'); + const repo = core.getInput('repo'); if (repo) { return repo; } @@ -158,39 +160,43 @@ class CoreInputs { return core.getInput('token', { required: true }); } get updatedDraft() { - if (CoreInputs.omitDraftDuringUpdate) + if (CoreInputs.omitDraftDuringUpdate) { return undefined; + } return this.createdDraft; } static get omitDraftDuringUpdate() { - return core.getInput('omitDraftDuringUpdate') == 'true'; + return core.getInput('omitDraftDuringUpdate') === 'true'; } get updatedPrerelease() { - if (CoreInputs.omitPrereleaseDuringUpdate) + if (CoreInputs.omitPrereleaseDuringUpdate) { return undefined; + } return this.createdPrerelease; } static get omitPrereleaseDuringUpdate() { - return core.getInput('omitPrereleaseDuringUpdate') == 'true'; + return core.getInput('omitPrereleaseDuringUpdate') === 'true'; } get updatedReleaseBody() { - if (CoreInputs.omitBody || CoreInputs.omitBodyDuringUpdate) + if (CoreInputs.omitBody || CoreInputs.omitBodyDuringUpdate) { return undefined; + } return this.body; } static get omitBodyDuringUpdate() { - return core.getInput('omitBodyDuringUpdate') == 'true'; + return core.getInput('omitBodyDuringUpdate') === 'true'; } get updatedReleaseName() { - if (CoreInputs.omitName || CoreInputs.omitNameDuringUpdate) + if (CoreInputs.omitName || CoreInputs.omitNameDuringUpdate) { return undefined; + } return this.name; } get updateOnlyUnreleased() { - return core.getInput('updateOnlyUnreleased') == 'true'; + return core.getInput('updateOnlyUnreleased') === 'true'; } static get omitNameDuringUpdate() { - return core.getInput('omitNameDuringUpdate') == 'true'; + return core.getInput('omitNameDuringUpdate') === 'true'; } stringFromFile(path) { return (0, fs_1.readFileSync)(path, 'utf-8'); diff --git a/lib/Releases.js b/lib/Releases.js index 2da9101f..896779b2 100644 --- a/lib/Releases.js +++ b/lib/Releases.js @@ -15,7 +15,7 @@ class GithubReleases { this.inputs = inputs; this.git = git; } - create(tag, body, commitHash, discussionCategory, draft, generateReleaseNotes, makeLatest, name, prerelease) { + create(tag, body, commitHash, discussionCategory, draft = false, generateReleaseNotes = false, makeLatest, name, prerelease = false) { return __awaiter(this, void 0, void 0, function* () { // noinspection TypeScriptValidateJSTypes return this.git.rest.repos.createRelease({ @@ -68,7 +68,7 @@ class GithubReleases { }); }); } - update(id, tag, body, commitHash, discussionCategory, draft, makeLatest, name, prerelease) { + update(id, tag, body, commitHash, discussionCategory, draft = false, makeLatest, name, prerelease = false) { return __awaiter(this, void 0, void 0, function* () { // noinspection TypeScriptValidateJSTypes return this.git.rest.repos.updateRelease({