code_review / dataset /dataset.json
h1manshu's picture
Upload folder using huggingface_hub
8684af9 verified
[
{
"task_type": "easy",
"pr": {
"id": "2",
"title": "Missing import",
"description": "Forgot to import module",
"language": "python",
"diffs": [
{
"file_name": "main.py",
"diff": "print(datetime.now())"
}
]
},
"ground_truth": {
"issues": ["missing import datetime"],
"decision": "reject",
"fix": "from datetime import datetime\nprint(datetime.now())"
}
},
{
"task_type": "easy",
"pr": {
"id": "9",
"title": "Missing return statement",
"description": "Function does not return value",
"language": "python",
"diffs": [
{
"file_name": "utils.py",
"diff": "def add(a, b):\n result = a + b"
}
]
},
"ground_truth": {
"issues": ["missing return statement"],
"decision": "reject",
"fix": "def add(a, b):\n result = a + b\n return result"
}
},
{
"task_type": "easy",
"pr": {
"id": "10",
"title": "Wrong comparison operator",
"description": "Fix equality check",
"language": "python",
"diffs": [
{
"file_name": "check.py",
"diff": "if x = 10:\n print('ten')"
}
]
},
"ground_truth": {
"issues": ["assignment instead of comparison"],
"decision": "reject",
"fix": "if x == 10:\n print('ten')"
}
},
{
"task_type": "easy",
"pr": {
"id": "11",
"title": "Undefined variable",
"description": "Variable used before assignment",
"language": "python",
"diffs": [
{
"file_name": "app.py",
"diff": "def greet():\n print(message)\n message = 'Hello'"
}
]
},
"ground_truth": {
"issues": ["undefined variable", "variable used before assignment"],
"decision": "reject",
"fix": "def greet():\n message = 'Hello'\n print(message)"
}
},
{
"task_type": "easy",
"pr": {
"id": "12",
"title": "Clean utility function",
"description": "Simple string helper",
"language": "python",
"diffs": [
{
"file_name": "utils.py",
"diff": "def to_upper(s):\n return s.upper()"
}
]
},
"ground_truth": {
"issues": [],
"decision": "approve",
"fix": ""
}
},
{
"task_type": "medium",
"pr": {
"id": "3",
"title": "Division function",
"description": "Handles division",
"language": "python",
"diffs": [
{
"file_name": "math.py",
"diff": "def divide(a,b): return a/b"
}
]
},
"ground_truth": {
"issues": ["division by zero"],
"decision": "reject",
"fix": "def divide(a, b):\n if b == 0:\n return None\n return a / b"
}
},
{
"task_type": "medium",
"pr": {
"id": "4",
"title": "Inefficient loop",
"description": "Optimizing search",
"language": "python",
"diffs": [
{
"file_name": "search.py",
"diff": "for i in range(len(arr)):\n if arr[i] == target:\n return True"
}
]
},
"ground_truth": {
"issues": ["inefficient loop"],
"decision": "approve",
"fix": "return target in arr"
}
},
{
"task_type": "medium",
"pr": {
"id": "13",
"title": "Mutable default argument",
"description": "Function with default list argument",
"language": "python",
"diffs": [
{
"file_name": "helper.py",
"diff": "def append_item(item, lst=[]):\n lst.append(item)\n return lst"
}
]
},
"ground_truth": {
"issues": ["mutable default argument"],
"decision": "reject",
"fix": "def append_item(item, lst=None):\n if lst is None:\n lst = []\n lst.append(item)\n return lst"
}
},
{
"task_type": "medium",
"pr": {
"id": "14",
"title": "Unhandled exception",
"description": "File read without error handling",
"language": "python",
"diffs": [
{
"file_name": "reader.py",
"diff": "def read_file(path):\n with open(path) as f:\n return f.read()"
}
]
},
"ground_truth": {
"issues": ["unhandled exception", "missing error handling"],
"decision": "reject",
"fix": "def read_file(path):\n try:\n with open(path) as f:\n return f.read()\n except FileNotFoundError:\n return None"
}
},
{
"task_type": "medium",
"pr": {
"id": "15",
"title": "Integer overflow risk",
"description": "Large number multiplication",
"language": "python",
"diffs": [
{
"file_name": "compute.py",
"diff": "def factorial(n):\n result = 1\n for i in range(1, n+1):\n result *= i\n return result"
}
]
},
"ground_truth": {
"issues": ["missing input validation"],
"decision": "reject",
"fix": "def factorial(n):\n if n < 0:\n raise ValueError('n must be non-negative')\n result = 1\n for i in range(1, n+1):\n result *= i\n return result"
}
},
{
"task_type": "hard",
"pr": {
"id": "6",
"title": "Authentication logic",
"description": "Adds login system",
"language": "python",
"diffs": [
{
"file_name": "auth.py",
"diff": "def login(password):\n if password == 'admin123':\n return True"
}
]
},
"ground_truth": {
"issues": ["hardcoded password", "security vulnerability"],
"decision": "reject",
"fix": "import bcrypt\n\ndef login(password, hashed_password):\n return bcrypt.checkpw(password.encode(), hashed_password)"
}
},
{
"task_type": "hard",
"pr": {
"id": "7",
"title": "SQL query issue",
"description": "Fetch user data",
"language": "python",
"diffs": [
{
"file_name": "db.py",
"diff": "query = \"SELECT * FROM users WHERE id = \" + user_id"
}
]
},
"ground_truth": {
"issues": ["sql injection"],
"decision": "reject",
"fix": "query = \"SELECT * FROM users WHERE id = %s\"\ncursor.execute(query, (user_id,))"
}
},
{
"task_type": "hard",
"pr": {
"id": "8",
"title": "Cross-file null bug",
"description": "User fetch logic",
"language": "python",
"diffs": [
{
"file_name": "service.py",
"diff": "def get_user(id):\n return db[id]"
},
{
"file_name": "controller.py",
"diff": "user = get_user(None)"
}
]
},
"ground_truth": {
"issues": ["invalid input", "null handling"],
"decision": "reject",
"fix": "def get_user(id):\n if id is None:\n raise ValueError('id must not be None')\n return db[id]\n\nuser = get_user(user_id)"
}
},
{
"task_type": "hard",
"pr": {
"id": "16",
"title": "Race condition in counter",
"description": "Shared counter increment",
"language": "python",
"diffs": [
{
"file_name": "counter.py",
"diff": "counter = 0\n\ndef increment():\n global counter\n counter += 1"
}
]
},
"ground_truth": {
"issues": ["race condition", "thread safety"],
"decision": "reject",
"fix": "import threading\n\ncounter = 0\nlock = threading.Lock()\n\ndef increment():\n global counter\n with lock:\n counter += 1"
}
},
{
"task_type": "hard",
"pr": {
"id": "17",
"title": "Insecure deserialization",
"description": "Load user data from request",
"language": "python",
"diffs": [
{
"file_name": "api.py",
"diff": "import pickle\n\ndef load_user(data):\n return pickle.loads(data)"
}
]
},
"ground_truth": {
"issues": ["insecure deserialization", "security vulnerability"],
"decision": "reject",
"fix": "import json\n\ndef load_user(data):\n return json.loads(data)"
}
},
{
"task_type": "hard",
"pr": {
"id": "18",
"title": "Path traversal vulnerability",
"description": "Serve user requested files",
"language": "python",
"diffs": [
{
"file_name": "files.py",
"diff": "def read_file(filename):\n with open('/var/data/' + filename) as f:\n return f.read()"
}
]
},
"ground_truth": {
"issues": ["path traversal", "security vulnerability"],
"decision": "reject",
"fix": "import os\n\ndef read_file(filename):\n base = '/var/data/'\n full_path = os.path.realpath(os.path.join(base, filename))\n if not full_path.startswith(base):\n raise ValueError('Invalid file path')\n with open(full_path) as f:\n return f.read()"
}
}
]