-
Notifications
You must be signed in to change notification settings - Fork 614
[CLEANUP][SONAR][LOW]: Identical if/elif branches in path_template normalization in schemas.py #2376
Copy link
Copy link
Open
Labels
COULDP3: Nice-to-have features with minimal impact if left out; included if time permitsP3: Nice-to-have features with minimal impact if left out; included if time permitschoreLinting, formatting, dependency hygiene, or project maintenance choresLinting, formatting, dependency hygiene, or project maintenance chorespythonPython / backend development (FastAPI)Python / backend development (FastAPI)sonarSonarQube code quality findingsSonarQube code quality findings
Milestone
Description
Severity: LOW
File: mcpgateway/schemas.py
Lines: 1148-1151
Rule: python:S3923
Description
The if/elif branches perform identical operations when normalizing path_template:
Code
# Lines 1148-1151
if path_template and not path_template.startswith("/"):
path_template = "/" + path_template.lstrip("/")
elif path_template:
path_template = "/" + path_template.lstrip("/") # Same as above!Technical Analysis
ifbranch: path_template exists AND doesn't start with "/"elifbranch: path_template exists (but already starts with "/")
Both branches do "/" + path_template.lstrip("/"), but the elif branch is redundant - if the path already starts with "/", lstrip("/") removes the leading slash and then "/" is prepended, resulting in the same value.
Impact
None - code functions correctly due to idempotent operation. This is a clarity/maintainability issue.
Suggested Fix
Simplify to a single branch:
if path_template:
# Normalize to ensure single leading slash
path_template = "/" + path_template.lstrip("/")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
COULDP3: Nice-to-have features with minimal impact if left out; included if time permitsP3: Nice-to-have features with minimal impact if left out; included if time permitschoreLinting, formatting, dependency hygiene, or project maintenance choresLinting, formatting, dependency hygiene, or project maintenance chorespythonPython / backend development (FastAPI)Python / backend development (FastAPI)sonarSonarQube code quality findingsSonarQube code quality findings