pi-lens 2.0.7 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/clients/ast-grep-client.test.ts +146 -116
- package/clients/ast-grep-client.ts +645 -551
- package/clients/biome-client.test.ts +154 -137
- package/clients/biome-client.ts +397 -337
- package/clients/complexity-client.test.ts +188 -200
- package/clients/complexity-client.ts +815 -667
- package/clients/dependency-checker.test.ts +55 -55
- package/clients/dependency-checker.ts +358 -333
- package/clients/go-client.test.ts +121 -111
- package/clients/go-client.ts +218 -216
- package/clients/jscpd-client.test.ts +132 -132
- package/clients/jscpd-client.ts +155 -118
- package/clients/knip-client.test.ts +123 -133
- package/clients/knip-client.ts +231 -218
- package/clients/metrics-client.test.ts +171 -167
- package/clients/metrics-client.ts +283 -252
- package/clients/ruff-client.test.ts +128 -117
- package/clients/ruff-client.ts +300 -269
- package/clients/rust-client.test.ts +104 -85
- package/clients/rust-client.ts +241 -234
- package/clients/subprocess-client.ts +1 -1
- package/clients/test-runner-client.test.ts +248 -215
- package/clients/test-runner-client.ts +728 -608
- package/clients/test-utils.ts +10 -3
- package/clients/todo-scanner.test.ts +288 -202
- package/clients/todo-scanner.ts +225 -187
- package/clients/type-coverage-client.test.ts +119 -119
- package/clients/type-coverage-client.ts +142 -115
- package/clients/types.ts +28 -28
- package/clients/typescript-client.test.ts +99 -93
- package/clients/typescript-client.ts +527 -502
- package/index.ts +662 -212
- package/package.json +1 -1
- package/tsconfig.json +12 -12
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { GoClient } from "./go-client.js";
|
|
3
|
-
import { setupTestEnvironment } from "./test-utils.js";
|
|
4
1
|
import * as fs from "node:fs";
|
|
5
2
|
import * as path from "node:path";
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
4
|
+
import { GoClient } from "./go-client.js";
|
|
5
|
+
import { setupTestEnvironment } from "./test-utils.js";
|
|
6
6
|
|
|
7
7
|
describe("GoClient", () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
8
|
+
let client: GoClient;
|
|
9
|
+
let tmpDir: string;
|
|
10
|
+
let cleanup: () => void;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
client = new GoClient();
|
|
14
|
+
({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-go-test-"));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
cleanup();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
cleanup();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("isGoFile", () => {
|
|
26
|
+
it("should recognize Go files", () => {
|
|
27
|
+
expect(client.isGoFile("main.go")).toBe(true);
|
|
28
|
+
expect(client.isGoFile("handler.go")).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should not recognize non-Go files", () => {
|
|
32
|
+
expect(client.isGoFile("main.ts")).toBe(false);
|
|
33
|
+
expect(client.isGoFile("main.py")).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("isGoAvailable", () => {
|
|
38
|
+
it("should check Go availability", () => {
|
|
39
|
+
const available = client.isGoAvailable();
|
|
40
|
+
expect(typeof available).toBe("boolean");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("isGoplsAvailable", () => {
|
|
45
|
+
it("should check gopls availability", () => {
|
|
46
|
+
const available = client.isGoplsAvailable();
|
|
47
|
+
expect(typeof available).toBe("boolean");
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("checkFile", () => {
|
|
52
|
+
it("should return empty array for non-existent files", () => {
|
|
53
|
+
if (!client.isGoAvailable()) return;
|
|
54
|
+
const result = client.checkFile("/nonexistent/file.go");
|
|
55
|
+
expect(result).toEqual([]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should return array for valid Go files", () => {
|
|
59
|
+
if (!client.isGoAvailable()) return;
|
|
60
|
+
|
|
61
|
+
const content = `
|
|
62
62
|
package main
|
|
63
63
|
|
|
64
64
|
import "fmt"
|
|
@@ -67,67 +67,77 @@ func main() {
|
|
|
67
67
|
fmt.Println("Hello, World!")
|
|
68
68
|
}
|
|
69
69
|
`;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const filePath = path.join(tmpDir, "main.go");
|
|
71
|
+
fs.writeFileSync(filePath, content);
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const result = client.checkFile(filePath);
|
|
74
|
+
expect(Array.isArray(result)).toBe(true);
|
|
75
|
+
});
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
it("should detect syntax errors", () => {
|
|
78
|
+
if (!client.isGoAvailable()) return;
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
const content = `
|
|
81
81
|
package main
|
|
82
82
|
|
|
83
83
|
func main() {
|
|
84
84
|
fmt.Println("missing import"
|
|
85
85
|
}
|
|
86
86
|
`;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
87
|
+
const filePath = path.join(tmpDir, "main.go");
|
|
88
|
+
fs.writeFileSync(filePath, content);
|
|
89
|
+
|
|
90
|
+
const result = client.checkFile(filePath);
|
|
91
|
+
// go vet should catch syntax issues
|
|
92
|
+
expect(Array.isArray(result)).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe("formatDiagnostics", () => {
|
|
97
|
+
it("should format diagnostics for display", () => {
|
|
98
|
+
const diags = [
|
|
99
|
+
{
|
|
100
|
+
line: 5,
|
|
101
|
+
column: 2,
|
|
102
|
+
endLine: 5,
|
|
103
|
+
endColumn: 10,
|
|
104
|
+
severity: "error" as const,
|
|
105
|
+
message: "undefined: fmt",
|
|
106
|
+
file: "main.go",
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const formatted = client.formatDiagnostics(diags);
|
|
111
|
+
expect(formatted).toContain("Go");
|
|
112
|
+
expect(formatted).toContain("1 issue");
|
|
113
|
+
expect(formatted).toContain("undefined: fmt");
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("should show error and warning counts", () => {
|
|
117
|
+
const diags = [
|
|
118
|
+
{
|
|
119
|
+
line: 1,
|
|
120
|
+
column: 0,
|
|
121
|
+
endLine: 1,
|
|
122
|
+
endColumn: 10,
|
|
123
|
+
severity: "error" as const,
|
|
124
|
+
message: "Error",
|
|
125
|
+
file: "test.go",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
line: 2,
|
|
129
|
+
column: 0,
|
|
130
|
+
endLine: 2,
|
|
131
|
+
endColumn: 10,
|
|
132
|
+
severity: "warning" as const,
|
|
133
|
+
message: "Warning",
|
|
134
|
+
file: "test.go",
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
const formatted = client.formatDiagnostics(diags);
|
|
139
|
+
expect(formatted).toContain("1 error(s)");
|
|
140
|
+
expect(formatted).toContain("1 warning(s)");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
133
143
|
});
|