Java Metrics
This extension analyzes Java source files and calculates software metrics to help you understand code complexity and maintainability.
Features
- Cyclomatic Complexity
- Halstead Metrics (Length, Volume, Difficulty, etc.)
- LCOM3 (Lack of Cohesion in Methods)
- Lines of Code
Usage
- Open a Java file or project in your workspace.
- Navigate to the Metrics container on the left (ruler symbol) and click Calculate Metrics.
- A new tree representation is created from your project and displayed in the project-structure view.
- Expand and navigate the tree as usual by clicking on the arrows.
- Select an entry in the tree to display the corresponding metrics.
- Metrics are shown at the bottom of your VS Code window in the Metrics tab.
- After changing your code, re-run the command to update the metrics.
Requirements
- Only one Java project may be in your workspace.
- If there is more than one, most metrics will still work as intended. However, metrics regarding the whole project may be incorrect.
Extension Settings
Java-metrics: enabled Metrics
Select which metrics you want to be calculated and displayed from the list of available metrics.
| |