This commit is contained in:
2026-09-12 14:19:56 +08:00
commit 87ab0b794b
130 changed files with 30042 additions and 0 deletions

27
engine/tests/fixtures/demo_sort.py vendored Normal file
View File

@@ -0,0 +1,27 @@
"""Demo script for users: contains several detectable anti-patterns.
- membership test against a list inside a loop -> membership_in_list
- nested loops -> nested_loops
- string concatenation with += inside a loop -> str_concat_loop
"""
def build_report(rows, allow):
out = ""
for r in rows:
if r in allow: # O(n) membership test on a list
out += str(r) + "," # string += accumulation
for other in rows: # nested loop -> O(n^2)
if r == other:
pass
return out
def main():
rows = list(range(400))
allow = list(range(0, 400, 2))
for _ in range(30):
build_report(rows, allow)
main()