-
Notifications
You must be signed in to change notification settings - Fork 614
[CLEANUP][SONAR][LOW]: Redundant ternary - both branches identical in log_aggregator.py #2367
Copy link
Copy link
Closed
Bug
Copy link
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 choresgood first issueGood for newcomersGood for newcomerspythonPython / backend development (FastAPI)Python / backend development (FastAPI)sonarSonarQube code quality findingsSonarQube code quality findings
Milestone
Description
Severity: LOW
File: mcpgateway/services/log_aggregator.py
Line: 873
Rule: python:S3923
Description
The conditional expression always evaluates to the same result regardless of the condition:
resolved_end = reference if window_end is None else referenceBoth branches return reference, making the conditional useless.
Code Context
# Lines 863-883
if window_end is None:
reference = datetime.now(timezone.utc)
else:
reference = window_end.astimezone(timezone.utc)
reference = reference.replace(second=0, microsecond=0)
minutes_offset = reference.minute % self.aggregation_window_minutes
if window_end is None and minutes_offset:
reference = reference - timedelta(minutes=minutes_offset)
resolved_end = reference if window_end is None else reference # RedundantImpact
None - code functions correctly. This is a maintainability/readability issue.
Suggested Fix
Replace the redundant ternary with a simple assignment:
resolved_end = referenceReactions 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 choresgood first issueGood for newcomersGood for newcomerspythonPython / backend development (FastAPI)Python / backend development (FastAPI)sonarSonarQube code quality findingsSonarQube code quality findings