Stat Lens
A VS Code extension that adds a Stat Lens view to the Explorer with key figures for the open workspace:
- Lines of code (without blank lines, optionally without comment lines)
- Languages with lines, files and percentage (detected with linguist-js, so the same rules as GitHub Linguist)
- Files, folders, total size, largest file (clickable)
- Project age and last change (from Git, otherwise from file timestamps)
- Git: commits, contributors, first and last commit
- Dependencies from
package.json, requirements.txt, pyproject.toml and *.csproj
Development
Requirements: Node.js (LTS) and Git in the PATH.
npm install
npm run compile
VS Code tasks (Terminal > Run Task…):
| Task |
Purpose |
PS - Build |
type check with tsc, then bundle with esbuild into dist/ (default build task, also Ctrl+Shift+B) |
PS - Clean |
deletes out/, dist/ and all *.vsix |
PS - Rebuild |
Clean, then Build |
PS - Publish |
Rebuild, then vsce package: creates stat-lens-<version>.vsix in the project folder |
PS - Watch |
esbuild in watch mode in the background |
The .vsix can be installed via Extensions > … > Install from VSIX…. Publishing to the Marketplace additionally requires vsce publish with a Personal Access Token.
Testing in the Extension Development Host: open the project in VS Code and press F5
(launch configuration "Run Extension", runs PS - Build first). Open any folder in the new
window; the "Stat Lens" view appears in the Explorer. The refresh icon in the title bar of the
view triggers a rescan. After code changes, run Developer: Reload Window in the host window.
Testing the scanner without VS Code:
npm run scan -- <path> [--ignore-comments]
prints the scan and Git result as JSON (progress on stderr). Run npm run compile first, the CLI is bundled
into dist/cli.js together with the extension but is not part of the VSIX.
The extension is bundled with esbuild (esbuild.mjs) into a single dist/extension.js. linguist-js reads its
language data at runtime; the build copies these files to dist/linguist-data/ and points linguist-js there.
Behavior
- The first workspace folder is analyzed.
- The folders from
projectStats.excludeFolders (default: node_modules, bin, obj, .git, dist, out, .vs, .vscode) are skipped, as is everything excluded by the .gitignore in the workspace root. Binary files count towards files and size, but not towards lines of code.
- The result is cached in the
workspaceState and shown immediately the next time the workspace is opened (row "Last Scan"). A rescan happens via the refresh button or automatically 15 s after the last file system change outside the excluded folders.
projectStats.ignoreComments: lines starting with //, #, /*, *, --, <!--, ; or ' are not counted (heuristic, language independent).
- The extension is disabled in untrusted workspaces (Restricted Mode) and in virtual workspaces.
Structure
| File |
Purpose |
src/scanner.ts |
File system scan, line counting, dependencies |
src/languageMap.ts |
Language detection via linguist-js |
src/gitInfo.ts |
Git queries via git log |
src/statsProvider.ts |
TreeDataProvider and formatting |
src/extension.ts |
Activation, command, cache, watcher |
src/cli.ts |
Terminal test run without VS Code |
License
Proprietary, all rights reserved. See the LICENSE file for the terms of use. Third-party components and their
licenses are listed in THIRD_PARTY_NOTICES.md.
| |