fix: address formal review findings from all 14 review-sets#115
fix: address formal review findings from all 14 review-sets#115Malcolmnixon merged 2 commits intomainfrom
Conversation
- Apply Uri.EscapeDataString to projectKey in SonarQubeClient.cs (4 locations) - Fix HttpClient resource leak in Validation.cs (ownsHttpClient false→true) - Add DirectoryNotFoundException to TemporaryDirectory.Dispose() catch - Fix requirements traceability in program.md, sonar-qube-client.md, sonar-quality-result.md Agent-Logs-Url: https://github.com/demaconsulting/SonarMark/sessions/cdc7a37d-c22b-4d98-b5e0-a898c2d9e2d8 Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses formal review findings across the ReviewMark review-sets by fixing URL encoding in SonarQube API calls, correcting a self-test HttpClient ownership/disposal issue, hardening temporary directory cleanup, and updating requirements traceability in design docs.
Changes:
- Encode
projectKeywithUri.EscapeDataStringwhen building SonarQube API URLs (multiple endpoints). - Fix
HttpClientdisposal in self-validation by settingownsHttpClient=true, and ignoreDirectoryNotFoundExceptionduring temp directory cleanup. - Adjust design-doc “Satisfies Requirements” lists to correctly reflect unit ownership/traceability.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/DemaConsulting.SonarMark/SonarIntegration/SonarQubeClient.cs | Escapes projectKey in API query strings to prevent malformed URLs for keys containing special characters. |
| src/DemaConsulting.SonarMark/SelfTest/Validation.cs | Ensures mock-created HttpClient is disposed via SonarQubeClient.Dispose(), and hardens temp directory cleanup against TOCTOU delete races. |
| docs/design/sonar-mark/sonar-integration/sonar-qube-client.md | Removes requirements that belong to other units to keep traceability accurate. |
| docs/design/sonar-mark/report-generation/sonar-quality-result.md | Removes server-fetch requirements from a data/formatting record doc to reflect correct responsibility. |
| docs/design/sonar-mark/program.md | Updates requirement mapping by removing server-fetch/validation items and adding the missing report-depth trace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot Validation.cs is getting complaints "Define a constant instead of using this literal 'application/json' 5 times." SonarQubeClient.FetchPaginatedAsync is getting "Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed." |
- Add JsonContentType constant in Validation.cs to replace 5 repeated 'application/json' literals - Extract HasMorePages helper from FetchPaginatedAsync to reduce cognitive complexity from 16 to ≤15 Agent-Logs-Url: https://github.com/demaconsulting/SonarMark/sessions/471c3d8f-8f03-4821-a918-d8a520a8fcfc Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Both addressed in commit 96265d1:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pull Request
Description
Performed formal review steps on all 14 review-sets defined in
.reviewmark.yamland fixed the issues found.High Severity
Uri.EscapeDataStringforprojectKeyinSonarQubeClient.cs(4 locations): project keys containing special characters (e.g. Maven-styleorg.example:project) would produce malformed API URLs. Fixed at lines forcomponents/show,qualitygates/project_status,issues/search, andhotspots/search— consistent with howbranchwas already handled.Medium Severity
Validation.cs: The mock factory passedownsHttpClient=false, meaning theHttpClientcreated per test was never disposed. Changed totruesoSonarQubeClient.Dispose()correctly releases it.TemporaryDirectory.Dispose()missingDirectoryNotFoundException:Directory.Delete()can throwDirectoryNotFoundException(TOCTOU race betweenExistscheck andDeletecall). Added to the exception filter alongsideIOExceptionandUnauthorizedAccessException.Code Quality
"application/json"literal inValidation.cs: Extracted into aprivate const string JsonContentTypeconstant, replacing 5 inline occurrences.FetchPaginatedAsynccognitive complexity: Extracted the paging-check logic (three ternary reads and finalif/else) into a newprivate static bool HasMorePages(JsonElement, int)helper, reducing the method's cognitive complexity from 16 to below the allowed threshold of 15.Documentation / Traceability
program.mdsatisfies-requirements section: RemovedSonarMark-Server-QualityGate,SonarMark-Server-Issues,SonarMark-Server-HotSpots(belong to SonarQubeClient unit) andSonarMark-Validation-Run(belongs to Validation unit); added missingSonarMark-Report-Depth.sonar-qube-client.mdsatisfies-requirements section: RemovedSonarMark-Server-Connect,SonarMark-Server-Auth,SonarMark-Server-ProjectKey,SonarMark-Server-Branch(all belong to the Program unit perunit-program.yaml).sonar-quality-result.mdsatisfies-requirements section: RemovedSonarMark-Server-QualityGate,SonarMark-Server-Issues,SonarMark-Server-HotSpots(belong to SonarQubeClient unit;SonarQualityResultholds the data but does not fetch it).Type of Change
Related Issues
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
dotnet build --configuration Releasedotnet test --configuration Releasedotnet run --project src/DemaConsulting.SonarMark --configuration Release --framework net10.0--no-build -- --validateCode Quality
dotnet format --verify-no-changesLinting
./lint.sh(Unix/macOS) orcmd /c lint.bat/./lint.bat(Windows)Testing
Documentation
Additional Notes
Formal review was performed by invoking the
code-reviewagent separately on each of the 14 review-sets defined in.reviewmark.yamlto avoid context collisions between reviews.