Skip to content

Add tests (eng-4588) - #109

Closed
vansh-deepsource wants to merge 2 commits into
masterfrom
test-file-supression
Closed

Add tests (eng-4588)#109
vansh-deepsource wants to merge 2 commits into
masterfrom
test-file-supression

Conversation

@vansh-deepsource

Copy link
Copy Markdown
Collaborator

No description provided.

vansh-deepsource and others added 2 commits June 8, 2026 17:33
Mirrors the FP cases (FP-46826/46827/46828/46829/46831) as Python test
files so the permissive test-file rubric can be exercised end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Defects that should remain reportable even when AI Review applies the
permissive test-file rubric from ENG-4588 (mutable default arg, SQL
injection, identity-vs-equality, file handle leak, off-by-one,
unreachable code, assert-for-auth).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@deepsource-development

deepsource-development Bot commented Jun 8, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 9d1323c...405518c on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade  

Focus Area: Reliability
Security  

Reliability  

Complexity  

Hygiene  

Feedback

Test assertions that don’t assert behavior

  • The constant assertTrue and the unreachable self.fail() both point to tests that execute code but don’t actually verify the outcome.
  • Given how focused the rest of the suite is, it’s worth making sure every test has a clear, reachable assertion of behavior, not just that “it runs.”

Subtle nondeterminism in tests

  • The mutable default seen=[], off‑by‑one range(len(...)+1), and is on strings all introduce hidden, order‑dependent or runtime‑dependent behavior.
  • Since these are tests, small nondeterminisms can make failures hard to reproduce; tightening these up keeps the suite as reliable as the behaviors it’s checking.

Code Review Summary

Analyzer Status Updated (UTC) Details
Ansible Jun 8, 2026 12:20p.m. Review ↗
Helm Jun 8, 2026 12:20p.m. Review ↗
Python Jun 8, 2026 12:20p.m. Review ↗
Secrets Jun 8, 2026 12:20p.m. Review ↗

f = open("/tmp/route_dump.txt", "w")
for method, path in ROUTES:
f.write(f"{method} {path}\n")
self.assertTrue(True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Passing constant to `assertTrue` makes test pointless


The assertTrue(True) call always passes because the condition is a constant true value, providing no real assertion or verification in test logic. This makes the test meaningless as it cannot fail and does not validate any behavior.

Replace assertTrue with an actual conditional expression or use a more appropriate assertion like assertEqual with meaningful variables to ensure the test validates intended logic properly.


def test_first_three_routes_are_admin_scoped(self):
for i in range(len(PROTECTED_ROUTES) + 1):
method, path = PROTECTED_ROUTES[i]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused variable `path` adds code clutter


The variable path is extracted from PROTECTED_ROUTES[i] but is not used anywhere in the surrounding code, which wastes memory and can confuse developers about its purpose.
Remove the path variable or replace its name with _ to indicate that it is intentionally unused, clarifying the code's intent.

role = "admin"
assert role == "admin", "audit log must run as admin"
return
self.fail("audit role check did not short-circuit")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreachable `self.fail()` call indicates dead code


The statement self.fail("audit role check did not short-circuit") will never execute because previous control flow paths prevent reaching it, indicating dead code that adds confusion and maintenance overhead. Such unreachable code may mask logic errors or lead to misunderstandings. Remove or refactor to ensure all statements are reachable and meaningful.

Remove the unreachable self.fail() call or adjust control structures so this statement is reachable and correctly signals failure when intended.

pass

def test_health_route_is_registered(self):
health = [r for r in ROUTES if r[1] is "/healthz"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`is` on string literals causes nondeterministic matching


The list filter uses r[1] is "/healthz", which compares identities instead of values. Python string interning is implementation-dependent, so route detection can become flaky across runtimes.

Replace identity comparison with value comparison using ==

Comment on lines +45 to +46
for i in range(len(PROTECTED_ROUTES) + 1):
method, path = PROTECTED_ROUTES[i]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`range(len(...)+1)` triggers `IndexError`


The index-based loop overruns PROTECTED_ROUTES by one, so the test errors instead of validating route scope. This produces unstable test outcomes and masks intent.
Replace the bound with range(len(PROTECTED_ROUTES)) or iterate directly over PROTECTED_ROUTES to avoid out-of-range access

Comment thread tests/test_fuzz.py
import unittest


def _record_seen(payload, seen=[]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`seen=[]` persists across calls, breaking test isolation


_record_seen keeps shared state between calls, so test_recorder_accumulates_payloads receives prior payloads instead of a fresh list. This makes the test non-deterministic and can fail based on execution order.

Replace the mutable default with None, then initialize seen = [] inside the function.

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.

1 participant