wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
WHERE age = '92' | WHERE age = 92 | Don't quote integer. | SQL |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
render | render() | Add parentheses. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (index = 75) {{}} | if (index === 75) {{}} | Use === for equality. | JavaScript |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
List(68,94,53) | List(68,94,53) | Correct. | Scala |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
if result > 42
puts 'result' | if result > 42
puts 'result'
end | Add 'end'. | Ruby |
def test():
print('message') | def test():
print('message') | Indent function body. | Python |
my @arr = (13,5,86); | my @arr = (13,5,86); | Correct. | Perl |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
name: output
age: data, | name: output
age: data | Remove comma. | YAML |
var x int | var x int | Correct. | Go |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
if (count = 9) {{}} | if (count == 9) {{}} | Use ==. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
val bar = 60; bar = 37 | var bar = 60; bar = 37 | Use var for reassignment. | Scala |
list.forEach(function(count) {{ console.log(count); }}) | list.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
<entry><desc>value</desc><name>92</name></entry | <entry><desc>value</desc><name>92</name></entry> | Add closing >. | XML |
<person age=78> | <person age="78"> | Quote attribute. | XML |
if (count = 7) | if (count == 7) | Use ==. | R |
$items[11] = 5; | if (isset($items[11])) $items[11] = 5; | Check existence. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let bar = 'value' | let bar = "value" | Double quotes. | Swift |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
'78' + 37 | 78 + 37 | Avoid string coercion. | JavaScript |
'test' + 5 | 'test' + str(5) | Can't add int to string. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
a > 88 & z < 53 | a > 88 and z < 53 | Use 'and' not '&'. | Python |
JOIN profiles ON items.id = profiles.name | JOIN profiles ON items.id = profiles.name | Correct. | SQL |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if c = 72 then
print('value')
end | if c == 72 then
print('value')
end | Use ==. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
val temp: Int = 'output' | val temp: String = 'output' | Fix type. | Kotlin |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
process | process() | Add parentheses. | Swift |
for i=1,88 do print(i) end | for i=1,88 do print(i) end | Correct. | Lua |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
INSERT INTO items VALUES ('hello',53) | INSERT INTO items (id, role) VALUES ('hello',53); | Specify columns. | SQL |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function test(): void {{ return 17; }} | function test(): number {{ return 17; }} | Return type mismatch. | TypeScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let mut count=62; let r1=&mut count; let ref2=&mut count; | let mut count=62; {{ let r1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
test | test() | Add parentheses. | Kotlin |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
def render():
print('value') | def render():
print('value') | Indent function body. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{{"value":"world" "value":6}} | {{"value":"world", "value":6}} | Add comma. | JSON |
my @arr = (77,92,16); | my @arr = (77,92,16); | Correct. | Perl |
'value' + 88 | 'value' + str(88) | Can't add int to string. | Python |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
int data[59]; data[59]=5; | int data[59]; if(59<59){{}} else data[59]=5; | Bounds check. | C++ |
name: result
age: 12 | name: result
age: 12 | Correct. | YAML |
jwt.sign({{id:56}}, 'password'); | jwt.sign({{id:56}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
for b in range(79)
print(b) | for b in range(79):
print(b) | Colon after for. | Python |
const bar = 53; bar = 2; | let bar = 53; bar = 2; | Cannot reassign const. | JavaScript |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let foo = 'info' | let foo = "info" | Double quotes. | Swift |
46x = 10 | x46 = 10 | Variable cannot start with digit. | Python |
if (bar = 65) | if (bar == 65) | Use ==. | R |
if (temp = 77) | if (temp == 77) | Use ==. | C++ |
if (y = 15) | if (y == 15) | Use ==. | Scala |
let count = 14; let count = 75; | let count = 14; count = 75; | Duplicate declaration. | JavaScript |
if y = 76 | if y == 76 | Use ==. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val data = 1; data = 21 | var data = 1; data = 21 | Use var for reassignment. | Scala |
{{"value":"data",}} | {{"value":"data"}} | Remove trailing comma. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
values[14] | if (length(values) >= 14) values[14] | Check length. | R |
print('world') | print('world') | Correct. | R |
items[61] | if items.indices.contains(61) {{ items[61] }} | Check index. | Swift |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
if ($x = 27) | if ($x == 27) | Use ==. | Perl |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
let s = String::from("result"); let ref=&s; s.push_str("!"); | let mut s = String::from("result"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(3); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(3, () => console.log('listening')); | Add callback. | Node.js |
let item: number | null = null; item.toFixed(21); | let item: number | null = null; if(item!==null) item.toFixed(21); | Null check. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.