pi-lens 1.3.12 → 1.3.13

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.
@@ -291,6 +291,17 @@ export class ComplexityClient {
291
291
  warnings.push(`High entropy (${metrics.codeEntropy.toFixed(1)} bits) — follow project conventions`);
292
292
  }
293
293
 
294
+ // Comments ratio (>30% = excessive comments, AI slop signal)
295
+ const totalLines = metrics.linesOfCode + metrics.commentLines;
296
+ if (totalLines > 10 && metrics.commentLines / totalLines > 0.3) {
297
+ warnings.push(`Excessive comments (${Math.round(metrics.commentLines / totalLines * 100)}%) — remove obvious comments`);
298
+ }
299
+
300
+ // Verbose code (long functions with low complexity = overly verbose)
301
+ if (metrics.avgFunctionLength > 30 && metrics.cyclomaticComplexity < 3) {
302
+ warnings.push(`Verbose code (avg ${Math.round(metrics.avgFunctionLength)} lines, low complexity) — simplify or extract`);
303
+ }
304
+
294
305
  return warnings;
295
306
  }
296
307
 
package/index.ts CHANGED
@@ -711,10 +711,24 @@ export default function (pi: ExtensionAPI) {
711
711
 
712
712
  const diags = tsClient.getDiagnostics(filePath);
713
713
  if (diags.length > 0) {
714
- lspOutput += `\n\n[TypeScript] ${diags.length} issue(s):\n`;
715
- for (const d of diags.slice(0, 10)) {
716
- const label = d.severity === 2 ? "Warning" : "Error";
717
- lspOutput += ` [${label}] L${d.range.start.line + 1}: ${d.message}\n`;
714
+ // Separate unused imports (TS6133, TS6196) from other diagnostics
715
+ const unusedImports = diags.filter(d => d.code === 6133 || d.code === 6196);
716
+ const otherDiags = diags.filter(d => d.code !== 6133 && d.code !== 6196);
717
+
718
+ if (unusedImports.length > 0) {
719
+ lspOutput += `\n\n[Unused Imports] ${unusedImports.length} imported but never used:\n`;
720
+ for (const d of unusedImports.slice(0, 10)) {
721
+ lspOutput += ` L${d.range.start.line + 1}: ${d.message}\n`;
722
+ }
723
+ lspOutput += ` → Remove unused imports to reduce noise\n`;
724
+ }
725
+
726
+ if (otherDiags.length > 0) {
727
+ lspOutput += `\n\n[TypeScript] ${otherDiags.length} issue(s):\n`;
728
+ for (const d of otherDiags.slice(0, 10)) {
729
+ const label = d.severity === 2 ? "Warning" : "Error";
730
+ lspOutput += ` [${label}] L${d.range.start.line + 1}: ${d.message}\n`;
731
+ }
718
732
  }
719
733
  }
720
734
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-lens",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "Real-time code feedback for pi — TypeScript LSP, Biome, ast-grep, Ruff, TODO scanner, dead code, duplicate detection, type coverage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,9 @@
1
+ id: magic-numbers
2
+ language: TypeScript
3
+ message: "Magic number detected — use a named constant"
4
+ severity: hint
5
+ note: |
6
+ Hardcoded numbers make code harder to understand and maintain.
7
+ Extract to a named constant with a descriptive name.
8
+ rule:
9
+ kind: number
@@ -0,0 +1,14 @@
1
+ id: silent-failure
2
+ language: TypeScript
3
+ message: "Silent failure detected — log or rethrow the error"
4
+ severity: warning
5
+ note: |
6
+ Empty catch blocks swallow errors silently.
7
+ Always log the error or rethrow it to aid debugging.
8
+ rule:
9
+ kind: catch_clause
10
+ has:
11
+ kind: statement_block
12
+ not:
13
+ has:
14
+ kind: throw_statement