Skip to content

Commit 3dc9655

Browse files
vaibhavbhalla2505Vaibhav  Bhalla
andauthored
refactor(chore): fix sonarqube issues (#2288)
GH-2287 Co-authored-by: Vaibhav Bhalla <[email protected]>
1 parent 2550720 commit 3dc9655

File tree

54 files changed

+253
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+253
-179
lines changed

packages/cache/src/services/strategies/redis-store.strategy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class RedisStoreStrategy implements ICacheStore {
8080
try {
8181
value = JSON.parse(value);
8282
} catch (e) {
83-
// do nothing
83+
throw new Error(`Failed to parse value: ${e.message}`);
8484
}
8585
return value as T;
8686
} else if (typeof res === 'number') {
@@ -94,7 +94,7 @@ export class RedisStoreStrategy implements ICacheStore {
9494
try {
9595
decoded = JSON.parse(decoded);
9696
} catch (e) {
97-
// do nothing
97+
throw new Error(`Failed to parse value: ${e.message}`);
9898
}
9999
return decoded;
100100
}) as T;

packages/cli/src/generators/scaffold/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class ScaffoldGenerator extends BaseGenerator<ScaffoldOptions> {
6262
},
6363
);
6464
} catch (error) {
65-
this.log(chalk.cyan(`Error while adding jenkinsfile`));
65+
this.log(chalk.cyan(`Error while adding jenkinsfile{error.message}`));
6666
}
6767
}
6868
async install() {

packages/core/src/casbin-secure-sequence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const SequenceActions = RestBindings.SequenceActions;
4242
const isJsonString = (str: string) => {
4343
try {
4444
JSON.parse(str);
45-
} catch (e) {
45+
} catch (_) {
4646
return false;
4747
}
4848
return true;

packages/core/src/components/proxy-builder/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// https://opensource.org/licenses/MIT
55
import {AnyObject, Entity} from '@loopback/repository';
66
import {ModelConstructor, RestRelationConfig} from './services';
7-
7+
export type HttpMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
88
export type ProxyBuilderConfig = Array<{
99
/**
1010
* The `configs` property in the `ProxyBuilderConfig` type is an array of either {@link EntityRestConfig} objects
@@ -85,7 +85,7 @@ export type RestOperationTemplate = {
8585
* operation like method, url, headers, etc
8686
*/
8787
template: {
88-
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
88+
method: HttpMethods;
8989
url: string;
9090
headers?: {
9191
Authorization?: '{token}' | string;

packages/core/src/secure-sequence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const SequenceActions = RestBindings.SequenceActions;
4141
const isJsonString = (str: string) => {
4242
try {
4343
JSON.parse(str);
44-
} catch (e) {
44+
} catch (_) {
4545
return false;
4646
}
4747
return true;

packages/core/src/service-sequence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const SequenceActions = RestBindings.SequenceActions;
3636
const isJsonString = (str: string) => {
3737
try {
3838
JSON.parse(str);
39-
} catch (e) {
39+
} catch (_) {
4040
return false;
4141
}
4242
return true;

sandbox/audit-ms-example/migration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ try {
1010
isLocal = true;
1111
}
1212
} catch (err) {
13-
console.info('\n');
13+
console.error('Error while checking for .infolder:', err);
1414
}
1515
if (isLocal) {
1616
console.info(`Skipping migrations`);

sandbox/auth-ms-basic-example/src/repositories/user.repository.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ export class UserRepository extends DefaultSoftCrudRepository<
105105
});
106106
await this.credentials(user.id).create(creds);
107107
} catch (err) {
108-
throw new HttpErrors.UnprocessableEntity('Error while hashing password');
108+
throw new HttpErrors.UnprocessableEntity(
109+
`Error while hashing password ${err.message}`,
110+
);
109111
}
110112
return user;
111113
}

sandbox/auth-ms-basic-example/src/services/user-ops.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class UserOpsService {
162162
try {
163163
creds = user && (await this.userRepository.credentials(user.id).get());
164164
} catch (e) {
165-
//do nothing
165+
throw new Error(`Error fetching credentials for user ${e.message}`);
166166
}
167167
if (!user || user.deleted) {
168168
throw new HttpErrors.Unauthorized(AuthenticateErrorKeys.UserDoesNotExist);

sandbox/auth-multitenant-example/src/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class AuthMultitenantExampleApplication extends BootMixin(
5151
includeProcessEnv: true,
5252
});
5353
}
54-
options.rest = options.rest || {};
54+
options.rest = options.rest ?? {};
5555
options.rest.port = +(process.env.PORT ?? port);
5656
options.rest.host = process.env.HOST;
5757
super(options);

0 commit comments

Comments
 (0)