Skip to content

BUILD-13853 Normalize assertion operand order in buildinfo tests - #444

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20261116-080322-037af0ed
Open

sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20261116-080322-037af0ed

Conversation

@sonarqube-agent

Copy link
Copy Markdown

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Why these issues? All three issues stem from the same SonarQube rule (python:S3415) with MAJOR severity and involve straightforward operand swaps to enforce consistent assertion ordering. These changes form a cohesive single-PR group addressing a specific code style violation in the test suite with high automation suitability.

Fixed three SonarQube S3415 violations in test_buildinfo.py by swapping assertion operands to place actual values first and expected values second. This standardizes the assertion convention throughout the file, improving readability and maintainability.

View Project in SonarCloud


Fixed Issues

python:S3415 - Swap these 2 operands so the actual value comes first, to match the rest of this file. • MAJOR • View issue

Location: main/tests/utils/test_buildinfo.py:47

Why is this an issue?

Assertions check that the code under test produces the expected results. When you write an equality assertion, one operand is the value from the code under test (the actual value) and the other is what you expect (the expected value).

What changed

Swaps the operands of the get_package() assertion so the actual value, build_info_with_artefacts.get_package(), sits on the left and the expected literal 'org.sonarsource.test' on the right. This matches the actual-first convention used elsewhere in the file. The neighbouring artifacts assertion is flipped the same way to keep the file consistent.

--- a/main/tests/utils/test_buildinfo.py
+++ b/main/tests/utils/test_buildinfo.py
@@ -46,2 +46,2 @@ def test_get_artifacts_to_publish(build_info_with_artefacts):
-    assert 'org.sonarsource.test:test1:jar,org.sonarsource.test:test2:jar' == artifacts
-    assert 'org.sonarsource.test' == build_info_with_artefacts.get_package()
+    assert artifacts == 'org.sonarsource.test:test1:jar,org.sonarsource.test:test2:jar'
+    assert build_info_with_artefacts.get_package() == 'org.sonarsource.test'
python:S3415 - Swap these 2 operands so the actual value comes first, to match the rest of this file. • MAJOR • View issue

Location: main/tests/utils/test_buildinfo.py:51

Why is this an issue?

Assertions check that the code under test produces the expected results. When you write an equality assertion, one operand is the value from the code under test (the actual value) and the other is what you expect (the expected value).

What changed

Swaps the operands so get_artifacts_to_publish() (the actual value) comes first and the expected string 'ARTIFACTS_TO_PUBLISH' comes second. This removes the expected-first ordering that broke the file's convention.

--- a/main/tests/utils/test_buildinfo.py
+++ b/main/tests/utils/test_buildinfo.py
@@ -51,1 +51,1 @@ def test_get_artifacts_to_publish_returns_property_when_no_module_property(build
-    assert 'ARTIFACTS_TO_PUBLISH' == build_info_with_artefacts_by_env.get_artifacts_to_publish()
+    assert build_info_with_artefacts_by_env.get_artifacts_to_publish() == 'ARTIFACTS_TO_PUBLISH'
python:S3415 - Swap these 2 operands so the actual value comes first, to match the rest of this file. • MAJOR • View issue

Location: main/tests/utils/test_buildinfo.py:57

Why is this an issue?

Assertions check that the code under test produces the expected results. When you write an equality assertion, one operand is the value from the code under test (the actual value) and the other is what you expect (the expected value).

What changed

Rewrites the assertion as captured[0] == "No artifacts to publish", putting the captured output (actual) first and the expected message second. This aligns it with the rest of the file's assertion order.

--- a/main/tests/utils/test_buildinfo.py
+++ b/main/tests/utils/test_buildinfo.py
@@ -57,1 +57,1 @@ def test_get_artifacts_to_publish_prints_message_when_no_artifacts(build_info_wi
-    assert "No artifacts to publish" == captured[0]
+    assert captured[0] == "No artifacts to publish"

Have a suggestion or found an issue? Share your feedback here.


SonarQube Cloud SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AaHFoFMIdm1Pkabk67fc for python:S3415 rule
- AaHFoFMIdm1Pkabk67fb for python:S3415 rule
- AaHFoFMIdm1Pkabk67fd for python:S3415 rule

Generated by SonarQube Agent (task: c5e23bc3-185e-4e64-a8b9-52c6a94e214c)
@sonarqube-agent
sonarqube-agent AI requested a review from a team as a code owner November 16, 2026 08:10
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Normalize assertion operand order in buildinfo tests BUILD-13853 Normalize assertion operand order in buildinfo tests Nov 16, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

BUILD-13853

@gitar-bot

gitar-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟢 Low risk

Swapping equality assertion operands in test_buildinfo.py improves test readability without changing runtime behavior or the values the tests assert.

Swaps operands in three test_buildinfo.py assertions so actual values come first and expected values second, matching the file's convention. No issues found.

Verification Rules 1/2 met PRs 1 inspected
Rules 1 failed 1 passed 2 not applicable

❌ Internal artifact registries - main/Pipfile uses public https://pypi.org/simple, and main/Dockerfile and build.yml run pip install against public PyPI instead of Repox (sonarsource-pypi); route package downloads through Repox.
✅ Repository license compliance

Functional validation No results

Broader impact PRs 1 inspected
Cross-PR 1 PR inspected 0 open impacts

PR 432: Import pytest as a module in test files Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant