Skip to content

fix: sonar issues - Unused function parameters#1611

Merged
ptoscano merged 3 commits into
mainfrom
sonar/S1172-unused-params
Jul 15, 2026
Merged

fix: sonar issues - Unused function parameters#1611
ptoscano merged 3 commits into
mainfrom
sonar/S1172-unused-params

Conversation

@jcraiglo1

@jcraiglo1 jcraiglo1 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

https://redhat.atlassian.net/browse/AAP-77394

One of multiple PRs addressing sonar quality gate issues. Removes unused function parameters.

Attached is a document describing the actions taken here.

sonarcloud-remediation-report.md

Assisted-by: Claude

Summary by CodeRabbit

  • Chores / Refactor
    • Clarified unused or internal method parameters across shared-resource validation, pod startup waiting, and revision parsing by renaming them without changing runtime behavior or error handling.

@jcraiglo1
jcraiglo1 requested a review from a team as a code owner July 9, 2026 17:04
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Renames three unused method parameters with leading underscores while preserving method behavior and return values.

Changes

Parameter naming cleanup

Layer / File(s) Summary
Rename unused parameters
src/aap_eda/api/serializers/mixins.py, src/aap_eda/services/activation/engine/kubernetes.py, src/aap_eda/services/project/scm.py
Renames parameters to _data, _log_handler, and _rev without changing runtime behavior.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: hsong-rh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the change: it describes fixing Sonar issues by removing unused function parameters.
Description check ✅ Passed The description is on-topic and includes the issue link, purpose, and remediation summary, though testing and impact details are sparse.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sonar/S1172-unused-params

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/aap_eda/services/project/scm.py (2)

135-142: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update docstring to match renamed parameter.

The parameter was renamed to _rev but the docstring still references :param rev:.

📝 Suggested fix
         :param rev: Revision specifier. Currently ignored.
+        :param _rev: Revision specifier. Currently ignored.
                     Always return identifier of the cloned branch.
🤖 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 `@src/aap_eda/services/project/scm.py` around lines 135 - 142, Update the
docstring for rev_parse to match the renamed parameter: the function signature
uses _rev, but the docstring still documents :param rev:. Adjust the parameter
name in the rev_parse method’s docstring so it references _rev consistently and
remains aligned with the method signature.

362-377: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Regex [^}]+ captures extra JSON fields beyond the error message.

For Ansible failure output like {"msg": "Auth failed", "changed": false}, the pattern ([^}]+) captures "Auth failed", "changed": false — including unrelated fields. This inflates error messages and could confuse downstream log parsing. A quoted-string capture is more precise for typical Ansible msg values.

Additionally, line 377 re-calls outputs.getvalue() despite output already holding that value on line 362.

♻️ Suggested refactor
             output = outputs.getvalue()
             match = None
             if "fatal: [localhost]: FAILED!" in output and '"msg":' in output:
-                match = re.search(r'"msg": ([^}]+)\}', output)
+                match = re.search(r'"msg":\s*"([^"]*)"', output)
             if match:
                 err_msg = match.group(1)
                 if "Authentication failed" in err_msg:
                     raise ScmAuthenticationError("Authentication failed")
                 if (
                     "could not read Username" in err_msg
                     or "could not read Password" in err_msg
                 ):
                     err_msg = "Credentials not provided or incorrect"
                     raise ScmAuthenticationError(err_msg)
                 raise ScmError(f"{self.ERROR_PREFIX} {err_msg}")
-            raise ScmError(f"{self.ERROR_PREFIX} {outputs.getvalue().strip()}")
+            raise ScmError(f"{self.ERROR_PREFIX} {output.strip()}")
🤖 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 `@src/aap_eda/services/project/scm.py` around lines 362 - 377, The Ansible
failure parsing in scm.py is too permissive and the fallback rereads the buffer
unnecessarily. Update the regex used in the error handling block around the
`match = re.search(...)` logic in `Scm` so it captures only the quoted `msg`
value instead of everything up to `}`. Then reuse the existing `output` variable
in the final `ScmError` raise rather than calling `outputs.getvalue()` again,
keeping the extracted message handling in `ScmAuthenticationError` and
`ScmError` consistent.
🤖 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.

Nitpick comments:
In `@src/aap_eda/services/project/scm.py`:
- Around line 135-142: Update the docstring for rev_parse to match the renamed
parameter: the function signature uses _rev, but the docstring still documents
:param rev:. Adjust the parameter name in the rev_parse method’s docstring so it
references _rev consistently and remains aligned with the method signature.
- Around line 362-377: The Ansible failure parsing in scm.py is too permissive
and the fallback rereads the buffer unnecessarily. Update the regex used in the
error handling block around the `match = re.search(...)` logic in `Scm` so it
captures only the quoted `msg` value instead of everything up to `}`. Then reuse
the existing `output` variable in the final `ScmError` raise rather than calling
`outputs.getvalue()` again, keeping the extracted message handling in
`ScmAuthenticationError` and `ScmError` consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: baab4443-1934-4ef4-81cc-97d0795adc8e

📥 Commits

Reviewing files that changed from the base of the PR and between 6eb7516 and 08fbeb9.

📒 Files selected for processing (3)
  • src/aap_eda/api/serializers/mixins.py
  • src/aap_eda/services/activation/engine/kubernetes.py
  • src/aap_eda/services/project/scm.py

@codecov-commenter

codecov-commenter commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.75%. Comparing base (deaac7e) to head (0d909f4).

@@           Coverage Diff           @@
##             main    #1611   +/-   ##
=======================================
  Coverage   92.75%   92.75%           
=======================================
  Files         244      244           
  Lines       11346    11346           
=======================================
  Hits        10524    10524           
  Misses        822      822           
Flag Coverage Δ
unit-int-tests-3.11 92.75% <100.00%> (ø)
unit-int-tests-3.12 92.75% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/aap_eda/api/serializers/mixins.py 100.00% <100.00%> (ø)
...c/aap_eda/services/activation/engine/kubernetes.py 90.34% <100.00%> (ø)
src/aap_eda/services/project/scm.py 77.57% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/aap_eda/services/project/scm.py Outdated
mkanoor
mkanoor previously approved these changes Jul 13, 2026
@B-Whitt

B-Whitt commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

/run-e2e

@B-Whitt

B-Whitt commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

/run-atf-tests

@aap-pde-ci-bot

Copy link
Copy Markdown

✅ Test Results - PASSED

Summary

Metric Count
Total Tests 65
✅ Passed 49
❌ Failed 0
⚠️ Errors 0
⏭️ Skipped 16
⏱️ Duration 199.16s

Pass Rate: 75.4%

@jcraiglo1

Copy link
Copy Markdown
Contributor Author

/run-e2e

@jcraiglo1

Copy link
Copy Markdown
Contributor Author

/run-atf-tests

@aap-pde-ci-bot

Copy link
Copy Markdown

✅ Test Results - PASSED

Summary

Metric Count
Total Tests 65
✅ Passed 49
❌ Failed 0
⚠️ Errors 0
⏭️ Skipped 16
⏱️ Duration 234.86s

Pass Rate: 75.4%

Signed-off-by: Jacob Craiglow <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@ptoscano
ptoscano merged commit b09cac8 into main Jul 15, 2026
7 checks passed
@ptoscano
ptoscano deleted the sonar/S1172-unused-params branch July 15, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants