Xoá file
This commit is contained in:
44
error.js
44
error.js
@@ -1,44 +0,0 @@
|
|||||||
// Basic JS file with review issues
|
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
|
||||||
|
|
||||||
// 1. Component không dùng prop types
|
|
||||||
function Demo(props) {
|
|
||||||
// 2. State không khởi tạo đúng kiểu
|
|
||||||
const [count, setCount] = useState('0'); // Nên là số
|
|
||||||
|
|
||||||
// 3. Hàm không dùng
|
|
||||||
function unusedFunc() {
|
|
||||||
return 'unused';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Truy cập props không tồn tại
|
|
||||||
const name = props.username;
|
|
||||||
|
|
||||||
// 5. Render mảng không có key
|
|
||||||
const arr = [1,2,3];
|
|
||||||
const list = arr.map(item => <li>{item}</li>);
|
|
||||||
|
|
||||||
// 6. Inline style sai cú pháp
|
|
||||||
const style = { color: 'red', fontWeight: 500 };
|
|
||||||
|
|
||||||
// 7. Sử dụng biến chưa khai báo
|
|
||||||
let result = value + 1;
|
|
||||||
|
|
||||||
// 8. Sử dụng setState sai
|
|
||||||
setCount(count++);
|
|
||||||
|
|
||||||
// 9. Return nhiều phần tử không bọc Fragment
|
|
||||||
return (
|
|
||||||
<div style={style}>
|
|
||||||
<span>Test</span>
|
|
||||||
{list}
|
|
||||||
<button onClick={() => setCount('abc')}>Click</button>
|
|
||||||
<p>{name}</p>
|
|
||||||
</div>
|
|
||||||
<h1>Unwrapped</h1>
|
|
||||||
) // Không bọc Fragment
|
|
||||||
}
|
|
||||||
|
|
||||||
// 10. Export sai kiểu
|
|
||||||
export { Demo };
|
|
||||||
44
error.jsx
44
error.jsx
@@ -1,44 +0,0 @@
|
|||||||
// Basic JSX file with review issues
|
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
|
||||||
|
|
||||||
// 1. Component không dùng prop types
|
|
||||||
function MyComponent(props) {
|
|
||||||
// 2. State không khởi tạo đúng kiểu
|
|
||||||
const [count, setCount] = useState('0'); // Nên là số
|
|
||||||
|
|
||||||
// 3. Hàm không dùng
|
|
||||||
function unusedFunc() {
|
|
||||||
return 'unused';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Truy cập props không tồn tại
|
|
||||||
const name = props.username;
|
|
||||||
|
|
||||||
// 5. Render mảng không có key
|
|
||||||
const arr = [1,2,3];
|
|
||||||
const list = arr.map(item => <li>{item}</li>);
|
|
||||||
|
|
||||||
// 6. Inline style sai cú pháp
|
|
||||||
const style = { color: 'red', fontWeight: 500 };
|
|
||||||
|
|
||||||
// 7. Sử dụng biến chưa khai báo
|
|
||||||
let result = value + 1;
|
|
||||||
|
|
||||||
// 8. Sử dụng setState sai
|
|
||||||
setCount(count++);
|
|
||||||
|
|
||||||
// 9. Return nhiều phần tử không bọc Fragment
|
|
||||||
return (
|
|
||||||
<div style={style}>
|
|
||||||
<span>Test</span>
|
|
||||||
{list}
|
|
||||||
<button onClick={() => setCount('abc')}>Click</button>
|
|
||||||
<p>{name}</p>
|
|
||||||
</div>
|
|
||||||
<h1>Unwrapped</h1>
|
|
||||||
) // Không bọc Fragment
|
|
||||||
}
|
|
||||||
|
|
||||||
// 10. Export sai kiểu
|
|
||||||
export { MyComponent };
|
|
||||||
37
error.php
37
error.php
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// Sử dụng Yii với nhiều lỗi review
|
|
||||||
use yii\base\Controller;
|
|
||||||
|
|
||||||
class SiteController extends Controller {
|
|
||||||
// 1. Hàm không có visibility
|
|
||||||
function actionIndex() {
|
|
||||||
// 2. Truy cập biến chưa khai báo
|
|
||||||
echo $title;
|
|
||||||
|
|
||||||
// 3. SQL injection
|
|
||||||
$id = $_GET['id'];
|
|
||||||
$user = Yii::$app->db->createCommand("SELECT * FROM user WHERE id = $id")->queryOne();
|
|
||||||
|
|
||||||
// 4. Không kiểm tra null
|
|
||||||
echo $user['name'];
|
|
||||||
|
|
||||||
// 5. Không dùng CSRF cho form
|
|
||||||
echo '<form method="post"><input name="test"></form>';
|
|
||||||
|
|
||||||
// 6. Không validate dữ liệu
|
|
||||||
$model = new \app\models\User();
|
|
||||||
$model->name = $_POST['name'];
|
|
||||||
$model->save();
|
|
||||||
|
|
||||||
// 7. Hardcode đường dẫn
|
|
||||||
require_once('/var/www/html/config.php');
|
|
||||||
|
|
||||||
// 8. Không đóng kết nối DB
|
|
||||||
// 9. Không xử lý exception
|
|
||||||
throw new Exception('Error!');
|
|
||||||
|
|
||||||
// 10. Hàm trả về giá trị không đúng
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
56
error.ts
56
error.ts
@@ -1,56 +0,0 @@
|
|||||||
// Basic TypeScript file with review issues
|
|
||||||
|
|
||||||
function add(a: number, b: number): number {
|
|
||||||
return a + b // Missing semicolon, no type safety for return
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = add('1', 2); // Passing string instead of number
|
|
||||||
console.log(result)
|
|
||||||
|
|
||||||
// 1. Unused variable
|
|
||||||
let unusedVar: string;
|
|
||||||
|
|
||||||
// 2. Function with wrong return type
|
|
||||||
function getString(): number {
|
|
||||||
return "hello" // Should return number
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Variable declared but never used
|
|
||||||
let neverUsed = 123;
|
|
||||||
|
|
||||||
// 4. Type assertion error
|
|
||||||
let x: any = "abc";
|
|
||||||
let y: number = x as number; // Wrong assertion
|
|
||||||
|
|
||||||
// 5. Shadowed variable
|
|
||||||
let a = 5;
|
|
||||||
function shadow() {
|
|
||||||
let a = "shadowed";
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 6. Function missing return type
|
|
||||||
function noReturnType() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. Incorrect interface usage
|
|
||||||
interface User {
|
|
||||||
name: string;
|
|
||||||
age: number;
|
|
||||||
}
|
|
||||||
const user: User = { name: "A", age: "20" }; // age should be number
|
|
||||||
|
|
||||||
// 8. Array with mixed types
|
|
||||||
const arr: number[] = [1, "2", 3];
|
|
||||||
|
|
||||||
// 9. Unreachable code
|
|
||||||
function unreachable() {
|
|
||||||
return 1;
|
|
||||||
console.log("This will never run");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 10. Using 'any' type unnecessarily
|
|
||||||
function useAny(a: any, b: any): any {
|
|
||||||
return a + b;
|
|
||||||
}
|
|
||||||
48
error.tsx
48
error.tsx
@@ -1,48 +0,0 @@
|
|||||||
// Basic TSX file with review issues
|
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
|
||||||
|
|
||||||
// 1. Không dùng prop types hoặc interface cho props
|
|
||||||
type Props = { title?: string };
|
|
||||||
function App(props: Props) {
|
|
||||||
// 2. State sai kiểu
|
|
||||||
const [count, setCount] = useState<string>(0); // Nên là number
|
|
||||||
|
|
||||||
// 3. Hàm không dùng
|
|
||||||
function unusedFunc(): string {
|
|
||||||
return 'unused';
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. Truy cập props không tồn tại
|
|
||||||
const name = props.username;
|
|
||||||
|
|
||||||
// 5. Render mảng không có key
|
|
||||||
const arr = [1,2,3];
|
|
||||||
const list = arr.map(item => <li>{item}</li>);
|
|
||||||
|
|
||||||
// 6. Inline style sai cú pháp
|
|
||||||
const style = { color: 'red', fontWeight: 500 };
|
|
||||||
|
|
||||||
// 7. Sử dụng biến chưa khai báo
|
|
||||||
let result = value + 1;
|
|
||||||
|
|
||||||
// 8. Sử dụng setState sai
|
|
||||||
setCount(count++);
|
|
||||||
|
|
||||||
// 9. Return nhiều phần tử không bọc Fragment
|
|
||||||
return (
|
|
||||||
<div style={style}>
|
|
||||||
<span>Hello World</span>
|
|
||||||
{list}
|
|
||||||
<button onClick={() => setCount('abc')}>Click</button>
|
|
||||||
<p>{name}</p>
|
|
||||||
</div>
|
|
||||||
<h1>Unwrapped</h1>
|
|
||||||
) // Không bọc Fragment
|
|
||||||
}
|
|
||||||
|
|
||||||
// 10. Export sai kiểu
|
|
||||||
export { App };
|
|
||||||
|
|
||||||
// 11. Unused variable
|
|
||||||
const unused = 123;
|
|
||||||
Reference in New Issue
Block a user