Skip to content

[CLEANUP][SONAR][LOW]: Dead code - unused variable max_duration in admin.py #2371

@crivetimihai

Description

@crivetimihai

Severity: LOW
File: mcpgateway/admin.py
Line: 17002
Rule: python:S1854

Description

The variable max_duration is reassigned but never used after the assignment.

Code

# Lines 16995-17006
min_duration = float(stats_row.min_d)
max_duration = float(stats_row.max_d)
latency_range = max_duration - min_duration

# Handle case where all durations are the same
if latency_range == 0:
    latency_range = 1.0
    max_duration = min_duration + 1.0  # <-- Never used after this

time_range_minutes = hours * 60
latency_bucket_size = latency_range / latency_buckets  # Uses latency_range, not max_duration

Impact

None - code functions correctly. The latency_range is already calculated before the reassignment, so the new max_duration value has no effect.

Suggested Fix

Remove the unused assignment:

if latency_range == 0:
    latency_range = 1.0
    # Remove: max_duration = min_duration + 1.0

Metadata

Metadata

Assignees

Labels

COULDP3: Nice-to-have features with minimal impact if left out; included if time permitschoreLinting, formatting, dependency hygiene, or project maintenance choresgood first issueGood for newcomerspythonPython / backend development (FastAPI)sonarSonarQube code quality findings

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions