Skip to content

Commit 81b71ae

Browse files
demo: added bad code for qodo review
1 parent 02680c9 commit 81b71ae

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

searches/linear_search.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@
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+
1143

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

0 commit comments

Comments
 (0)