registry: fix code quality issues flagged by sonarqube static analysis#319
Open
iamabhilaksh wants to merge 2 commits intosalesforce:mainfrom
Open
registry: fix code quality issues flagged by sonarqube static analysis#319iamabhilaksh wants to merge 2 commits intosalesforce:mainfrom
iamabhilaksh wants to merge 2 commits intosalesforce:mainfrom
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (77.77%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #319 +/- ##
============================================
- Coverage 82.36% 82.33% -0.04%
- Complexity 625 626 +1
============================================
Files 191 191
Lines 11503 11504 +1
Branches 1525 1521 -4
============================================
- Hits 9475 9472 -3
- Misses 1357 1361 +4
Partials 671 671
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
SriramGuduri
reviewed
Mar 4, 2026
...istry-client/src/main/java/com/salesforce/multicloudj/registry/driver/OciRegistryClient.java
Outdated
Show resolved
Hide resolved
- AbstractRegistry: remove redundant abstract method declarations already defined in AuthProvider interface - BearerTokenExchange: extract nested try block into executeTokenRequest(); define constants TOKEN_FIELD and ACCESS_TOKEN_FIELD - LayerExtractor: close PipedOutputStream in finally clause if executor submission fails; merge duplicate continue statements into one condition - OciRegistryClient: define MANIFEST_ERROR_FORMAT constant; extract fetchManifest nested try into executeFetchManifestRequest() and computeManifestDigest(); simplify nested ifs using mapHttpStatusToException - OciRegistryClientTest: replace hardcoded Base64 token with dynamic encoding to avoid credential scanning false positives Made-with: Cursor
46b8629 to
8e779c4
Compare
- OciRegistryClient: add back manifest size limit, digest validation, and Docker-Content-Digest fallback comments in extracted methods - BearerTokenExchange: rephrase split token field comment into single line
SriramGuduri
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
registry: fix code quality issues flagged by sonarqube static analysis
Summary
Fixes code quality issues in the registry module flagged by static analysis tools. The changes
reduce code duplication, improve resource safety, clarify intent through inline comments, and
eliminate a credential-scanning false positive in tests. No functional behaviour is changed.
Changes
Modified Files
AbstractRegistry.java— Remove redundant abstract method declarations (6 lines removed)getAuthUsername()andgetAuthToken()were re-declared with@OverrideonAbstractRegistrybut are already defined on the
AuthProviderinterface it implements; the duplicate declarationsare removed
BearerTokenExchange.java— Reduce nesting, add constants, fix comment (72 lines changed)TOKEN_FIELD = "token"andACCESS_TOKEN_FIELD = "access_token"constants to eliminatemagic strings referenced in multiple places
try (CloseableHttpResponse ...)block into a privateexecuteTokenRequest()method, removing one level of nesting from
getBearerToken()// Token can be in ... (GCP Artifact Registry) \n// field— rewordedinto a single line within the 100-char checkstyle limit:
// Token field is "token" (Docker Hub, AWS ECR) or "access_token" (GCP Artifact Registry)LayerExtractor.java— Improve executor error handling and merge duplicate conditions(70 lines changed)
executor.submit(...)in atry-catchblock that closesPipedOutputStreamandthrows
UnknownExceptionif submission fails, preventing the caller from blocking indefinitelyon a pipe that will never be written to
if (...) continue;checks into a single combined condition with||,eliminating the duplicate
continuestatement flagged by static analysisOciRegistryClient.java— Extract methods, add constant, restore comments (134 lines changed)MANIFEST_ERROR_FORMATconstant to avoid repeating the identicalString.formattemplateacross the three HTTP-error branches (404, 401, default)
fetchManifest()internals into:buildFetchManifestRequest()— builds theHttpGetwith auth and Accept headersexecuteFetchManifestRequest()— executes, checks status, enforces size limit, and parsescomputeManifestDigest()— returns theDocker-Content-Digestheader value or computesSHA-256 from the response body when the header is absent (e.g. AWS ECR)
if (reference.startsWith(DIGEST_PREFIX)) { if (!reference.equals(...)) }into a single combined condition
// Check manifest size limit to prevent resource exhaustion// Validate digest if fetching by digest reference (e.g., repo@sha256:...)// Docker-Content-Digest header may be absent (e.g., AWS ECR); calculate from response bodymapHttpStatusToException()helperinstead of repeating the if/else chain
OciRegistryClientTest.java— Replace hardcoded Base64 credential with dynamic encoding(6 lines changed)
"Basic dXNlcjp0b2tlbg=="was a hardcoded Base64-encoded credential triggering secret-scanningfalse positives; replaced with
"Basic " + Base64.getEncoder().encodeToString(...)so thevalue is computed at runtime
Testing Details
Unit Tests (136/136 passed)
References
used to cross-verify manifest size limit (100 MB), digest validation behaviour, and the
Docker-Content-Digestfallback pattern