fix: sonar issues - Unused function parameters#1611
Conversation
Signed-off-by: Jacob Craiglow <[email protected]>
📝 WalkthroughWalkthroughRenames three unused method parameters with leading underscores while preserving method behavior and return values. ChangesParameter naming cleanup
Estimated code review effort: 1 (Trivial) | ~3 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (2)
src/aap_eda/services/project/scm.py (2)
135-142: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUpdate docstring to match renamed parameter.
The parameter was renamed to
_revbut 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 winRegex
[^}]+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 Ansiblemsgvalues.Additionally, line 377 re-calls
outputs.getvalue()despiteoutputalready 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
📒 Files selected for processing (3)
src/aap_eda/api/serializers/mixins.pysrc/aap_eda/services/activation/engine/kubernetes.pysrc/aap_eda/services/project/scm.py
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1611 +/- ##
=======================================
Coverage 92.75% 92.75%
=======================================
Files 244 244
Lines 11346 11346
=======================================
Hits 10524 10524
Misses 822 822
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/run-e2e |
|
/run-atf-tests |
✅ Test Results - PASSEDSummary
Pass Rate: 75.4% |
|
/run-e2e |
|
/run-atf-tests |
✅ Test Results - PASSEDSummary
Pass Rate: 75.4% |
Signed-off-by: Jacob Craiglow <[email protected]>
|



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