From 74056629f1429d4b019b8bb20e51aa69d0ec260a Mon Sep 17 00:00:00 2001 From: RaghavaroraSF <97958393+RaghavaroraSF@users.noreply.github.com> Date: Wed, 19 Apr 2023 19:02:47 +0530 Subject: [PATCH] fix(chore): fix sonar code smells (#59) resolves sonar code smells to improve quality gate GH-52 --- .sonarcloud.properties | 15 +++++++++++++++ src/services/vault-connector.ts | 5 ++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 .sonarcloud.properties diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000..7437eac --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,15 @@ +# Path to sources +sonar.sources=src +sonar.exclusions=src/__tests__/** +#sonar.inclusions= + +# Path to tests +sonar.tests=src/__tests__ +#sonar.test.exclusions= +#sonar.test.inclusions= + +# Source encoding +sonar.sourceEncoding=UTF-8 + +# Exclusions for copy-paste detection +#sonar.cpd.exclusions= diff --git a/src/services/vault-connector.ts b/src/services/vault-connector.ts index 3f5f425..372d87e 100644 --- a/src/services/vault-connector.ts +++ b/src/services/vault-connector.ts @@ -42,7 +42,6 @@ export class VaultConnector { const resp = await this._vaultClient.init(opts); // eslint-disable-next-line @typescript-eslint/prefer-optional-chain if (!resp || !resp.keys || resp.keys.length === 0 || !resp.root_token) { - console.error(`Vault initialisation failed ! Response :: ${resp}`); throw new Error('Vault initialisation failed !'); } const keys = resp.keys; @@ -55,7 +54,8 @@ export class VaultConnector { secret_shares: 1, key: this._unsealKey ?? config?.unsealKey ?? '', }); - } else if (health.sealed) { + } + if (health.sealed && health.initialized) { // unseal vault server await this._vaultClient.unseal({ // eslint-disable-next-line @typescript-eslint/naming-convention @@ -438,7 +438,6 @@ export class VaultConnector { pathPrefix: this._config?.pathPrefix, }); } catch (error) { - console.error(`Vault connection failed ! Error :: ${error}`); throw new HttpErrors.Forbidden('Vault connection failed !'); } }