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,111 +1,130 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { RustClient } from "./rust-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 { RustClient } from "./rust-client.js";
|
|
5
|
+
import { setupTestEnvironment } from "./test-utils.js";
|
|
6
6
|
|
|
7
7
|
describe("RustClient", () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
let client: RustClient;
|
|
9
|
+
let tmpDir: string;
|
|
10
|
+
let cleanup: () => void;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
client = new RustClient();
|
|
14
|
+
({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-rust-test-"));
|
|
15
|
+
});
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
cleanup();
|
|
19
|
+
});
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
cleanup();
|
|
23
|
+
});
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
describe("isRustFile", () => {
|
|
26
|
+
it("should recognize Rust files", () => {
|
|
27
|
+
expect(client.isRustFile("main.rs")).toBe(true);
|
|
28
|
+
expect(client.isRustFile("lib.rs")).toBe(true);
|
|
29
|
+
});
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
it("should not recognize non-Rust files", () => {
|
|
32
|
+
expect(client.isRustFile("main.ts")).toBe(false);
|
|
33
|
+
expect(client.isRustFile("main.py")).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
describe("isAvailable", () => {
|
|
38
|
+
it("should check cargo availability", () => {
|
|
39
|
+
const available = client.isAvailable();
|
|
40
|
+
expect(typeof available).toBe("boolean");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
describe("checkFile", () => {
|
|
45
|
+
it("should return empty array for non-existent files", () => {
|
|
46
|
+
if (!client.isAvailable()) return;
|
|
47
|
+
const result = client.checkFile("/nonexistent/file.rs", tmpDir);
|
|
48
|
+
expect(result).toEqual([]);
|
|
49
|
+
});
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
it("should return array for valid Rust files", () => {
|
|
52
|
+
if (!client.isAvailable()) return;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// Need a Cargo.toml for cargo to work
|
|
55
|
+
fs.writeFileSync(
|
|
56
|
+
path.join(tmpDir, "Cargo.toml"),
|
|
57
|
+
`
|
|
56
58
|
[package]
|
|
57
59
|
name = "test"
|
|
58
60
|
version = "0.1.0"
|
|
59
61
|
edition = "2021"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
`,
|
|
63
|
+
);
|
|
64
|
+
fs.mkdirSync(path.join(tmpDir, "src"), { recursive: true });
|
|
65
|
+
fs.writeFileSync(
|
|
66
|
+
path.join(tmpDir, "src", "main.rs"),
|
|
67
|
+
`
|
|
63
68
|
fn main() {
|
|
64
69
|
println!("Hello, world!");
|
|
65
70
|
}
|
|
66
|
-
|
|
71
|
+
`,
|
|
72
|
+
);
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
const result = client.checkFile(
|
|
75
|
+
path.join(tmpDir, "src", "main.rs"),
|
|
76
|
+
tmpDir,
|
|
77
|
+
);
|
|
78
|
+
expect(Array.isArray(result)).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
72
81
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
describe("formatDiagnostics", () => {
|
|
83
|
+
it("should format diagnostics for display", () => {
|
|
84
|
+
const diags = [
|
|
85
|
+
{
|
|
86
|
+
line: 3,
|
|
87
|
+
column: 0,
|
|
88
|
+
endLine: 3,
|
|
89
|
+
endColumn: 10,
|
|
90
|
+
severity: "error" as const,
|
|
91
|
+
message: "cannot find value `x` in this scope",
|
|
92
|
+
code: "E0425",
|
|
93
|
+
file: "main.rs",
|
|
94
|
+
},
|
|
95
|
+
];
|
|
87
96
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
const formatted = client.formatDiagnostics(diags);
|
|
98
|
+
expect(formatted).toContain("Rust");
|
|
99
|
+
expect(formatted).toContain("1 issue");
|
|
100
|
+
expect(formatted).toContain("E0425");
|
|
101
|
+
});
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
it("should show error and warning counts", () => {
|
|
104
|
+
const diags = [
|
|
105
|
+
{
|
|
106
|
+
line: 1,
|
|
107
|
+
column: 0,
|
|
108
|
+
endLine: 1,
|
|
109
|
+
endColumn: 10,
|
|
110
|
+
severity: "error" as const,
|
|
111
|
+
message: "Error",
|
|
112
|
+
file: "test.rs",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
line: 2,
|
|
116
|
+
column: 0,
|
|
117
|
+
endLine: 2,
|
|
118
|
+
endColumn: 10,
|
|
119
|
+
severity: "warning" as const,
|
|
120
|
+
message: "Warning",
|
|
121
|
+
file: "test.rs",
|
|
122
|
+
},
|
|
123
|
+
];
|
|
105
124
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
const formatted = client.formatDiagnostics(diags);
|
|
126
|
+
expect(formatted).toContain("1 error(s)");
|
|
127
|
+
expect(formatted).toContain("1 warning(s)");
|
|
128
|
+
});
|
|
129
|
+
});
|
|
111
130
|
});
|