Boobesh007 commited on
Commit
89b1caf
·
verified ·
1 Parent(s): 23978e3

Upload server/code_review_environment.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. server/code_review_environment.py +61 -1
server/code_review_environment.py CHANGED
@@ -53,7 +53,67 @@ TASKS = {
53
  "severity": "medium"
54
  },
55
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  "hard": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  {
58
  "code": "import os\ndef delete_files(path):\n files = os.listdir(path)\n for f in files:\n os.remove(f)",
59
  "language": "python",
@@ -84,7 +144,7 @@ class CodeReviewEnvironment(Environment):
84
  self._step = 0
85
 
86
  def _get_task(self):
87
- task_type = random.choice(["easy", "medium", "hard"])
88
  self._task_type = task_type
89
  return random.choice(TASKS[task_type])
90
 
 
53
  "severity": "medium"
54
  },
55
  ],
56
+ "javascript": [
57
+ {
58
+ "code": "function add(a, b) {\n return a + b\n}\nconsole.log(add(1, 2))",
59
+ "language": "javascript",
60
+ "description": "Find code quality issues in this JavaScript code",
61
+ "has_syntax_error": False,
62
+ "expected_issues": ["missing semicolons"],
63
+ "severity": "low"
64
+ },
65
+ {
66
+ "code": "var password = 'admin123';\nif (userInput == password) {\n grantAccess();\n}",
67
+ "language": "javascript",
68
+ "description": "Full review: find bugs and security issues",
69
+ "has_syntax_error": False,
70
+ "expected_issues": ["hardcoded password", "use === instead of ==", "security risk"],
71
+ "severity": "high"
72
+ },
73
+ {
74
+ "code": "function fetchData(url) {\n var result = null;\n $.ajax({url: url, async: false, success: function(data) { result = data; }});\n return result;\n}",
75
+ "language": "javascript",
76
+ "description": "Full review: find bugs and performance issues",
77
+ "has_syntax_error": False,
78
+ "expected_issues": ["synchronous ajax call", "performance issue", "blocks main thread"],
79
+ "severity": "high"
80
+ },
81
+ ],
82
+ "java": [
83
+ {
84
+ "code": "public class Main {\n public static void main(String[] args) {\n String s = null;\n System.out.println(s.length());\n }\n}",
85
+ "language": "java",
86
+ "description": "Full review: find bugs and security issues",
87
+ "has_syntax_error": False,
88
+ "expected_issues": ["null pointer exception", "no null check"],
89
+ "severity": "high"
90
+ },
91
+ {
92
+ "code": "public void readFile(String path) {\n FileReader fr = new FileReader(path);\n BufferedReader br = new BufferedReader(fr);\n System.out.println(br.readLine());\n}",
93
+ "language": "java",
94
+ "description": "Full review: find bugs and security issues",
95
+ "has_syntax_error": False,
96
+ "expected_issues": ["resource leak", "no try-finally", "file not closed"],
97
+ "severity": "high"
98
+ },
99
+ ],
100
  "hard": [
101
+ {
102
+ "code": "def divide(a, b):\n return a / b",
103
+ "language": "python",
104
+ "description": "Full review: find bugs, security issues and performance problems",
105
+ "has_syntax_error": False,
106
+ "expected_issues": ["division by zero", "no error handling"],
107
+ "severity": "high"
108
+ },
109
+ {
110
+ "code": "password = \"admin123\"\nif user_input == password:\n grant_access()",
111
+ "language": "python",
112
+ "description": "Full review: find bugs, security issues and performance problems",
113
+ "has_syntax_error": False,
114
+ "expected_issues": ["hardcoded password", "security risk"],
115
+ "severity": "high"
116
+ },
117
  {
118
  "code": "import os\ndef delete_files(path):\n files = os.listdir(path)\n for f in files:\n os.remove(f)",
119
  "language": "python",
 
144
  self._step = 0
145
 
146
  def _get_task(self):
147
+ task_type = random.choice(["easy", "medium", "hard", "javascript", "java"])
148
  self._task_type = task_type
149
  return random.choice(TASKS[task_type])
150