Skip to content

DelightfulGames/vscode-code-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š VS Code Code Counter

Transform your code visibility with intelligent line counting, visual indicators, and comprehensive reporting

Version VS Code Marketplace License: MIT Downloads VS Code Rating TypeScript Build Status Tests Coverage GitHub Issues GitHub Stars GitHub Forks

๐Ÿš€ What Makes Code Counter Special?

A Visual Studio Code extension that counts lines of code in your project and generates beautiful HTML reports with XML data sources. Features intelligent file explorer integration with customizable emoji indicators, performance-optimized caching, and support for 78+ programming languages and file types.

๐ŸŽ‰ MAJOR RELEASE v1.1.0: Revolutionary language support expansion with systematic coverage across all major programming paradigms! Now supporting 78+ languages from web development to enterprise systems. See CHANGELOG.md for complete details.

๐Ÿ“ธ See It In Action

Before VS Code Code Counter

๐Ÿ“ src/
โ”œโ”€โ”€ service.ts
โ”œโ”€โ”€ utils.ts 
โ””โ”€โ”€ ๐Ÿ“ components/
    โ””โ”€โ”€ legacy.ts

After VS Code Code Counter

๐Ÿ“ src/                ๐ŸŸจ๐Ÿ”ด # (avg 917 lines, max 2,847 lines)
โ”œโ”€โ”€ service.ts            ๐ŸŸข # (156 lines)
โ”œโ”€โ”€ utils.ts              ๐ŸŸข # (42 lines)
โ””โ”€โ”€ ๐Ÿ“ components/     ๐ŸŸฅ๐Ÿ”ด # (avg 2,847 lines, max 2,847 lines)  
    โ””โ”€โ”€ legacy.ts         ๐Ÿ”ด # (2,847 lines)

๐ŸŽฏ Instant Visual Feedback

See Code Counter in Action

โ–ถ๏ธ Click to watch on YouTube

๐Ÿ“Š Professional reporting tools

See Code Counter Reports

โ–ถ๏ธ Click to watch on YouTube

๐Ÿ–ฅ๏ธ Standalone reports and data export

๐ŸŽฏ Perfect For

Role Primary Benefit
Software Developer Real-time complexity feedback during coding
Solution Architect Project-wide code quality metrics
Team Lead Standardized complexity indicators across team
DevOps Engineer Automated reporting for CI/CD pipelines
Technical Writer Code statistics for documentation
Open Source Maintainer Contributor-friendly project insights

โœจ Key Highlights

  • Live Status Bar: Current file metrics at a glance
  • Emoji Indicators: ๐ŸŸข๐ŸŸก๐Ÿ”ด badges for instant complexity assessment
  • File Explorer Integration: Visual cues directly in your project tree
  • Activate: Extension activates automatically on startup

๐Ÿ“‹ Table of Contents

โœจ Key Features

  • ๐Ÿ—„๏ธ Database-Powered: Lightning-fast SQLite database replaces scattered JSON files (10-100x performance boost)
  • ๐Ÿ“ Organized Structure: All extension data in clean .vscode/code-counter/ directory with reports in reports/ subfolder
  • ๐ŸŽฏ Context Menu Magic: Right-click any file/folder for instant exclusion management
  • ๐Ÿ“Š Professional Reporting: Advanced standalone HTML reports with interactive filtering, grouping, and multiple export formats
  • ๐ŸŽจ Enhanced UI Controls: Group by language/directory, advanced filtering, and export to CSV/JSON/XML
  • ๐Ÿ”ง Directory Management: Smart directory filtering with expand/collapse controls and hidden directory toggle
  • For Architects: Comprehensive project analytics with minified, self-contained reports
  • For Developers: Real-time visual feedback on code complexity with fun emoji indicators
  • For Teams: Standardized code metrics with professional export capabilities
  • For VS Code Enthusiasts: Professional-grade extension with cutting-edge reporting features

Quick Start

  1. Install: Search "Code Counter" in VS Code Extensions
  2. Activate: Extension activates automatically on startup
  3. Customize: Press Ctrl+Shift+P โ†’ "CodeCounter: Customize Emoji Indicators"
  4. View: See emoji badges (๐ŸŸข๐ŸŸก๐Ÿ”ด) next to files in explorer
  5. Reports: Run "Count Lines of Code" command for professional interactive HTML reports
  6. Export: Use webView "Export HTML" for standalone reports with filtering and export capabilities

๐Ÿ—„๏ธ Database-Powered Performance

v1.0.0 introduces revolutionary SQLite database architecture:

  • Lightning Fast: 10-100x performance boost over JSON files
  • Zero Dependencies: Pure JavaScript sql.js - no native compilation required
  • Organized Structure: All extension data in .vscode/code-counter/
    • code-counter.db - High-performance SQLite settings database
    • reports/ - All your HTML/XML/JSON reports
  • Automatic Migration: Seamlessly imports existing .code-counter.json files
  • Hierarchical Inheritance: Workspace settings cascade to subdirectories

โœจ Key Highlights

  • โš™๏ธ Hierarchical Workspace Settings: Workspace/Directory-specific configurations with inheritance
  • โš™๏ธ๐ŸŽจ Emoji Customization: Choose ANY emoji for your line count thresholds
  • ๐Ÿ“ Glob Pattern Manager: Visual interface for managing file exclusion patterns
  • โŒจ๏ธ Language Support: 78+ programming languages and file types
  • ๐Ÿ” Smart Search: Find emojis by typing "smile", "heart", "circle", etc.
  • ๐Ÿง  Smart Exclusions: Configurable patterns (node_modules, build files, etc.)
  • โšก Performance First: Intelligent caching and real-time updates
  • ๐Ÿ“Š Professional Reports: Interactive HTML reports with grouping, filtering, and multi-format exports
  • ๐ŸŽ›๏ธ Advanced UI Controls: Group by language/directory, expand/collapse trees, smart filtering
  • ๐Ÿ”ง WebView Enhancements: Export HTML with same professional quality as command palette reports
  • ๐ŸŽฏ 127-Line Rule: Based on proven software engineering principles
  • ๐ŸŽจ Theme Integration: Respects VS Code's color schemes

Backstory

๐ŸŽจ A long time ago (in technology generations), someone ran a statistical test to see how many lines of code a single file could contain that a single developer could "eyeball" and ensure working code; that number was about 127 lines. In other words, a single developer could ensure "bug-free" code by segmenting code and organizing it so that files have ~127 lines on average. It's one of those good "rules of thumb" behaviors that's learned (typically through debug hell) the hard way. That's where CodeCounter comes in. Simply, it counts lines in files, and alerts users that documents are getting too large for human consumption. It's not meant as a strict limitation for files, but is useful metadata about the file that coders/writers can use to organize their data in the best possible manner.

Features

  • Flexible Thresholds: Configure your own complexity boundaries
  • Emoji Customization: Choose your preferred indicator system

๐Ÿ—๏ธ Database-Powered Workspace Settings

v1.0.0: Revolutionary SQLite-powered configuration management

High-Performance Configuration

  • Lightning-fast SQLite database replaces scattered JSON files
  • 10-100x performance improvement for settings lookup
  • All configuration data centralized in .vscode/code-counter/code-counter.db
  • Atomic operations prevent configuration corruption

Smart Settings Management

  • Unified settings interface through webview
  • Real-time emoji customization with live preview
  • Advanced glob pattern management with validation
  • Automatic migration from legacy JSON configurations

Professional Organization

  • All extension data organized in .vscode/code-counter/ directory
  • Separate reports/ subfolder for HTML/XML output
  • Clean workspace with no scattered configuration files
  • Easy backup and synchronization of all extension data

๐Ÿ“ˆ Professional Reporting & Analytics

๐ŸŽฏ Advanced Standalone HTML Reports

  • ๐Ÿ“Š Interactive Tables: Sortable, filterable tables with real-time search
  • ๐ŸŽ›๏ธ Group Controls: Group by language or directory with one-click buttons
  • ๐Ÿ” Advanced Filtering: Filter by language, line count ranges, and file size
  • ๐Ÿงน Clear Functions: Reset all filters and grouping with a single button
  • ๐Ÿ“ฑ Responsive Design: Professional layout that works across all screen sizes

๐Ÿš€ Enhanced Export Capabilities

  • ๐Ÿ“Š Multiple Formats: Export to CSV, JSON, and XML with consistent data structure
  • โšก Professional Minification: Optimized HTML with terser, clean-css, and html-minifier-terser
  • ๐Ÿ“ฆ Self-Contained Reports: Standalone HTML files with all dependencies embedded
  • ๐Ÿ”— Export Integration: WebView and standalone reports use the same professional generation pipeline
  • ๐Ÿ“‹ Metadata Support: All exports include "Generated At" timestamps for tracking

๐ŸŽจ WebView Enhancements

  • ๐Ÿ“ Smart Directory Management: Filter directories with "All", "All + Hidden", and "Active" modes
  • ๐Ÿ—‚๏ธ Expand/Collapse Controls: Individual directory expansion with โ–ถ/โ–ผ glyphs
  • ๐Ÿ”ง Bulk Operations: "Expand All" and "Collapse All" buttons for quick navigation
  • ๐Ÿ‘๏ธ Hidden Directory Toggle: Show/hide hidden directories and their subdirectories
  • โš™๏ธ Settings Organization: Clean, organized settings interface with hierarchical directory display

๐Ÿ“Š Comprehensive Analytics

  • ๐Ÿ“Š Count Lines of Code: Analyzes all files in your workspace with smart caching
  • ๐Ÿ“ˆ Detailed Statistics: Shows code lines, comment lines, and blank lines separately
  • ๐Ÿ“„ Enhanced HTML Reports: Beautiful, interactive HTML reports with intelligent path display system
    • ๐Ÿ“ Smart Path Toggle: Interactive button to show/hide full directory paths
    • ๐ŸŽฏ Optimized Layout: Clean filename display with expandable path information
    • ๐Ÿ’พ Persistent Preferences: Remembers your path display choice across sessions
  • ๐Ÿ—‚๏ธ Enhanced XML Data: Comprehensive XML exports with streamlined data structure
    • ๐Ÿ“ Clean Data Format: Optimized structure focusing on essential information
    • ๐Ÿ”„ Consistent Exports: Unified data format across CSV, JSON, and XML exports
  • โšก Performance Optimized: Only recalculates on file save, not every keystroke
  • ๐ŸŽฏ Glob Exclusions: Exclude files and directories using customizable glob patterns

๐Ÿ—๏ธ For Software Architects & Team Leads

Project Health Monitoring

  • ๐ŸŽจ Visual Indicators: Customizable emoji indicators next to files in explorer (๐ŸŸข๐ŸŸก๐Ÿ”ด by default)
  • ๐Ÿ“‹ Status Bar Integration: Live line counts for active files with hover tooltips
  • ๐Ÿ“ File Explorer Integration: Non-intrusive indicators that don't interfere with Git colors

Standardized Metrics

  • Cross-Project Consistency: Same metrics across all codebases

Production-Grade Quality

  • Team Alignment: Visual indicators everyone understands
  • Technical Debt Tracking: Identify refactoring candidates
  • Documentation Integration: Embed reports in architecture docs
  • โœ… 261/261 Tests Passing - Comprehensive test coverage with all features tested
  • โœ… 41% Code Coverage - Real metrics, not estimates```
  • โœ… TypeScript 5.2+ - Modern, type-safe codebase
  • โœ… Zero Dependencies - Lightweight and secure

Advanced Technical Features

  • Comprehensive VS Code API Mock: 15+ API surfaces for testing
  • Intelligent File Watching: Performance-optimized change detection
  • Memory Efficient: Proper resource disposal and caching
  • Extensible Architecture: Clean service-based design

Installation

From VS Code Marketplace (Recommended)

  1. Open VS Code
  2. Go to Extensions view (Ctrl+Shift+X)
  3. Search for "Code Counter"
  4. Click "Install" on the DelightfulGames.vscode-code-counter extension

๐Ÿ› ๏ธ For VS Code Extension Enthusiasts

From Command Line

install-extension DelightfulGames.vscode-code-counter

Manual Installation

  1. Download the latest .vsix file from GitHub Releases
  2. Run: code --install-extension vscode-code-counter-*.vsix

Usage

Commands - Command Palette (Ctrl+Shift+P)

  • Manually trigger line counting and report generation
    • โ†’ Code Counter: Count Lines of Code (codeCounter.countLines)
  • Opens comprehensive settings interface featuring:
    • โ†’ Code Counter: Customize Emoji Indicators (codeCounter.openSettings)
  • Reset the plugin to the defaults
    • โ†’ Code Counter: Reset Emoji Indicators to Defaults (codeCounter.resetBadgeSettings)

Context Menu Commands

Right-click on files or folders in the File Explorer or Editor Tab to access exclusion commands:

  • CodeCounter: Exclude This File/Folder: Adds the relative path to workspace settings
  • CodeCounter: Exclude Files/Folders with Same Name: Adds a global pattern (e.g., **/README.md) to exclude all files with the same name
  • CodeCounter: Exclude Files with Same Extension: Adds a global pattern (e.g., **/*.log) to exclude all files with the same extension

๐Ÿ’ก Smart Configuration: Exclusion patterns are managed through the SQLite database in .vscode/code-counter/code-counter.db. The settings webview and file decorators automatically refresh when exclusion patterns are added through context menus.

UI Integration

File Explorer Integration

  • Emoji Badge Indicators: Visual badges (๐ŸŸข๐ŸŸก๐Ÿ”ด๐ŸŸฉ๐ŸŸจ๐ŸŸฅ) that don't interfere with Git status colors
  • Non-Intrusive Design: File names keep their normal colors (green for new, red for modified, etc.)
  • Smart Updates: Only recalculates on file save, not every keystroke
  • Hover Tooltips: Simple "Lines: X" format for consistency

Status Bar Integration

  • Live Display: Shows line count for active file with badge
  • Hover Tooltips: Simple "Lines: X" format for consistency

Smart Emoji Badge Selection

The extension provides comprehensive emoji customization options:

See Code Counter Emojis

  • Universal Emoji Support: Choose ANY emoji for your line count thresholds
  • Professional Emoji Picker: Search through 1800+ emojis by name and aliases
  • Searchable Database: Find emojis by typing "smile", "heart", "circle", "warning", etc.
  • Category Organization: Browse emojis by category (Smileys, Symbols, Objects, etc.)
    • Examples:
      • Traditional: ๐ŸŸข ๐ŸŸก ๐Ÿ”ด (traffic light system)
      • Creative: ๐ŸŽฏ ๐Ÿ”ฅ ๐Ÿ’ฏ (target/performance theme)
      • Professional: โœ… โš ๏ธ โŒ (status indicators)
      • Fun: ๐Ÿ˜Š ๐Ÿ˜ ๐Ÿ˜ฑ (emotion-based)
  • Unified Configuration: Set both emoji badges AND thresholds in one interface
  • Flexible Thresholds: Configure exact line count boundaries for each badge level
  • WebView Interface: Professional emoji picker with search and live preview

Glob Pattern Management

Manage file exclusion patterns through the enhanced settings interface:

  • ๐Ÿ“ Visual Pattern Manager: Add/remove glob patterns with intuitive interface
  • โœ… Pattern Validation: Real-time validation prevents invalid glob patterns
  • ๐Ÿ“– Built-in Examples: Common patterns like **/node_modules/**, **/*.tmp
  • ๐Ÿ”„ Easy Reset: Restore default exclusion patterns with one click
  • ๐ŸŽฏ Smart Defaults: Pre-configured to exclude common build artifacts and dependencies
  • ๐Ÿ’ก Interactive Help: Expandable examples section with pattern explanations
  • โŒจ๏ธ Keyboard Support: Press Enter to add patterns quickly

Configuration Options

The extension provides several configuration options to customize behavior:

Notification Settings

  • codeCounter.showNotificationOnAutoGenerate (default: false)
    • Controls whether popup notifications appear when reports are auto-generated on file save
    • Set to true to enable popup notifications with "View Report" button
    • Set to false for silent operation (recommended for focused coding)
    • ๐Ÿ’ก Tip: Use the checkbox in the settings webview (Code Counter: Customize Emoji Indicators) for easy toggling

Auto-Generation Control

  • codeCounter.autoGenerate (default: true)
    • Enable/disable automatic report generation when files are saved
    • When disabled, reports are only generated via manual command execution

Output Files

The extension generates two files in the configured output directory:

  • Intelligent Caching: Modification-time based invalidation
  1. code-counter-report.html: Interactive HTML report with charts and tables
  • Event-Driven Updates: Real-time file system watching
  1. code-counter-data.xml: XML data source for integration with other tools

๐Ÿ“Š Technical Excellence

Testing & Quality

  • Unit Tests: 261 comprehensive tests across multiple test suites covering all features
  • Integration Tests: VS Code API compatibility validation
  • Performance Tests: File system operation optimization
  • Coverage Analysis: 41% real coverage with C8 tooling

Smart Performance Features

  • Save-Based Updates: Only recalculates when files are saved, not on every keystroke
  • Selective File Watching: Only monitors relevant code files, ignores binaries and build outputs
  • Intelligent Caching: Modification time-based cache invalidation for accuracy
  • Efficient Event Handling: Debounced file system events prevent performance loops
  • Memory Management: Proper disposables prevent memory leaks
  • Battery Friendly: Minimal background processing for laptop users

Architecture Highlights

  • Service-Oriented Design: Modular, testable components
  • Memory Management: Proper disposal patterns

VS Code Integration

  • Command Palette: Full VS Code command system integration
  • Status Bar Integration: Non-intrusive information display
  • File Explorer Decorators: Native VS Code theming support
  • Configuration API: Seamless settings management

Supported Languages

The extension automatically detects and counts lines for 78+ programming languages and file types, including:

Programming Languages

  • Web Development: JavaScript, TypeScript, JSX, TSX, HTML, CSS, SCSS, Sass, Less, CoffeeScript, LiveScript
  • Systems Programming: C, C++, C#, Java, Go, Rust, Swift, Kotlin, Scala, Dart, Assembly, Zig, V, Nim, Crystal
  • Scripting & Shell: Python, Ruby, PHP, Shell, Bash, Zsh, Fish, PowerShell, Batch, AWK, Tcl
  • Functional Programming: Haskell, Erlang, Elixir, Clojure, F#, OCaml, Scheme, Racket
  • Mobile & Platform: Swift, Kotlin, Scala, Dart, Objective-C, Vala
  • Data Science & Analytics: R, MATLAB, Julia, SQL
  • Enterprise & Legacy: COBOL, Fortran, Visual Basic, Pascal, Ada, Groovy, Delphi
  • Specialized Languages: GraphQL, Protocol Buffers, ANTLR

Configuration & Data Files

  • Build & Project: CMake, Makefile, Dockerfile, TOML, YAML, JSON, XML
  • Development Tools: Environment files, Properties, GitIgnore, EditorConfig
  • Documentation: Markdown, Text, INI, Config files

๐Ÿš€ Total Coverage: 78+ languages with intelligent comment detection and proper line counting algorithms for each language family.

๐Ÿ” Visibility & Accessibility

Making Emoji Badges Bigger & Easier to See

If you find the emoji badges (๐ŸŸข๐ŸŸก๐Ÿ”ด) in the File Explorer too small or hard to distinguish, you can increase VS Code's zoom level to make them larger and more visible:

Quick Method:

  • Zoom In: Ctrl + + (Windows/Linux) or Cmd + + (Mac)
  • Zoom Out: Ctrl + - (Windows/Linux) or Cmd + - (Mac)
  • Reset Zoom: Ctrl + 0 (Windows/Linux) or Cmd + 0 (Mac)

Precise Control via Settings:

  1. Open Settings: Ctrl + , (Windows/Linux) or Cmd + , (Mac)
  2. Search: Type window.zoomLevel
  3. Adjust: Set a value like 1 (120% zoom) or 2 (140% zoom)
    • 0 = 100% (default)
    • 1 = 120% zoom
    • 2 = 140% zoom
    • 0.5 = 110% zoom (fine adjustment)

Benefits of Increased Zoom:

  • ๐Ÿ‘๏ธ Better Visibility: Emoji badges become larger and easier to distinguish
  • ๐ŸŽฏ Improved Accuracy: Easier to spot complexity hotspots at a glance
  • โ™ฟ Accessibility: Better for users who prefer larger interface elements
  • ๐Ÿ–ฅ๏ธ High-DPI Displays: Especially helpful on high-resolution monitors

๐Ÿ’ก Pro Tip: The zoom level affects the entire VS Code interface, making not just emoji badges but all text and UI elements larger and more comfortable to work with!

Report Features

๐ŸŽฏ Enhanced Path Display System

๐Ÿ’พ Smart Persistence

  • Your path display preference is automatically saved using localStorage
  • Consistent experience across all reports and browser sessions
  • No need to repeatedly adjust settings

๐ŸŽจ Optimized Design

  • Clean Layout: Filenames prominently displayed with subtle path information
  • Responsive Design: Works beautifully on all screen sizes
  • Visual Hierarchy: Clear distinction between filename and directory path

๐Ÿ“Š Multiple Export Formats

  • HTML Reports: Interactive reports with enhanced path toggle functionality
  • XML, JSON, CSV
  • Backward Compatible: Existing integrations continue to work seamlessly

๐Ÿ“ˆ Comprehensive Analytics

The generated reports include:

  • Summary Statistics: Total files, lines, languages, and averages
  • Language Breakdown: Files and lines per programming language
  • Grouping Controls: data can be grouped by directory or language
  • Enhanced File Details: Searchable table with intelligent path display and individual file statistics
  • Interactive Elements: Search, filtering, and responsive design

Contributing

We welcome contributions from developers, architects, and VS Code enthusiasts! CONTRIBUTING.md

๐Ÿ“š Documentation

Document Audience Content
๐Ÿš€ Contributing Guide Contributors Development workflow and standards
๐Ÿ“‹ Testing Guide Contributors Test execution and coverage
๐Ÿ—๏ธ Architecture Docs Developers Technical implementation details

๐Ÿ”ฎ Roadmap

  • ๐Ÿ“Š Advanced Analytics: Complexity trends over time
  • ๐Ÿค– AI Integration: Smart refactoring suggestions
  • ๐Ÿ”— Git Integration: Blame-aware complexity analysis# Lint code
  • ๐Ÿ“ฑ Web Dashboard: Team-wide project insights

โญโญโญโญโญ Star this repo if VS Code Code Counter makes your development workflow better!

Built with โค๏ธ by developers, for developers

๐Ÿค Connect With Us

License

This project is licensed under the MIT License - see the LICENSE file for full details.

What this means:

  • โœ… Free to use - Personal and commercial use allowed
  • โœ… Free to modify - Create your own versions and improvements
  • โœ… Free to distribute - Share with others, including modified versions
  • โœ… Attribution required - Just keep the original copyright notice
  • โœ… No warranty - Provided "as-is" without guarantees

TL;DR: Use it freely, modify it as needed, just give credit to the original project!