Skip to content

Commit

Permalink
refactor(chore): fix sonar code smells (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
barleendhaliwal authored Jul 6, 2022
1 parent f7802fb commit 347d2f2
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 27 deletions.
8 changes: 4 additions & 4 deletions packages/cache/src/mixins/cache.mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class CacheManager {
finalResult = await super.findById(id, filter, options);
this.strategy
.saveInCache(key, finalResult, cacheOptions)
.catch(err => console.error(err));
.catch(err => console.error(err)); //NOSONAR
} else {
const result = (await this.strategy.searchInCache(
key,
Expand All @@ -77,7 +77,7 @@ export class CacheManager {
finalResult = await super.findById(id, filter, options);
this.strategy
.saveInCache(key, finalResult, cacheOptions)
.catch(err => console.error(err));
.catch(err => console.error(err)); //NOSONAR
}
}

Expand All @@ -97,7 +97,7 @@ export class CacheManager {
finalResult = await super.find(filter, options);
this.strategy
.saveInCache(key, finalResult, cacheOptions)
.catch(err => console.error(err));
.catch(err => console.error(err)); //NOSONAR
} else {
const result = (await this.strategy.searchInCache(
key,
Expand All @@ -109,7 +109,7 @@ export class CacheManager {
finalResult = await super.find(filter, options);
this.strategy
.saveInCache(key, finalResult, cacheOptions)
.catch(err => console.error(err));
.catch(err => console.error(err)); //NOSONAR
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
Provider,
ValueOrPromise,
} from '@loopback/core';
import {HttpErrors} from '@loopback/rest';
import {MiddlewareContext, Middleware} from '@loopback/express';
import {HttpErrors, MiddlewareContext, Middleware} from '@loopback/rest';
import {StrategyBindings} from '../keys';
import {FeatureFlagFn} from '../types';

Expand Down
3 changes: 3 additions & 0 deletions services/audit-service/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {AuditDbSourceName} from '@sourceloop/audit-log';
import {IServiceConfig} from '@sourceloop/core';

// sonarignore:start
export interface IAuditServiceConfig extends IServiceConfig {
//do nothing
}

// sonarignore:end

export const AuditSourceName = AuditDbSourceName;
2 changes: 2 additions & 0 deletions services/authentication-service/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {OtpMethodType} from './enums';
import {LocalUserProfileDto} from './models';
import {SignupRequestDto} from './models/signup-request-dto.model';

// sonarignore:start
export interface IAuthServiceConfig extends IServiceConfig {
//do nothing
}
// sonarignore:end

export const AuthDbSourceName = 'AuthDB';
export const AuthCacheSourceName = 'AuthCache';
Expand Down
2 changes: 2 additions & 0 deletions services/chat-service/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {IServiceConfig} from '@sourceloop/core';

// sonarignore:start
export interface IChatServiceConfig extends IServiceConfig {
//do nothing
}
// sonarignore:end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Provider} from '@loopback/context';
import {Provider} from '@loopback/core';
import {verify} from 'jsonwebtoken';
import {VerifyFunction} from 'loopback4-authentication';
import {IAuthUserWithPermissions} from '@sourceloop/core';
Expand Down
3 changes: 2 additions & 1 deletion services/in-mail-service/src/types/service-config.type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {IServiceConfig} from '@sourceloop/core';

// sonarignore:start
export interface IInMailServiceConfig extends IServiceConfig {
//do nothing
}
// sonarignore:end
16 changes: 4 additions & 12 deletions services/ocr-service/src/providers/fetch-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,13 @@ export class FetchClientProvider implements Provider<IRequestServiceConfig> {
sendRequest(url: string, method: string) {
if (method?.toUpperCase() === 'POST') {
return this.post(url);
}

if (method?.toUpperCase() === 'GET') {
} else if (method?.toUpperCase() === 'GET') {
return this.get(url);
}

if (method?.toUpperCase() === 'PUT') {
} else if (method?.toUpperCase() === 'PUT') {
return this.put(url);
}

if (method?.toUpperCase() === 'PATCH') {
} else if (method?.toUpperCase() === 'PATCH') {
return this.patch(url);
}

if (method?.toUpperCase() === 'DELETE') {
} else if (method?.toUpperCase() === 'DELETE') {
return this.delete(url);
} else {
//do nothing
Expand Down
2 changes: 2 additions & 0 deletions services/payment-service/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/**
* Interface defining the component's options object
*/
// sonarignore:start
export interface PaymentServiceComponentOptions {
// Add the definitions here
}
// sonarignore:end

/**
* Default options for the component
Expand Down
2 changes: 2 additions & 0 deletions services/reporting-service/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/**
* Interface defining the component's options object
*/
// sonarignore:start
export interface ReportingServiceComponentOptions {
// Add the definitions here
}
// sonarignore:end

/**
* Default options for the component
Expand Down
2 changes: 2 additions & 0 deletions services/user-tenant-service/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**
* Interface defining the component's options object
*/
// sonarignore:start
export interface UserTenantServiceComponentOptions {
//NOSONAR
// Add the definitions here
}
// sonarignore:end

/**
* Default options for the component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import {inject} from '@loopback/core';
import {TwilioBindings} from './keys';
import {TwilioConfig} from './types';
import twilio from 'twilio';
import {Twilio as TwilioClient} from 'twilio';
import twilio, {Twilio as TwilioClient} from 'twilio';
import {
RoomInstance,
RoomListInstanceCreateOptions,
} from 'twilio/lib/rest/video/v1/room';

import AccessToken from 'twilio/lib/jwt/AccessToken';
import {VideoGrant} from 'twilio/lib/jwt/AccessToken';
import AccessToken, {VideoGrant} from 'twilio/lib/jwt/AccessToken';
import {DataObject, repository} from '@loopback/repository';
import {ArchiveResponse, SessionResponse, VideoChatFeatures} from '../..';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ export interface TwilioVideoChat extends VideoChatInterface {
getFeatures(): VideoChatFeatures;
}

// sonarignore:start
export interface TwilioMeetingResponse extends MeetingResponse {}
// sonarignore:end

export interface TwilioS3TargetOptions extends ExternalStorageOptions {
awsS3Url: string;
bucket?: string;
}
// sonarignore:start
export interface TwilioSessonOptions extends SessionOptions {}
// sonarignore:end

export interface TwilioWebhookPayload extends WebhookPayloadParameters {
accountSid?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ export class MeetingLinkIdGeneratorProvider
implements Provider<MeetingLinkIdGenerator>
{
async value() {
return (): Promise<string> => {
return nanoid(nanoId);
};
return (): Promise<string> => nanoid(nanoId);
}
}

Expand Down

0 comments on commit 347d2f2

Please sign in to comment.