Skip to content

Commit 8d6e1ae

Browse files
committed
fixed sonar cloud issue
1 parent 46dd1f3 commit 8d6e1ae

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ jobs:
7878
pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90 python-stdnum==1.20
7979
poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
8080
poetry run coverage xml -o sonarcloud-coverage.xml
81+
82+
- name: Run unittest with coverage-mesh-processor
83+
id: meshprocessor
84+
continue-on-error: true
85+
run: |
86+
pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90 python-stdnum==1.20
87+
poetry run coverage run --source=meshfileprocessor -m unittest discover -s meshfileprocessor || echo "meshfileprocessor tests failed" >> failed_tests.txt
88+
poetry run coverage xml -o sonarcloud-meshfileprocessor-coverage.xml
8189
8290
- name: Run Test Failure Summary
8391
id: check_failure

meshfileprocessor/tests/test_converter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from unittest import TestCase
22
from unittest.mock import patch, MagicMock
3-
import os
43
from src.converter import lambda_handler, ensure_dat_extension
54

65

recordprocessor/src/utils_for_recordprocessor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_csv_content_dict_reader(file_key: str) -> DictReader:
2222
csv_data = response["Body"].read().decode("utf-8")
2323

2424
# Verify and process the DAT file content coming from MESH
25-
if '.dat' in file_key:
25+
if ".dat" in file_key:
2626
csv_data = extract_content(csv_data)
2727
return DictReader(StringIO(csv_data), delimiter="|"), csv_data
2828

@@ -50,16 +50,16 @@ def invoke_filename_lambda(file_key: str, message_id: str) -> None:
5050

5151
def extract_content(dat_file_content):
5252

53-
boundary_pattern = re.compile(r'----------------------------\d+')
53+
boundary_pattern = re.compile(r"----------------------------\d+")
5454

5555
parts = boundary_pattern.split(dat_file_content)
5656

5757
# Extract the content between the boundaries
5858
filecontent = None
5959
for part in parts:
60-
if 'Content-Disposition' in part and 'Content-Type' in part:
60+
if "Content-Disposition" in part and "Content-Type" in part:
6161

62-
content_start = part.index('Content-Type') + len('Content-Type: text/csv') + 2
62+
content_start = part.index("Content-Type") + len("Content-Type: text/csv") + 2
6363
filecontent = part[content_start:].strip()
6464
break
6565

recordprocessor/tests/test_utils_for_recordprocessor.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
from tests.utils_for_recordprocessor_tests.mock_environment_variables import MOCK_ENVIRONMENT_DICT, BucketNames
1616

1717
with patch("os.environ", MOCK_ENVIRONMENT_DICT):
18-
from utils_for_recordprocessor import get_environment, get_csv_content_dict_reader, create_diagnostics_dictionary, extract_content
18+
from utils_for_recordprocessor import (
19+
get_environment,
20+
get_csv_content_dict_reader,
21+
create_diagnostics_dictionary,
22+
extract_content,
23+
)
1924
from file_level_validation import move_file
2025

2126
s3_client = boto3.client("s3", region_name=REGION_NAME)
@@ -79,10 +84,11 @@ def test_create_diagnostics_dictionary(self):
7984
def test_extract_content_valid_input(self):
8085
dat_file_content = (
8186
"----------------------------1234567890\n"
82-
"Content-Disposition: form-data; name=\"file\"; filename=\"COVID19_Vaccinations_v5_YGM41_20250312T113455981.csv\"\n"
87+
'Content-Disposition: form-data; name="file"; filename="COVID19_Vaccinations_v5_YGM41_20250312T113455981.csv"\n'
8388
"Content-Type: text/csv\n\n"
8489
"NHS_NUMBER|PERSON_FORENAME|PERSON_SURNAME|PERSON_DOB|PERSON_GENDER_CODE|PERSON_POSTCODE\n"
85-
"----------------------------1234567890\n")
90+
"----------------------------1234567890\n"
91+
)
8692
expected_content = "NHS_NUMBER|PERSON_FORENAME|PERSON_SURNAME|PERSON_DOB|PERSON_GENDER_CODE|PERSON_POSTCODE"
8793
result = extract_content(dat_file_content)
8894
self.assertEqual(result, expected_content)

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sonar.organization=nhsdigital
44
sonar.host.url=https://sonarcloud.io
55
sonar.python.version=3.11
66
sonar.exclusions=**/e2e/**,**/e2e_batch/**,**/temporary_sandbox/**,**/devtools/**,**/proxies/**,**/scripts/**,**/terraform/**,**/tests/**
7-
sonar.python.coverage.reportPaths=sonarcloud-coverage.xml,sonarcloud-coverage-delta.xml,sonarcloud-coverage-ack-lambda.xml,sonarcloud-coverage-filenameprocessor-coverage.xml,sonarcloud-coverage-recordforwarder-coverage.xml,sonarcloud-coverage-recordprocessor-coverage.xml
7+
sonar.python.coverage.reportPaths=sonarcloud-coverage.xml,sonarcloud-coverage-delta.xml,sonarcloud-coverage-ack-lambda.xml,sonarcloud-coverage-filenameprocessor-coverage.xml,sonarcloud-coverage-recordforwarder-coverage.xml,sonarcloud-coverage-recordprocessor-coverage.xml,sonarcloud-meshfileprocessor-coverage.xml
88
sonar.issue.ignore.multicriteria=exclude_snomed_urls,exclude_hl7_urls
99
sonar.issue.ignore.multicriteria.exclude_snomed_urls.ruleKey=python:S5332
1010
sonar.issue.ignore.multicriteria.exclude_snomed_urls.resourceKey=**http://snomed\.info/sct**

0 commit comments

Comments
 (0)