-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathverification-test.ts
More file actions
57 lines (52 loc) · 1.39 KB
/
verification-test.ts
File metadata and controls
57 lines (52 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Verification: Clean human-written code that should NOT be flagged as AI slop
*/
// Legitimate JSON parsing - should NOT be flagged
function parseResponse(jsonStr: string): any {
try {
return JSON.parse(jsonStr);
} catch (error) {
console.error('Parse error:', error);
return null;
}
}
// Legitimate simple conditional - should NOT be flagged
function findUser(users: any[], id: number): any | null {
const userIndex = users.findIndex(user => user.id === id);
if (userIndex === -1) {
return null;
}
return users[userIndex];
}
// Legitimate data processing function - should NOT be flagged
function processApiResponse(data: any[]): any[] {
return data.map(item => {
if (typeof item === 'object' && item !== null) {
return { ...item, processed: true };
}
return item;
});
}
// Legitimate error handling - should NOT be flagged
async function fetchUserData(userId: number) {
try {
const response = await fetch(`/api/users/${userId}`);
return await response.json();
} catch (error) {
console.error('Failed to fetch user:', error);
return null;
}
}
// Simple for loop - should NOT be flagged as complex
function getMaxValue(numbers: number[]): number {
if (numbers.length === 0) {
return 0;
}
let max = numbers[0];
for (let i = 1; i < numbers.length; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
}
return max;
}