Skip to content

Commit

Permalink
chore: fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardhyan committed Mar 20, 2023
1 parent 0a5a32d commit 86e540c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
4 changes: 2 additions & 2 deletions lib/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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* () {
Expand All @@ -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;
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ArtifactGlobber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ArtifactPathValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/GithubError.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 "";
Expand Down
50 changes: 28 additions & 22 deletions lib/Inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -112,28 +114,28 @@ 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;
}
return this.context.repo.owner;
}
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;
}
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions lib/Releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 86e540c

Please sign in to comment.