Skip to content

Commit

Permalink
Fix: [AEA-4159] - Resolve sonar issues (#449)
Browse files Browse the repository at this point in the history
## Summary

- Routine Change

### Details

Just going down the sonar issues, and resolving them.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
wildjames and dependabot[bot] authored Sep 3, 2024
1 parent 51fff1c commit ca8c51b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion SAMtemplates/main_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Resources:
AccessToSpine: "true"
LogRetentionDays: !Ref LogRetentionDays
StatusLambda:
Type: AWS::Serverless::Function
Type: AWS::Serverless::Function # NOSONAR - The scan complains that this has no log group, but it's defined in the lambda resources above.
Properties:
FunctionName: !Sub "${AWS::StackName}-statusLambda"
CodeUri: ../packages
Expand Down
4 changes: 2 additions & 2 deletions SAMtemplates/sandbox_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Resources:
LambdaName: !Sub "${AWS::StackName}-Sandbox"
LogRetentionDays: !Ref LogRetentionDays
Sandbox:
Type: AWS::Serverless::Function
Type: AWS::Serverless::Function # NOSONAR - The scan complains that this has no log group, but it's defined in the lambda resources above.
Properties:
FunctionName: !Sub "${AWS::StackName}-Sandbox"
CodeUri: ../packages
Expand Down Expand Up @@ -134,7 +134,7 @@ Resources:
LambdaName: !Sub "${AWS::StackName}-statusLambda"
LogRetentionDays: !Ref LogRetentionDays
StatusLambda:
Type: AWS::Serverless::Function
Type: AWS::Serverless::Function # NOSONAR - The scan complains that this has no log group, but it's defined in the lambda resources above.
Properties:
FunctionName: !Sub "${AWS::StackName}-statusLambda"
CodeUri: ../packages
Expand Down
8 changes: 6 additions & 2 deletions packages/sandbox/tests/test-handler.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {APIGatewayProxyEvent, APIGatewayProxyResult} from "aws-lambda"
import {handler} from "../src/sandbox"
import {expect, describe, it} from "@jest/globals"
import {helloworldContext} from "@clinicaltracker_common/testing"
import successData from "../examples/GetMyPrescriptions/Bundle/success.json"
import {mockAPIGatewayProxyEvent, test_append_trace_ids, test_mime_type} from "@clinicaltracker_common/testing"
import {
mockAPIGatewayProxyEvent,
test_append_trace_ids,
test_mime_type,
helloworldContext
} from "@clinicaltracker_common/testing"

const dummyContext = helloworldContext
const mockEvent: APIGatewayProxyEvent = mockAPIGatewayProxyEvent
Expand Down
17 changes: 8 additions & 9 deletions packages/statusLambda/tests/test-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {
describe,
it
} from "@jest/globals"
import {helloworldContext} from "@clinicaltracker_common/testing"
import {Logger} from "@aws-lambda-powertools/logger"
import MockAdapter from "axios-mock-adapter"
import axios from "axios"
import {mockAPIGatewayProxyEvent} from "@clinicaltracker_common/testing"
import {mockAPIGatewayProxyEvent, helloworldContext} from "@clinicaltracker_common/testing"

const mock = new MockAdapter(axios)

Expand All @@ -30,7 +29,7 @@ describe("Unit test for status check", function () {
const result: APIGatewayProxyResult = (await handler(
mockAPIGatewayProxyEvent,
dummyContext
)) as APIGatewayProxyResult
))

expect(result.statusCode).toEqual(200)
expect(JSON.parse(result.body)).toMatchObject({
Expand All @@ -45,7 +44,7 @@ describe("Unit test for status check", function () {
const result: APIGatewayProxyResult = (await handler(
mockAPIGatewayProxyEvent,
dummyContext
)) as APIGatewayProxyResult
))

expect(result.statusCode).toEqual(200)
expect(JSON.parse(result.body)).toMatchObject({
Expand Down Expand Up @@ -74,7 +73,7 @@ describe("Unit test for status check", function () {
const result: APIGatewayProxyResult = (await handler(
mockAPIGatewayProxyEvent,
dummyContext
)) as APIGatewayProxyResult
))

const headers = result.headers

Expand Down Expand Up @@ -103,7 +102,7 @@ describe("Unit test for status check", function () {
const result: APIGatewayProxyResult = (await handler(
mockAPIGatewayProxyEvent,
dummyContext
)) as APIGatewayProxyResult
))

expect(result.statusCode).toEqual(200)
const result_body = JSON.parse(result.body)
Expand All @@ -120,7 +119,7 @@ describe("Unit test for status check", function () {
const result: APIGatewayProxyResult = (await handler(
mockAPIGatewayProxyEvent,
dummyContext
)) as APIGatewayProxyResult
))

expect(result.statusCode).toEqual(200)
const result_body = JSON.parse(result.body)
Expand All @@ -137,7 +136,7 @@ describe("Unit test for status check", function () {
const result: APIGatewayProxyResult = (await handler(
mockAPIGatewayProxyEvent,
dummyContext
)) as APIGatewayProxyResult
))

expect(result.statusCode).toEqual(200)
const result_body = JSON.parse(result.body)
Expand All @@ -154,7 +153,7 @@ describe("Unit test for status check", function () {
const result: APIGatewayProxyResult = (await handler(
mockAPIGatewayProxyEvent,
dummyContext
)) as APIGatewayProxyResult
))

expect(result.statusCode).toEqual(200)
const result_body = JSON.parse(result.body)
Expand Down
3 changes: 2 additions & 1 deletion scripts/calculate_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def calculate_version(base_major=1, base_minor=0, base_revision=0, base_pre="alp
"""Calculates a semver based on commit history and special flags in commit messages"""
major = base_major
minor = base_minor
patch = base_revision
# Unused variable
# patch = base_revision
pre = base_pre

commits = get_versionable_commits(REPO)
Expand Down
11 changes: 10 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ sonar.organization=nhsdigital
sonar.projectKey=NHSDigital_electronic-prescription-service-clinical-prescription-tracker
sonar.host.url=https://sonarcloud.io

sonar.coverage.exclusions=**/*.test.*, \
sonar.coverage.exclusions=**/*.test.*,\
**/tests/*,\
**/jest.config.ts,scripts/*, \
packages/common/testing/*, \
eslint.config.mjs

sonar.cpd.exclusions=**/*.test.*,\
**/tests/*,\
**/jest.config.ts,scripts/*, \
packages/common/testing/*, \
eslint.config.mjs

sonar.javascript.lcov.reportPaths=packages/sandbox/coverage/lcov.info, \
packages/statusLambda/coverage/lcov.info

sonar.python.version=3.10

0 comments on commit ca8c51b

Please sign in to comment.