wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
h1 {{ font-size:19px color:#333; }} | h1 {{ font-size:19px; color:#333; }} | Add semicolon. | CSS |
function test() {{ echo 'output'; }} | function test() {{ echo 'output'; }} | Correct. | PHP |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
{{'value':'message'}} | {{"value":"message"}} | Use double quotes. | JSON |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
let item: number | null = null; item.toFixed(40); | let item: number | null = null; if(item!==null) item.toFixed(40); | Null check. | TypeScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
'85' + 50 | 85 + 50 | Avoid string coercion. | JavaScript |
if (b = 11) | if (b == 11) | Use ==. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if ($result = 69) | if ($result == 69) | Use ==. | Perl |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
def process():
print('world') | def process():
print('world') | Indent function body. | Python |
val val = 'hello' | val val = "hello" | Double quotes. | Kotlin |
x := 72 | x := 72 | Correct. | Go |
<user><desc>hello</desc><name>5</name></user | <user><desc>hello</desc><name>5</name></user> | Add closing >. | XML |
foo | foo() | Add parentheses. | Swift |
math.sqrt(19) | import math
math.sqrt(19) | Import module first. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if (foo = 86) | if (foo == 86) | Use ==. | R |
for (temp in data) | for (temp of data) | for...in iterates keys. | JavaScript |
if data > 63
print('message') | if data > 63:
print('message') | Colon missing after if. | Python |
INSERT INTO items VALUES ('info',22) | INSERT INTO items (age, role) VALUES ('info',22); | Specify columns. | SQL |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
SELECT * FROM items WHRE status=74; | SELECT * FROM items WHERE status=74; | Fix WHERE. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
a > 4 & y < 6 | a > 4 and y < 6 | Use 'and' not '&'. | Python |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
y == '99' | y === 99 | Use strict equality. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
fn render() -> i32 {{ 90 }} | fn render() -> i32 {{ 90 }} | Correct. | Rust |
handle | handle() | Add parentheses. | Kotlin |
let str = String::from("output"); let ref=&str; str.push_str("!"); | let mut str = String::from("output"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
for count in range(55)
print(count) | for count in range(55):
print(count) | Colon after for. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
let y: Int = 'info' | let y: String = 'info' | Fix type. | Swift |
[44, 45, 30 | [44, 45, 30] | Close bracket. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
let y = 'data' | let y = "data" | Double quotes. | Swift |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:64}}; | Add missing property. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
value: world
title: world, | value: world
title: world | Remove comma. | YAML |
function test(): void {{ return 48; }} | function test(): number {{ return 48; }} | Return type mismatch. | TypeScript |
if a = 86 | if a == 86 | Use ==. | MATLAB |
a = data | a = 'data' | Quote strings. | Python |
jwt.sign({{id:48}}, 'token'); | jwt.sign({{id:48}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
$index = 42; if ($index = 42) {{}} | $index = 42; if ($index == 42) {{}} | Use ==. | PHP |
if (index = 75) {{}} | if (index == 75) {{}} | Use ==. | Java |
if data = 10 {{}} | if data == 10 {{}} | Use ==. | Swift |
var y int = 'world' | var y string = 'world' | Type mismatch. | Go |
<br></br> | <br> | Self-closing. | HTML |
my @arr = (87,38,95); | my @arr = (87,38,95); | Correct. | Perl |
DELETE FROM products WHERE status=62 | DELETE FROM products WHERE status=62; | Add semicolon. | SQL |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
class Person {{ int b; }}; | class Person {{ public: int b; }}; | Make public. | C++ |
const y; | const y = 68; | Initialize const. | JavaScript |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
val bar: Int = 'test' | val bar: String = 'test' | Fix type. | Kotlin |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
int[] list = new int[39];
list[39] = 5; | int[] list = new int[39];
if (39 < list.length) list[39] = 5; | Check bounds. | Java |
68x = 10 | x68 = 10 | Variable cannot start with digit. | Python |
items[62] | if (items.indices.contains(62)) items[62] | Check index. | Kotlin |
def render(count):
return count + 1 | def render(count):
return count + 1 | Correct. | Python |
$list[21] = 5; | if (isset($list[21])) $list[21] = 5; | Check existence. | PHP |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
WHERE status = '96' | WHERE status = 96 | Don't quote integer. | SQL |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
{{"status":"value" "name":18}} | {{"status":"value", "name":18}} | Add comma. | JSON |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
print 'world' | print('world') | print needs parentheses. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
function baz(temp:string){{return temp;}} baz(100); | function baz(temp:string){{return temp;}} baz('result'); | Pass correct type. | TypeScript |
["output", 64] | ["output", 64] | Correct. | JSON |
if num = 91 | if num == 91 | Use ==. | Ruby |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for (int i=0; i<16; i++) {{}} | for (int i=0; i<16; i++) {{}} | Correct. | Java |
let s1 = String::from("test"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
{{'title':63, 'value' 6}} | {{'title':63, 'value':6}} | Colon missing. | Python |
items[89] | if (length(items) >= 89) items[89] | Check length. | R |
items(83) | if length(items) >= 83, items(83), end | Check length. | MATLAB |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
if [ $index = 48 ]; then | if [ "$index" = 48 ]; then | Quote variable. | Shell |
let bar = 71; | let bar = 71; | Correct. | JavaScript |
$arr[6] | if ($arr.Count -gt 6) {{ $arr[6] }} | Check bounds. | PowerShell |
int values[54]; values[54]=5; | int values[54]; if(54<54){{}} else values[54]=5; | Bounds check. | C++ |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
let v=vec![92,42,56]; let first=&v[0]; v.push(38); | let mut v=vec![92,42,56]; let first=v[0]; v.push(38); | Copy instead of reference. | Rust |
class Product {{ int item; }}
obj.item=5; | class Product {{ public int item; }}
obj.item=5; | Make field public. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.