pi-lens 2.2.8 → 2.2.9

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.
@@ -68,11 +68,31 @@ const SECRET_PATTERNS = [
68
68
  message: "Possible secret in .env format",
69
69
  },
70
70
  ];
71
+ /**
72
+ * Check if file path is a test file (should skip secrets scan)
73
+ */
74
+ function isTestFile(filePath) {
75
+ const normalized = filePath.replace(/\\/g, "/");
76
+ return (normalized.includes(".test.") ||
77
+ normalized.includes(".spec.") ||
78
+ normalized.includes("/test/") ||
79
+ normalized.includes("/tests/") ||
80
+ normalized.includes("__tests__/") ||
81
+ normalized.includes("test-utils") ||
82
+ normalized.startsWith("test-") ||
83
+ normalized.includes(".fixture.") ||
84
+ normalized.includes(".mock."));
85
+ }
71
86
  /**
72
87
  * Scan content for potential secrets
73
- * Returns findings with line numbers
88
+ * Returns findings with line numbers.
89
+ * Skips test files to avoid false positives.
74
90
  */
75
- export function scanForSecrets(content) {
91
+ export function scanForSecrets(content, filePath) {
92
+ // Skip test files — secrets in tests are usually fake/test values
93
+ if (filePath && isTestFile(filePath)) {
94
+ return [];
95
+ }
76
96
  const findings = [];
77
97
  const lines = content.split("\n");
78
98
  for (let i = 0; i < lines.length; i++) {
@@ -83,11 +83,38 @@ export interface SecretFinding {
83
83
  message: string;
84
84
  }
85
85
 
86
+ /**
87
+ * Check if file path is a test file (should skip secrets scan)
88
+ */
89
+ function isTestFile(filePath: string): boolean {
90
+ const normalized = filePath.replace(/\\/g, "/");
91
+ return (
92
+ normalized.includes(".test.") ||
93
+ normalized.includes(".spec.") ||
94
+ normalized.includes("/test/") ||
95
+ normalized.includes("/tests/") ||
96
+ normalized.includes("__tests__/") ||
97
+ normalized.includes("test-utils") ||
98
+ normalized.startsWith("test-") ||
99
+ normalized.includes(".fixture.") ||
100
+ normalized.includes(".mock.")
101
+ );
102
+ }
103
+
86
104
  /**
87
105
  * Scan content for potential secrets
88
- * Returns findings with line numbers
106
+ * Returns findings with line numbers.
107
+ * Skips test files to avoid false positives.
89
108
  */
90
- export function scanForSecrets(content: string): SecretFinding[] {
109
+ export function scanForSecrets(
110
+ content: string,
111
+ filePath?: string,
112
+ ): SecretFinding[] {
113
+ // Skip test files — secrets in tests are usually fake/test values
114
+ if (filePath && isTestFile(filePath)) {
115
+ return [];
116
+ }
117
+
91
118
  const findings: SecretFinding[] = [];
92
119
  const lines = content.split("\n");
93
120
 
package/index.ts CHANGED
@@ -1303,7 +1303,7 @@ export default function (pi: ExtensionAPI) {
1303
1303
 
1304
1304
  // --- Secrets scan (blocking - must check before other linting) ---
1305
1305
  if (fileContent) {
1306
- const secretFindings = scanForSecrets(fileContent);
1306
+ const secretFindings = scanForSecrets(fileContent, filePath);
1307
1307
  if (secretFindings.length > 0) {
1308
1308
  const secretsOutput = formatSecrets(secretFindings, filePath);
1309
1309
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-lens",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "type": "module",
5
5
  "description": "Real-time code quality feedback for pi — TypeScript LSP, Biome, ast-grep, Ruff, complexity metrics, duplicate detection. Includes automated fix loop (/lens-booboo-fix) and interactive architectural refactoring (/lens-booboo-refactor) with browser-based interviews.",
6
6
  "repository": {