Live Code Metrics is a VS Code extension that provides real-time analysis of function sizes in your code. Supporting JavaScript, TypeScript, Java, and Python, it helps maintain clean and maintainable code by visualizing function lengths against customizable thresholds.
- Real-time Function Analysis: Automatically detects and displays functions, methods, and classes in your open files.
- Line Count Visualization: Shows the number of lines for each code section, along with its name and location in the file.
- Progress Bar: Visual representation of how close each function is to the maximum line threshold.
- Customizable Threshold: Set your own maximum line count to suit your team's coding standards.
Maintaining smaller, focused functions in your codebase offers numerous benefits:
- Improved Readability: Shorter functions are easier to read and understand at a glance.
- Enhanced Maintainability: Smaller code units are easier to modify, test, and debug.
- Better Code Organization: Encourages breaking down complex logic into manageable pieces.
- Reduced Cognitive Load: Developers can focus on one specific task or concept at a time.
- Easier Collaboration: Smaller functions lead to fewer merge conflicts and easier code reviews.
- Increased Reusability: Well-defined, focused functions are more likely to be reusable in other parts of your codebase.
By using the Live Code Metrics extension, you're taking a proactive step towards writing cleaner, more efficient code.
- Open Visual Studio Code
- Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
- Search for "Live Code Metrics"
- Click Install
- Open a supported file (JavaScript, TypeScript, Java, or Python)
- Navigate to the Explorer tab and find the "Live Code Metrics" section
- The extension will automatically display metrics for your open file
To set a custom maximum line threshold:
- Click on the "Max lines" button in the Live Code Metrics view, or
- Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and run "Live Code Metrics: Set Max Lines Count"
You can customize the position of the Live Code Metrics view for easier access:
- Drag the Live Code Metrics view to the primary side bar to keep it always visible
- If you've moved it to the primary side bar, you can drag it back to the Explorer tab at any time
Your feedback and contributions are welcome! Please feel free to submit issues or pull requests on the GitHub repository.