Fix SonarCloud violations in Xray Cloud support#6651
Conversation
Qodana for JVM5 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
| { | ||
| @Bean | ||
| @ConditionalOnProperty(name = "xray-exporter.cloud.enabled", havingValue = "false", matchIfMissing = true) | ||
| public XrayClient xrayServerClient(JiraClientProvider jiraClientProvider, |
| xray-exporter.test-case-updates-enabled=true | ||
| xray-exporter.test-execution.attachments= | ||
| xray-exporter.test-case.use-scenario-title-as-description=false | ||
| xray-exporter.cloud.enabled=false |
| xray-exporter.test-execution.attachments= | ||
| xray-exporter.test-case.use-scenario-title-as-description=false | ||
| xray-exporter.cloud.enabled=false | ||
| xray-exporter.cloud.client-id= |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6651 +/- ##
============================================
+ Coverage 97.79% 97.80% +0.01%
- Complexity 7325 7362 +37
============================================
Files 1015 1018 +3
Lines 21508 21640 +132
Branches 1416 1428 +12
============================================
+ Hits 21033 21165 +132
+ Misses 359 357 -2
- Partials 116 118 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Addresses several SonarCloud/QDJVM violations introduced by the recent Xray Cloud support work and improves test coverage. Changes are concentrated in the vividus-to-xray-exporter module and adjust the Spring wiring and configuration metadata so that QDJVM and SonarCloud no longer flag generated/conditional beans and configuration properties.
Changes:
- Replace
Optional<String> jiraInstanceKeyfield/parameter with@Nullable StringinXrayFacadeandXrayServerClient; normalize empty strings tonull. - Add
@Lazyto theJiraClientProviderparameter inXrayClientConfigurationand commitMETA-INF/additional-spring-configuration-metadata.json(replacing the annotation-processor approach) to silence QDJVM warnings. - Add new tests (
XrayServerClientTests,XrayClientConfigurationTests, extraXrayCloudClientTests/XrayFacadeTests/XrayExporterOptionsValidatorTestscases) covering the affected branches.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayFacade.java | Switches jiraInstanceKey to @Nullable String; converts to Optional only at the JiraFacade.createIssue call site. |
| vividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayServerClient.java | Same @Nullable String change applied to the server client constructor. |
| vividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayCloudClient.java | Unchanged behavior; covered by additional tests. |
| vividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayClient.java | Interface (context). |
| vividus-to-xray-exporter/src/main/java/org/vividus/xray/configuration/XrayClientConfiguration.java | Adds @Lazy to the JiraClientProvider parameter to avoid QDJVM autowire warnings. |
| vividus-to-xray-exporter/src/main/java/org/vividus/xray/configuration/XrayExporterOptions.java | Existing cloud options (context). |
| vividus-to-xray-exporter/src/main/java/org/vividus/xray/configuration/validator/XrayExporterOptionsValidator.java | Cloud credential and attachment validation (context). |
| vividus-to-xray-exporter/src/main/resources/META-INF/additional-spring-configuration-metadata.json | New committed metadata for the four xray-exporter.cloud.* properties. |
| vividus-to-xray-exporter/src/main/resources/application.properties | Default cloud property values (context). |
| vividus-to-xray-exporter/build.gradle | Adds vividus-http-client dependency. |
| docs/modules/integrations/pages/xray-exporter.adoc | Cloud configuration docs (context). |
| vividus-to-xray-exporter/src/test/java/org/vividus/xray/facade/XrayFacadeTests.java | Updates constructor calls for the @Nullable change; adds test for non-null Jira instance key path. |
| vividus-to-xray-exporter/src/test/java/org/vividus/xray/facade/XrayServerClientTests.java | New test class for the server client. |
| vividus-to-xray-exporter/src/test/java/org/vividus/xray/facade/XrayCloudClientTests.java | Adds informational 1xx response test (and other coverage). |
| vividus-to-xray-exporter/src/test/java/org/vividus/xray/configuration/XrayClientConfigurationTests.java | New tests for the bean factory configuration. |
| vividus-to-xray-exporter/src/test/java/org/vividus/xray/configuration/validator/XrayExporterOptionsValidatorTests.java | Adds cloud credential and IO failure test cases. |
| vividus-to-xray-exporter/src/test/java/org/vividus/xray/integration/VividusToXrayExporterIntegrationTests.java | Verifies the default XrayServerClient bean is selected. |
| gradle/wrapper/gradle-wrapper.properties | Description says removed, diff shows added — see comment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR adds cloud API support to the Xray exporter module by introducing a pluggable ChangesXray Cloud Integration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (1)
gradle/wrapper/gradle-wrapper.properties (1)
1-9:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRemove committed Gradle wrapper properties file to match PR intent.
This file’s presence conflicts with the stated objective (“remove committed Gradle wrapper files”) and earlier review feedback; please delete it from this PR.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@gradle/wrapper/gradle-wrapper.properties` around lines 1 - 9, The gradle wrapper properties (entries like distributionBase, distributionUrl, distributionPath, zipStorePath) was committed despite the PR intent to remove Gradle wrapper files; delete this file from the commit and repository (remove gradle/wrapper/gradle-wrapper.properties from the index and commit the removal), and update .gitignore if needed to prevent re-adding wrapper files in future so the PR no longer contains distributionUrl/distributionBase entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@vividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayCloudClient.java`:
- Around line 205-207: The code in XrayCloudClient currently trims quotes via
tokenJson.substring(1, tokenJson.length() - 1), which is brittle; instead parse
the body as a JSON string (e.g., use your project JSON utility or Jackson
ObjectMapper.readValue(response.getResponseBodyAsString(), String.class)) to
correctly handle quoted/escaped tokens and empty/null bodies, validate the
result is non-empty and on failure throw an IOException with a clear message;
update the logic around response.getResponseBodyAsString() and the tokenJson
variable and remove the substring usage so token handling in XrayCloudClient is
robust.
In
`@vividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayFacade.java`:
- Line 37: Replace the deprecated Spring Nullable import in XrayFacade by
swapping the import line: remove import org.springframework.lang.Nullable and
add import org.jspecify.annotations.Nullable, then ensure any `@Nullable`
annotations in the XrayFacade class remain unchanged (they will now reference
the JSpecify annotation); this aligns XrayFacade.java with the other files and
removes the Spring deprecation finding.
In
`@vividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayServerClient.java`:
- Around line 38-44: The jiraInstanceKey empty-string handling should also
normalize whitespace-only values; update the normalization so blank strings
become null. For example, in the XrayServerClient constructor (and/or where
XrayClientConfiguration.xrayServerClient creates the instance) replace the
current isEmpty-based logic with a trim/isBlank check and store a normalized
value (e.g., this.jiraInstanceKey = (jiraInstanceKey == null ||
jiraInstanceKey.isBlank()) ? null : jiraInstanceKey.trim()); this ensures
Optional.ofNullable(jiraInstanceKey) in importExecution yields Optional.empty()
for blank inputs as well.
In
`@vividus-to-xray-exporter/src/test/java/org/vividus/xray/configuration/XrayClientConfigurationTests.java`:
- Around line 43-47: The test constructs XrayExporterOptions.CloudOptions
without setting apiBaseUrl which causes a NPE when XrayCloudClient's constructor
calls apiBaseUrl.endsWith("/"); fix the test by calling cloud.setApiBaseUrl(...)
with a valid base URL (e.g., "https://xray.cloud.getxray.app") on the
XrayExporterOptions.CloudOptions instance before options.setCloudOptions(cloud)
so that xrayCloudClient() can construct XrayCloudClient without null API base.
---
Duplicate comments:
In `@gradle/wrapper/gradle-wrapper.properties`:
- Around line 1-9: The gradle wrapper properties (entries like distributionBase,
distributionUrl, distributionPath, zipStorePath) was committed despite the PR
intent to remove Gradle wrapper files; delete this file from the commit and
repository (remove gradle/wrapper/gradle-wrapper.properties from the index and
commit the removal), and update .gitignore if needed to prevent re-adding
wrapper files in future so the PR no longer contains
distributionUrl/distributionBase entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2be5ee0a-4bc1-4741-af46-a738b04678ee
⛔ Files ignored due to path filters (1)
gradle/wrapper/gradle-wrapper.jaris excluded by!**/*.jar
📒 Files selected for processing (18)
docs/modules/integrations/pages/xray-exporter.adocgradle/wrapper/gradle-wrapper.propertiesvividus-to-xray-exporter/build.gradlevividus-to-xray-exporter/src/main/java/org/vividus/xray/configuration/XrayClientConfiguration.javavividus-to-xray-exporter/src/main/java/org/vividus/xray/configuration/XrayExporterOptions.javavividus-to-xray-exporter/src/main/java/org/vividus/xray/configuration/validator/XrayExporterOptionsValidator.javavividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayClient.javavividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayCloudClient.javavividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayFacade.javavividus-to-xray-exporter/src/main/java/org/vividus/xray/facade/XrayServerClient.javavividus-to-xray-exporter/src/main/resources/META-INF/additional-spring-configuration-metadata.jsonvividus-to-xray-exporter/src/main/resources/application.propertiesvividus-to-xray-exporter/src/test/java/org/vividus/xray/configuration/XrayClientConfigurationTests.javavividus-to-xray-exporter/src/test/java/org/vividus/xray/configuration/validator/XrayExporterOptionsValidatorTests.javavividus-to-xray-exporter/src/test/java/org/vividus/xray/facade/XrayCloudClientTests.javavividus-to-xray-exporter/src/test/java/org/vividus/xray/facade/XrayFacadeTests.javavividus-to-xray-exporter/src/test/java/org/vividus/xray/facade/XrayServerClientTests.javavividus-to-xray-exporter/src/test/java/org/vividus/xray/integration/VividusToXrayExporterIntegrationTests.java
- Extract string constants in XrayCloudClient for duplicate literals (/import/execution, /graphql, COMMA_SEPARATOR, DOUBLE_QUOTE) - Reduce NPath complexity in XrayExporterOptionsValidator by extracting validateAttachment() and validateCloudOptions() private methods - Fix XrayCloudClientTests: extract path/string constants, replace catch (Exception) with catch (URISyntaxException) - Fix XrayExporterOptionsValidatorTests: extract CLIENT_ID/CLIENT_SECRET constants - Fix VividusToXrayExporterIntegrationTests: correct import lexicographic order - Fix XrayServerClientTests: shorten long line, extract CONFIG_ERROR constant
…loudClient, update default API URL
…onfiguration-processor
- Remove gradle/wrapper/gradle-wrapper.{jar,properties}
- XrayFacade: Optional<String> jiraInstanceKey → @nullable String (S3553)
- XrayClientConfiguration: add @lazy to JiraClientProvider param (QDJVM autowiring)
- Remove annotationProcessor for spring-boot-configuration-processor from build.gradle
- Add META-INF/additional-spring-configuration-metadata.json so SonarCloud can
resolve xray-exporter.cloud.* properties without depending on build outputs
- XrayCloudClientTests: add test for status < 200 in ensureSuccessful (missing branch)
- XrayFacadeTests: update constructor call null→null; add test with non-null jiraInstanceKey
49ffb3c to
74e7298
Compare
|



Addresses several QDJVM/SonarCloud violations introduced by the Xray Cloud support PR, plus removes committed Gradle wrapper files and improves test coverage.
SonarCloud / QDJVM fixes
S3553 —
Optionalas field/parameter (XrayFacade,XrayServerClient): changedOptional<String> jiraInstanceKeyfields and constructor params to@Nullable String;Optional.ofNullable()is called at theJiraFacade.createIssue()use site. Empty-string input (Spring XML default) is normalised tonullin constructors.QDJVM — "Could not autowire
JiraClientProvider" (XrayClientConfiguration): added@Lazyto theJiraClientProviderparameter —@ConditionalOnPropertymakes the bean absent in cloud mode, which QDJVM flags as an error without evaluating conditions.QDJVM — unresolvable
xray-exporter.cloud.*properties (application.properties): replaced thespring-boot-configuration-processorannotationProcessorapproach (SonarCloud analyses source, not build output, so generated metadata is invisible to it) with a committedsrc/main/resources/META-INF/additional-spring-configuration-metadata.jsondefining all fourxray-exporter.cloud.*keys.Test coverage
XrayCloudClientTests: added test for HTTP 1xx (informational) status inensureSuccessful, covering the previously-missingstatus < SC_OKbranch.XrayFacadeTests: updated constructor calls for the@Nullablechange; addedshouldCreateManualTestCaseWithJiraInstanceKeyto cover the non-null key path.Housekeeping
gradle/wrapper/gradle-wrapper.jarandgradle/wrapper/gradle-wrapper.properties.Summary by CodeRabbit
New Features
Documentation
Chores