Skip to content

Commit 3b42d44

Browse files
refactor(all-services): fix sonarqube issues (#2358)
* refactor(all-services): fix sonarqube issues GH-2356 * refactor(all-services): fix sonarqube issues GH-2356
1 parent 937f2db commit 3b42d44

File tree

19 files changed

+172
-182
lines changed

19 files changed

+172
-182
lines changed

packages/ocr-parser/projects/ocr-parser-lib/src/lib/ocr-parser/directives/text-select.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
OnDestroy,
1010
OnInit,
1111
NgZone,
12+
Output,
1213
} from '@angular/core';
1314
export interface TextSelectEvent {
1415
text: string;
@@ -23,10 +24,9 @@ export interface SelectionRectangle {
2324
}
2425
@Directive({
2526
selector: '[textSelect]',
26-
outputs: ['textSelectEvent: textSelect'],
2727
})
2828
export class TextSelectDirective implements OnInit, OnDestroy {
29-
public textSelectEvent: EventEmitter<TextSelectEvent>;
29+
@Output('textSelect') textSelectEvent = new EventEmitter<TextSelectEvent>();
3030
private readonly elementRef: ElementRef;
3131
private hasSelection: boolean;
3232
private readonly zone: NgZone;

sandbox/auth-multitenant-example/src/providers/casbin-authorization-action.provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export class CasbinAuthorizationProvider
9696
desiredPermissions: string[],
9797
enforcer: casbin.Enforcer,
9898
subject: string,
99-
authDecision: boolean,
99+
authDecision = false,
100100
) {
101-
let decision = authDecision ?? false;
101+
let decision = authDecision;
102102
for (const resourceId of resourceIds) {
103103
for (const permission of desiredPermissions) {
104104
decision = await enforcer.enforce(subject, permission, resourceId);

sandbox/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ CURRENT_DIR=$2
44

55
# TODO: remove sudo once build agent is fixed
66

7-
if [ -z "$REGISTRY" ]; then
7+
if [[ -z "$REGISTRY" ]]; then
88
REGISTRY="localhost:32000"
99
echo "${REGISTRY}"
1010
else
1111
echo "${REGISTRY}"
1212
fi
1313

14-
if [ ! -z "${DOCKER_USERNAME}" ] && [ ! -z "${DOCKER_PASSWORD}" ]; then
14+
if [[ ! -z "${DOCKER_USERNAME}" ]] && [[ ! -z "${DOCKER_PASSWORD}" ]]; then
1515
echo "Logging in to Docker"
1616
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
1717
fi
1818

19-
if [ -z "$CURRENT_DIR" ]; then
19+
if [[ -z "$CURRENT_DIR" ]]; then
2020
CURRENT_DIR=$(echo $PWD)
2121
fi
2222

sandbox/ci_build.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ install_kubectl() {
1111
sudo apt-get update -y
1212
sudo apt-get install -y kubectl
1313
kubectl cluster-info
14+
return 0
1415
}
1516

1617
install_microk8s() {
@@ -22,6 +23,7 @@ install_microk8s() {
2223
mkdir -p .kube
2324
microk8s config >.kube/config
2425
popd
26+
return 0
2527
}
2628

2729
local_docker_push() {
@@ -35,7 +37,7 @@ local_docker_push() {
3537
docker push ${LOCAL_REGISTRY}/search-ms-example
3638
docker push ${LOCAL_REGISTRY}/chat-notification-pubnub-example
3739
docker push ${LOCAL_REGISTRY}/feature-toggle-example
38-
40+
return 0
3941
}
4042

4143
docker_push() {
@@ -60,7 +62,7 @@ docker_push() {
6062
docker push ${DOCKER_USERNAME}/search-ms-example
6163
docker push ${DOCKER_USERNAME}/chat-notification-pubnub-example
6264
docker push ${DOCKER_USERNAME}/feature-toggle-example
63-
65+
return 0
6466
# TODO: should we clean up after build? Since agent is ephemeral, some caching may be helpful after an initial run
6567
# TODO: remove specific images and cache
6668
# docker system prune -a -f
@@ -71,26 +73,29 @@ terraform_apply() {
7173
terraform init
7274
terraform apply -auto-approve
7375
popd
76+
return 0
7477
}
7578

7679
terraform_destroy() {
7780
pushd ${CURRENT_DIR}/k8s/tf-sourceloop-sandbox
7881
terraform destroy -auto-approve
7982
popd
83+
return 0
8084
}
8185

8286
run_tests() {
8387
echo "Sleeping to wait for services to come online."
8488
sleep 180
8589
${CURRENT_DIR}/health_check.sh sourceloop.local true
90+
return 0
8691
}
8792

88-
if [ ! -z "${DOCKER_USERNAME}" ] && [ ! -z "${DOCKER_PASSWORD}" ]; then
93+
if [[ ! -z "${DOCKER_USERNAME}" ]] && [[ ! -z "${DOCKER_PASSWORD}" ]]; then
8994
echo "Logging in to Docker"
9095
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
9196
fi
9297

93-
if [ -z "$CURRENT_DIR" ]; then
98+
if [[ -z "$CURRENT_DIR" ]]; then
9499
CURRENT_DIR=$(echo $PWD)
95100
fi
96101

@@ -101,7 +106,7 @@ sudo chmod +x ${CURRENT_DIR}/docker-compose
101106

102107
sudo REGISTRY=$LOCAL_REGISTRY ./docker-compose -f "${CURRENT_DIR}/docker-compose.yml" build
103108

104-
if [ "${INSTALL_MICROK8S}" = "true" ]; then
109+
if [[ "${INSTALL_MICROK8S}" = "true" ]]; then
105110
install_microk8s
106111
install_kubectl
107112
fi

sandbox/health_check.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ IS_LOCALHOST=$2
44
ERROR_COUNT=0
55

66
# check the basic health check on its own
7-
if [ "$IS_LOCALHOST" = "true" ]; then
7+
if [[ "$IS_LOCALHOST" = "true" ]]; then
88
curl_response=$(curl -Is -H "Host: health-check.${DOMAIN}" https://localhost --insecure -f)
99
else
1010
curl_response=$(curl -Is -H "Host: health-check.${DOMAIN}" https://health-check.${DOMAIN} --insecure -f)
1111
fi
1212

13-
if [ -z "$curl_response" ]; then
13+
if [[ -z "$curl_response" ]]; then
1414
echo "health-check service is unhealthy"
1515
ERROR_COUNT=$((ERROR_COUNT + 1))
1616
fi
@@ -19,13 +19,13 @@ fi
1919
declare -a services=("workflow" "scheduler" "notification" "in-mail" "auth" "audit")
2020

2121
for service in "${services[@]}"; do
22-
if [ "$IS_LOCALHOST" = "true" ]; then
22+
if [[ "$IS_LOCALHOST" = "true" ]]; then
2323
curl_response=$(curl -Is -H "Host: ${service}.${DOMAIN}" https://localhost/openapi.json --insecure -f)
2424
else
2525
curl_response=$(curl -Is -H "Host: ${service}.${DOMAIN}" https://${service}.${DOMAIN}/openapi.json --insecure -f)
2626
fi
2727

28-
if [ -z "$curl_response" ]; then
28+
if [[ -z "$curl_response" ]]; then
2929
echo "${service} service is unhealthy"
3030
ERROR_COUNT=$((ERROR_COUNT + 1))
3131
fi

sandbox/telemed-app/backend/authentication-service/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let secret: SecretEnv;
2121

2222
export async function getSecretValue() {
2323
let response;
24-
// eslint-disable-next-line
24+
// eslint-disable-next-line no-useless-catch
2525
try {
2626
response = await client.send(
2727
new GetSecretValueCommand({

sandbox/telemed-app/backend/notification-service/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let secret: SecretEnv;
2121

2222
export async function getSecretValue() {
2323
let response;
24-
// eslint-disable-next-line
24+
// eslint-disable-next-line no-useless-catch
2525
try {
2626
response = await client.send(
2727
new GetSecretValueCommand({

sandbox/telemed-app/backend/video-conferencing-service/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let secret: SecretEnv;
2121

2222
export async function getSecretValue() {
2323
let response;
24-
// eslint-disable-next-line
24+
// eslint-disable-next-line no-useless-catch
2525
try {
2626
response = await client.send(
2727
new GetSecretValueCommand({

services/authentication-service/src/__tests__/unit/bearer-verify.provider.unit.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,25 @@ import {expect} from '@loopback/testlab';
66
import {JwtKeysRepository} from '@sourceloop/core';
77
import sinon from 'sinon';
88
import {SignupBearerVerifyProvider} from '../../providers';
9+
function log() {
10+
// This is intentional
11+
}
912

13+
function info() {
14+
// This is intentional
15+
}
16+
17+
function warn() {
18+
// This is intentional
19+
}
20+
21+
function error() {
22+
// This is intentional
23+
}
24+
25+
function debug() {
26+
// This is intentional
27+
}
1028
describe('Bearer Verify Signup Service', () => {
1129
let bearerVerifyProvider: SignupBearerVerifyProvider;
1230
let jwtKeysRepo: JwtKeysRepository;
@@ -37,26 +55,6 @@ describe('Bearer Verify Signup Service', () => {
3755
});
3856
});
3957

40-
function log() {
41-
// This is intentional
42-
}
43-
44-
function info() {
45-
// This is intentional
46-
}
47-
48-
function warn() {
49-
// This is intentional
50-
}
51-
52-
function error() {
53-
// This is intentional
54-
}
55-
56-
function debug() {
57-
// This is intentional
58-
}
59-
6058
function setUp() {
6159
jwtKeysRepo = sinon.createStubInstance(JwtKeysRepository); // Mock the repository
6260
bearerVerifyProvider = new SignupBearerVerifyProvider(jwtKeysRepo, logger);

services/authentication-service/src/__tests__/unit/jwt-payload.provider.unit.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,25 @@ import {
1717
UserLevelPermissionRepository,
1818
UserTenantRepository,
1919
} from '../../repositories';
20+
function log() {
21+
// This is intentional
22+
}
2023

24+
function info() {
25+
// This is intentional
26+
}
27+
28+
function warn() {
29+
// This is intentional
30+
}
31+
32+
function error() {
33+
// This is intentional
34+
}
35+
36+
function debug() {
37+
// This is intentional
38+
}
2139
describe('JWT Payload Provider', () => {
2240
let roleRepo: StubbedInstanceWithSinonAccessor<RoleRepository>;
2341
let userLevelPermissionRepo: StubbedInstanceWithSinonAccessor<UserLevelPermissionRepository>;
@@ -68,26 +86,6 @@ describe('JWT Payload Provider', () => {
6886
});
6987
});
7088

71-
function log() {
72-
// This is intentional
73-
}
74-
75-
function info() {
76-
// This is intentional
77-
}
78-
79-
function warn() {
80-
// This is intentional
81-
}
82-
83-
function error() {
84-
// This is intentional
85-
}
86-
87-
function debug() {
88-
// This is intentional
89-
}
90-
9189
function setUp() {
9290
roleRepo = createStubInstance(RoleRepository);
9391
userLevelPermissionRepo = createStubInstance(UserLevelPermissionRepository);

0 commit comments

Comments
 (0)