Skip to content

Commit

Permalink
fix(chore): fix sonar code smells (#59)
Browse files Browse the repository at this point in the history
resolves sonar code smells to improve quality gate

GH-52
  • Loading branch information
RaghavaroraSF authored Apr 19, 2023
1 parent 06a10c9 commit 7405662
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -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=
5 changes: 2 additions & 3 deletions src/services/vault-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 !');
}
}
Expand Down

0 comments on commit 7405662

Please sign in to comment.