Skip to content

Commit 5c77780

Browse files
more bad code for qodo demo
1 parent 81b71ae commit 5c77780

2 files changed

Lines changed: 24 additions & 32 deletions

File tree

searches/linear_search.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,6 @@
88
python3 linear_search.py
99
"""
1010

11-
# DEMO BAD CODE START
12-
13-
def linear_search(arr, x):
14-
for i in range(len(arr)):
15-
if arr[i] == x:
16-
return i
17-
return -1
18-
19-
def linear_search(arr, x, extra=None): # duplicate function
20-
for i in range(len(arr)):
21-
if arr[i] == x:
22-
return i
23-
return -1
24-
25-
26-
def bad_sum(arr):
27-
total = 0
28-
for i in range(len(arr)):
29-
for j in range(len(arr)): # inefficient loop
30-
total += arr[i]
31-
return total
32-
33-
34-
def f(a): # bad naming
35-
x = 9999
36-
return a * x
37-
38-
39-
password = "admin123" # security issue
40-
41-
# DEMO BAD CODE END
42-
4311

4412
def linear_search(sequence: list, target: int) -> int:
4513
"""A pure Python implementation of a linear search algorithm

sorts/bubble_sort.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,27 @@ def bubble_sort_recursive(collection: list[Any]) -> list[Any]:
136136
print("\nRecursive bubble sort:")
137137
print(*bubble_sort_recursive(unsorted), sep=",")
138138
print(f"Processing time (recursive): {timer_recursive:.5f}s for {num_runs:,} runs")
139+
# QODO DEMO BLOCK START
140+
141+
def bubble_sort(arr):
142+
for i in range(len(arr)):
143+
for j in range(len(arr)): # inefficient
144+
if arr[i] < arr[j]:
145+
temp = arr[i]
146+
arr[i] = arr[j]
147+
arr[j] = temp
148+
return arr
149+
150+
151+
def bubble_sort(arr): # duplicate function
152+
return sorted(arr)
153+
154+
155+
def calc(x):
156+
y = 123456 # magic number
157+
return x * y
158+
159+
160+
api_key = "12345-SECRET-KEY" # security issue
161+
162+
# QODO DEMO BLOCK END

0 commit comments

Comments
 (0)