Spaces:
Sleeping
Sleeping
feat: upload train sft file
Browse files- README.md +14 -12
- app.py +2 -2
- data/train_dataset.jsonl +200 -0
- requirements.txt +4 -2
- train_sft.py +37 -0
README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
1 |
+
# JavaScript Code‑Reviewer SFT Space
|
2 |
+
|
3 |
+
This Space hosts a small, CPU‑only SFT‑tuned CodeGen model that reads a git diff + guidelines
|
4 |
+
and returns a JSON array of `{ line: int, comment: str }`.
|
5 |
+
|
6 |
+
- **API endpoint**: `/predict`
|
7 |
+
- **Inputs**: `diff` (string), `guidelines` (string)
|
8 |
+
- **Output**: JSON list of review comments.
|
9 |
+
|
10 |
+
To retrain locally, run:
|
11 |
+
|
12 |
+
```bash
|
13 |
+
pip install -r requirements.txt
|
14 |
+
python train_sft.py
|
app.py
CHANGED
@@ -9,11 +9,11 @@ from transformers import (
|
|
9 |
|
10 |
# ── 1) Pick your model ────────────────────────────────────────────────
|
11 |
# ▸ For a causal code model (no T5 errors):
|
12 |
-
|
13 |
# ▸ Or, for a seq‑to‑seq model:
|
14 |
# MODEL_ID = "google/flan-t5-base"
|
15 |
# MODEL_ID = "google/flan-t5-small"
|
16 |
-
MODEL_ID = "Salesforce/codegen-350M-multi"
|
17 |
|
18 |
# ── 2) Load tokenizer + model ────────────────────────────────────────
|
19 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
|
|
9 |
|
10 |
# ── 1) Pick your model ────────────────────────────────────────────────
|
11 |
# ▸ For a causal code model (no T5 errors):
|
12 |
+
MODEL_ID = "Salesforce/codegen-350M-multi"
|
13 |
# ▸ Or, for a seq‑to‑seq model:
|
14 |
# MODEL_ID = "google/flan-t5-base"
|
15 |
# MODEL_ID = "google/flan-t5-small"
|
16 |
+
# MODEL_ID = "Salesforce/codegen-350M-multi"
|
17 |
|
18 |
# ── 2) Load tokenizer + model ────────────────────────────────────────
|
19 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
data/train_dataset.jsonl
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"diff": "diff --git a/file0.js b/file0.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
2 |
+
{"diff": "diff --git a/file1.js b/file1.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
3 |
+
{"diff": "diff --git a/file2.js b/file2.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
4 |
+
{"diff": "diff --git a/file3.js b/file3.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
5 |
+
{"diff": "diff --git a/file4.js b/file4.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
6 |
+
{"diff": "diff --git a/file5.js b/file5.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
7 |
+
{"diff": "diff --git a/file6.js b/file6.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
8 |
+
{"diff": "diff --git a/file7.js b/file7.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
9 |
+
{"diff": "diff --git a/file8.js b/file8.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
10 |
+
{"diff": "diff --git a/file9.js b/file9.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
11 |
+
{"diff": "diff --git a/file10.js b/file10.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
12 |
+
{"diff": "diff --git a/file11.js b/file11.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
13 |
+
{"diff": "diff --git a/file12.js b/file12.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
14 |
+
{"diff": "diff --git a/file13.js b/file13.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
15 |
+
{"diff": "diff --git a/file14.js b/file14.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
16 |
+
{"diff": "diff --git a/file15.js b/file15.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
17 |
+
{"diff": "diff --git a/file16.js b/file16.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
18 |
+
{"diff": "diff --git a/file17.js b/file17.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
19 |
+
{"diff": "diff --git a/file18.js b/file18.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
20 |
+
{"diff": "diff --git a/file19.js b/file19.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
21 |
+
{"diff": "diff --git a/file20.js b/file20.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
22 |
+
{"diff": "diff --git a/file21.js b/file21.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
23 |
+
{"diff": "diff --git a/file22.js b/file22.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
24 |
+
{"diff": "diff --git a/file23.js b/file23.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
25 |
+
{"diff": "diff --git a/file24.js b/file24.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
26 |
+
{"diff": "diff --git a/file25.js b/file25.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
27 |
+
{"diff": "diff --git a/file26.js b/file26.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
28 |
+
{"diff": "diff --git a/file27.js b/file27.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
29 |
+
{"diff": "diff --git a/file28.js b/file28.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
30 |
+
{"diff": "diff --git a/file29.js b/file29.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
31 |
+
{"diff": "diff --git a/file30.js b/file30.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
32 |
+
{"diff": "diff --git a/file31.js b/file31.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
33 |
+
{"diff": "diff --git a/file32.js b/file32.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
34 |
+
{"diff": "diff --git a/file33.js b/file33.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
35 |
+
{"diff": "diff --git a/file34.js b/file34.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
36 |
+
{"diff": "diff --git a/file35.js b/file35.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
37 |
+
{"diff": "diff --git a/file36.js b/file36.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
38 |
+
{"diff": "diff --git a/file37.js b/file37.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
39 |
+
{"diff": "diff --git a/file38.js b/file38.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
40 |
+
{"diff": "diff --git a/file39.js b/file39.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
41 |
+
{"diff": "diff --git a/file40.js b/file40.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
42 |
+
{"diff": "diff --git a/file41.js b/file41.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
43 |
+
{"diff": "diff --git a/file42.js b/file42.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
44 |
+
{"diff": "diff --git a/file43.js b/file43.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
45 |
+
{"diff": "diff --git a/file44.js b/file44.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
46 |
+
{"diff": "diff --git a/file45.js b/file45.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
47 |
+
{"diff": "diff --git a/file46.js b/file46.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
48 |
+
{"diff": "diff --git a/file47.js b/file47.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
49 |
+
{"diff": "diff --git a/file48.js b/file48.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
50 |
+
{"diff": "diff --git a/file49.js b/file49.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
51 |
+
{"diff": "diff --git a/file50.js b/file50.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
52 |
+
{"diff": "diff --git a/file51.js b/file51.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
53 |
+
{"diff": "diff --git a/file52.js b/file52.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
54 |
+
{"diff": "diff --git a/file53.js b/file53.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
55 |
+
{"diff": "diff --git a/file54.js b/file54.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
56 |
+
{"diff": "diff --git a/file55.js b/file55.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
57 |
+
{"diff": "diff --git a/file56.js b/file56.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
58 |
+
{"diff": "diff --git a/file57.js b/file57.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
59 |
+
{"diff": "diff --git a/file58.js b/file58.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
60 |
+
{"diff": "diff --git a/file59.js b/file59.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
61 |
+
{"diff": "diff --git a/file60.js b/file60.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
62 |
+
{"diff": "diff --git a/file61.js b/file61.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
63 |
+
{"diff": "diff --git a/file62.js b/file62.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
64 |
+
{"diff": "diff --git a/file63.js b/file63.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
65 |
+
{"diff": "diff --git a/file64.js b/file64.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
66 |
+
{"diff": "diff --git a/file65.js b/file65.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
67 |
+
{"diff": "diff --git a/file66.js b/file66.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
68 |
+
{"diff": "diff --git a/file67.js b/file67.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
69 |
+
{"diff": "diff --git a/file68.js b/file68.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
70 |
+
{"diff": "diff --git a/file69.js b/file69.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
71 |
+
{"diff": "diff --git a/file70.js b/file70.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
72 |
+
{"diff": "diff --git a/file71.js b/file71.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
73 |
+
{"diff": "diff --git a/file72.js b/file72.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
74 |
+
{"diff": "diff --git a/file73.js b/file73.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
75 |
+
{"diff": "diff --git a/file74.js b/file74.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
76 |
+
{"diff": "diff --git a/file75.js b/file75.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
77 |
+
{"diff": "diff --git a/file76.js b/file76.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
78 |
+
{"diff": "diff --git a/file77.js b/file77.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
79 |
+
{"diff": "diff --git a/file78.js b/file78.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
80 |
+
{"diff": "diff --git a/file79.js b/file79.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
81 |
+
{"diff": "diff --git a/file80.js b/file80.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
82 |
+
{"diff": "diff --git a/file81.js b/file81.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
83 |
+
{"diff": "diff --git a/file82.js b/file82.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
84 |
+
{"diff": "diff --git a/file83.js b/file83.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
85 |
+
{"diff": "diff --git a/file84.js b/file84.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
86 |
+
{"diff": "diff --git a/file85.js b/file85.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
87 |
+
{"diff": "diff --git a/file86.js b/file86.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
88 |
+
{"diff": "diff --git a/file87.js b/file87.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
89 |
+
{"diff": "diff --git a/file88.js b/file88.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
90 |
+
{"diff": "diff --git a/file89.js b/file89.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
91 |
+
{"diff": "diff --git a/file90.js b/file90.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
92 |
+
{"diff": "diff --git a/file91.js b/file91.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
93 |
+
{"diff": "diff --git a/file92.js b/file92.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
94 |
+
{"diff": "diff --git a/file93.js b/file93.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
95 |
+
{"diff": "diff --git a/file94.js b/file94.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
96 |
+
{"diff": "diff --git a/file95.js b/file95.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
97 |
+
{"diff": "diff --git a/file96.js b/file96.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
98 |
+
{"diff": "diff --git a/file97.js b/file97.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
99 |
+
{"diff": "diff --git a/file98.js b/file98.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
100 |
+
{"diff": "diff --git a/file99.js b/file99.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
101 |
+
{"diff": "diff --git a/file100.js b/file100.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
102 |
+
{"diff": "diff --git a/file101.js b/file101.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
103 |
+
{"diff": "diff --git a/file102.js b/file102.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
104 |
+
{"diff": "diff --git a/file103.js b/file103.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
105 |
+
{"diff": "diff --git a/file104.js b/file104.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
106 |
+
{"diff": "diff --git a/file105.js b/file105.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
107 |
+
{"diff": "diff --git a/file106.js b/file106.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
108 |
+
{"diff": "diff --git a/file107.js b/file107.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
109 |
+
{"diff": "diff --git a/file108.js b/file108.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
110 |
+
{"diff": "diff --git a/file109.js b/file109.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
111 |
+
{"diff": "diff --git a/file110.js b/file110.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
112 |
+
{"diff": "diff --git a/file111.js b/file111.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
113 |
+
{"diff": "diff --git a/file112.js b/file112.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
114 |
+
{"diff": "diff --git a/file113.js b/file113.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
115 |
+
{"diff": "diff --git a/file114.js b/file114.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
116 |
+
{"diff": "diff --git a/file115.js b/file115.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
117 |
+
{"diff": "diff --git a/file116.js b/file116.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
118 |
+
{"diff": "diff --git a/file117.js b/file117.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
119 |
+
{"diff": "diff --git a/file118.js b/file118.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
120 |
+
{"diff": "diff --git a/file119.js b/file119.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
121 |
+
{"diff": "diff --git a/file120.js b/file120.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
122 |
+
{"diff": "diff --git a/file121.js b/file121.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
123 |
+
{"diff": "diff --git a/file122.js b/file122.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
124 |
+
{"diff": "diff --git a/file123.js b/file123.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
125 |
+
{"diff": "diff --git a/file124.js b/file124.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
126 |
+
{"diff": "diff --git a/file125.js b/file125.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
127 |
+
{"diff": "diff --git a/file126.js b/file126.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
128 |
+
{"diff": "diff --git a/file127.js b/file127.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
129 |
+
{"diff": "diff --git a/file128.js b/file128.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
130 |
+
{"diff": "diff --git a/file129.js b/file129.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
131 |
+
{"diff": "diff --git a/file130.js b/file130.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
132 |
+
{"diff": "diff --git a/file131.js b/file131.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
133 |
+
{"diff": "diff --git a/file132.js b/file132.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
134 |
+
{"diff": "diff --git a/file133.js b/file133.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
135 |
+
{"diff": "diff --git a/file134.js b/file134.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
136 |
+
{"diff": "diff --git a/file135.js b/file135.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
137 |
+
{"diff": "diff --git a/file136.js b/file136.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
138 |
+
{"diff": "diff --git a/file137.js b/file137.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
139 |
+
{"diff": "diff --git a/file138.js b/file138.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
140 |
+
{"diff": "diff --git a/file139.js b/file139.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
141 |
+
{"diff": "diff --git a/file140.js b/file140.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
142 |
+
{"diff": "diff --git a/file141.js b/file141.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
143 |
+
{"diff": "diff --git a/file142.js b/file142.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
144 |
+
{"diff": "diff --git a/file143.js b/file143.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
145 |
+
{"diff": "diff --git a/file144.js b/file144.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
146 |
+
{"diff": "diff --git a/file145.js b/file145.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
147 |
+
{"diff": "diff --git a/file146.js b/file146.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
148 |
+
{"diff": "diff --git a/file147.js b/file147.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
149 |
+
{"diff": "diff --git a/file148.js b/file148.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
150 |
+
{"diff": "diff --git a/file149.js b/file149.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
151 |
+
{"diff": "diff --git a/file150.js b/file150.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
152 |
+
{"diff": "diff --git a/file151.js b/file151.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
153 |
+
{"diff": "diff --git a/file152.js b/file152.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
154 |
+
{"diff": "diff --git a/file153.js b/file153.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
155 |
+
{"diff": "diff --git a/file154.js b/file154.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
156 |
+
{"diff": "diff --git a/file155.js b/file155.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
157 |
+
{"diff": "diff --git a/file156.js b/file156.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
158 |
+
{"diff": "diff --git a/file157.js b/file157.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
159 |
+
{"diff": "diff --git a/file158.js b/file158.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
160 |
+
{"diff": "diff --git a/file159.js b/file159.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
161 |
+
{"diff": "diff --git a/file160.js b/file160.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
162 |
+
{"diff": "diff --git a/file161.js b/file161.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
163 |
+
{"diff": "diff --git a/file162.js b/file162.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
164 |
+
{"diff": "diff --git a/file163.js b/file163.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
165 |
+
{"diff": "diff --git a/file164.js b/file164.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
166 |
+
{"diff": "diff --git a/file165.js b/file165.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
167 |
+
{"diff": "diff --git a/file166.js b/file166.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
168 |
+
{"diff": "diff --git a/file167.js b/file167.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
169 |
+
{"diff": "diff --git a/file168.js b/file168.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
170 |
+
{"diff": "diff --git a/file169.js b/file169.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
171 |
+
{"diff": "diff --git a/file170.js b/file170.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
172 |
+
{"diff": "diff --git a/file171.js b/file171.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
173 |
+
{"diff": "diff --git a/file172.js b/file172.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
174 |
+
{"diff": "diff --git a/file173.js b/file173.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
175 |
+
{"diff": "diff --git a/file174.js b/file174.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
176 |
+
{"diff": "diff --git a/file175.js b/file175.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
177 |
+
{"diff": "diff --git a/file176.js b/file176.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
178 |
+
{"diff": "diff --git a/file177.js b/file177.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
179 |
+
{"diff": "diff --git a/file178.js b/file178.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
180 |
+
{"diff": "diff --git a/file179.js b/file179.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
181 |
+
{"diff": "diff --git a/file180.js b/file180.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
182 |
+
{"diff": "diff --git a/file181.js b/file181.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
183 |
+
{"diff": "diff --git a/file182.js b/file182.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
184 |
+
{"diff": "diff --git a/file183.js b/file183.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
185 |
+
{"diff": "diff --git a/file184.js b/file184.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
186 |
+
{"diff": "diff --git a/file185.js b/file185.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
187 |
+
{"diff": "diff --git a/file186.js b/file186.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
188 |
+
{"diff": "diff --git a/file187.js b/file187.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
189 |
+
{"diff": "diff --git a/file188.js b/file188.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
190 |
+
{"diff": "diff --git a/file189.js b/file189.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
191 |
+
{"diff": "diff --git a/file190.js b/file190.js\n@@ -1,1 +1,1 @@\n-var count = 0\n+let count = 0\n", "comment": "Use `let` or `const` instead of `var` for block scoping."}
|
192 |
+
{"diff": "diff --git a/file191.js b/file191.js\n@@ -1,1 +1,1 @@\n-if (a == b) {\n+if (a === b) {\n", "comment": "Use strict equality `===` instead of `==`."}
|
193 |
+
{"diff": "diff --git a/file192.js b/file192.js\n@@ -1,1 +1,1 @@\n-function greet(name) { return 'Hello ' + name }\n+const greet = (name) => `Hello ${name}`;\n", "comment": "Use arrow functions and template literals for cleaner syntax."}
|
194 |
+
{"diff": "diff --git a/file193.js b/file193.js\n@@ -1,1 +1,1 @@\n-console.log('Value: ' + value)\n+console.log(`Value: ${value}`)\n", "comment": "Prefer template literals over string concatenation."}
|
195 |
+
{"diff": "diff --git a/file194.js b/file194.js\n@@ -1,1 +1,1 @@\n-for (var i = 0; i < arr.length; i++) { doSomething(arr[i]); }\n+for (const item of arr) { doSomething(item); }\n", "comment": "Use `for...of` with `const` for cleaner iteration."}
|
196 |
+
{"diff": "diff --git a/file195.js b/file195.js\n@@ -1,1 +1,1 @@\n-function add(a, b) { return a + b }\n+function add(a = 0, b = 0) { return a + b; }\n", "comment": "Provide default parameter values to avoid `undefined`."}
|
197 |
+
{"diff": "diff --git a/file196.js b/file196.js\n@@ -1,1 +1,1 @@\n-const result = x ? x : 10\n+const result = x || 10;\n", "comment": "Use logical OR `||` for default values."}
|
198 |
+
{"diff": "diff --git a/file197.js b/file197.js\n@@ -1,1 +1,1 @@\n-let obj = { a: a, b: b }\n+let obj = { a, b };\n", "comment": "Use object property shorthand when key and variable name match."}
|
199 |
+
{"diff": "diff --git a/file198.js b/file198.js\n@@ -1,1 +1,1 @@\n-if (!Array.isArray(items)) { return false }\n+if (!Array.isArray(items)) return false;\n", "comment": "Use concise single-line `if` statements for simple returns."}
|
200 |
+
{"diff": "diff --git a/file199.js b/file199.js\n@@ -1,1 +1,1 @@\n-var sum = 0;\narr.forEach(function(n) { sum += n; });\n+const sum = arr.reduce((acc, n) => acc + n, 0);\n", "comment": "Use `Array.prototype.reduce` instead of manual accumulation."}
|
requirements.txt
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
transformers
|
2 |
accelerate
|
3 |
-
torch
|
4 |
-
gradio
|
|
|
|
|
|
1 |
transformers
|
2 |
accelerate
|
3 |
+
torch
|
4 |
+
gradio
|
5 |
+
trl
|
6 |
+
datasets
|
train_sft.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
from trl import SFTTrainer, SFTTrainingArguments
|
4 |
+
|
5 |
+
MODEL_ID = "Salesforce/codegen-350M-multi"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
|
8 |
+
|
9 |
+
# 1) load your local JSONL
|
10 |
+
ds = load_dataset("json", data_files="data/train_dataset.jsonl", split="train")
|
11 |
+
|
12 |
+
# 2) tokenize & format
|
13 |
+
def tokenize(example):
|
14 |
+
prompt = f"DIFF:\n{example['diff']}\n\nOUTPUT FORMAT:\n"
|
15 |
+
output = example['comments']
|
16 |
+
text = prompt + tokenizer.decode(tokenizer.encode(str(output), add_special_tokens=False))
|
17 |
+
tokens = tokenizer(text, truncation=True, max_length=512)
|
18 |
+
tokens["labels"] = tokens["input_ids"].copy()
|
19 |
+
return tokens
|
20 |
+
|
21 |
+
ds = ds.map(tokenize, remove_columns=ds.column_names, batched=False)
|
22 |
+
|
23 |
+
# 3) SFT arguments
|
24 |
+
training_args = SFTTrainingArguments(
|
25 |
+
output_dir="sft-model",
|
26 |
+
per_device_train_batch_size=2,
|
27 |
+
gradient_accumulation_steps=8,
|
28 |
+
learning_rate=2e-5,
|
29 |
+
max_train_steps=500,
|
30 |
+
logging_steps=50,
|
31 |
+
save_steps=200
|
32 |
+
)
|
33 |
+
|
34 |
+
# 4) kick off the trainer
|
35 |
+
trainer = SFTTrainer(model, tokenizer, args=training_args, train_dataset=ds)
|
36 |
+
trainer.train()
|
37 |
+
trainer.save_model("sft-model")
|