Metrics
Unentropy helps you track code metrics that matter to your project. Use built-in metrics for common indicators like coverage and bundle size, or define custom metrics specific to your needs.
Built-in Metrics
Section titled “Built-in Metrics”Unentropy includes pre-configured metric templates that work out of the box. Reference them with minimal configuration using the $ref property:
This will generate reports with two metrics: lines of code (calculated from the whole repository) and test coverage (you need to run tests first with appropriate flags).
The command property can be any shell command that outputs a single number to be tracked. @collect is a shortcut for running built-in collectors.
Coverage Metrics
Section titled “Coverage Metrics”Unentropy supports three coverage report formats. Choose the one that matches your test framework.
Available Coverage Formats
Section titled “Available Coverage Formats”| LCOV | Cobertura | Clover | |
|---|---|---|---|
| Collector | @collect coverage-lcov | @collect coverage-cobertura | @collect coverage-clover |
| File format | .lcov / lcov.info | .xml (Cobertura XML) | .xml (Clover XML) |
| Typical tools | Jest, Istanbul, nyc | PHPUnit, gcovr, OpenCppCoverage | PHPUnit, OpenClover |
| Syntax | <path> (single file) | <paths...> (single or multiple) | <paths...> (single or multiple) |
| Multi-report merge | Not supported | Supported | Supported |
| Coverage types | line, branch, function | line, branch, function | line, branch, function |
Track coverage from LCOV reports (Jest, Istanbul, nyc):
- Unit: Percent
- Note: Requires coverage report generation before metric collection
Cobertura
Section titled “Cobertura”Track coverage from Cobertura XML reports (PHPUnit, gcovr). Unlike LCOV, Cobertura supports merging multiple reports — useful when tests run in parallel CI jobs.
Pass multiple paths to merge:
Or use a glob for sharded output:
Also supports --type branch and --type function:
The merge sums covered and valid counts across all reports, then recomputes the percentage — producing a correctly weighted combined rate.
- Unit: Percent
- Note: Requires coverage report generation before metric collection
Clover
Section titled “Clover”Track coverage from Clover XML reports (PHPUnit --coverage-clover, OpenClover). Like Cobertura, Clover supports merging multiple reports.
Pass multiple paths to merge:
Or use a glob for sharded output:
Also supports --type branch and --type function:
The merge uses per-file, per-line deduplication for line coverage (unions line numbers across reports so overlapping coverage isn’t double-counted), and project-level summation for branch and function coverage.
- Unit: Percent
- Note: Requires coverage report generation before metric collection
Code Size Metrics
Section titled “Code Size Metrics”Lines of Code
Section titled “Lines of Code”Count lines of code in your project:
This uses the default command @collect loc . which counts all lines in your project.
Internally, Unentropy uses the scc tool to do the counting.
Customize the path or language:
- Unit: Integer (displays as
4,521)
Bundle Size
Section titled “Bundle Size”Track production build artifact size:
Supports glob patterns for specific files:
- Unit: Bytes (auto-scales to KB, MB, GB)
Performance Metrics
Section titled “Performance Metrics”Build Time
Section titled “Build Time”Track how long your builds take:
- Unit: Duration (auto-scales to ms, s, m, h)
- Note: No default command - too project-specific
Test Suite Duration
Section titled “Test Suite Duration”Track test execution time:
- Unit: Duration
Dependency Metrics
Section titled “Dependency Metrics”Dependency Count
Section titled “Dependency Count”Track the number of direct dependencies:
- Unit: Integer
Custom Metrics
Section titled “Custom Metrics”You can define metrics specific to your project needs:
Custom Metric Properties
Section titled “Custom Metric Properties”- type:
numeric(required) - name: Display name in reports (required)
- description: What this metric tracks (optional)
- unit: How to format values (optional, see Unit Types)
- command: Shell command that outputs the metric value (required)
Unit Types
Section titled “Unit Types”Choose the right unit for proper formatting:
| Unit | Example | Use Case |
|---|---|---|
percent | 85.5% | Coverage, ratios |
integer | 1,234 | Counts, LOC |
bytes | 1.5 MB | File sizes, bundles |
duration | 1m 30s | Build/test time |
decimal | 3.14 | Generic numbers |
Customizing built-in metrics
Section titled “Customizing built-in metrics”Override Display Name
Section titled “Override Display Name”Customize how metrics appear in reports:
Multiple Variations
Section titled “Multiple Variations”Track the same type of metric for different paths:
Each gets a unique ID from its object key, so they can be tracked separately in reports and quality gates.
The @collect Shortcut
Section titled “The @collect Shortcut”Built-in collectors run faster than shell commands because they execute in-process.
Available Collectors
Section titled “Available Collectors”@collect loc <path>
Section titled “@collect loc <path>”Count lines of code using the SCC tool:
@collect size <path1> [<path2>] [<path3>] [...]
Section titled “@collect size <path1> [<path2>] [<path3>] [...]”Calculate total file size (supports glob patterns):
@collect coverage-lcov <path>
Section titled “@collect coverage-lcov <path>”Extract coverage from LCOV format:
Options:
--type <line|branch|function>- Coverage type to extract (default:line)
@collect coverage-clover <paths...>
Section titled “@collect coverage-clover <paths...>”Extract and merge coverage from Clover XML format (PHPUnit --coverage-clover, OpenClover):
Options:
--type <line|branch|function>- Coverage type to extract (default:line)- Accepts multiple paths — line coverage uses per-file line deduplication; branch and function coverage use project-level summation
@collect coverage-cobertura <paths...>
Section titled “@collect coverage-cobertura <paths...>”Extract and merge coverage from Cobertura XML format:
Options:
--type <line|branch|function>- Coverage type to extract (default:line)- Accepts multiple paths — coverage data is merged by summing covered/valid counts across all reports
Example Configurations
Section titled “Example Configurations”JavaScript/TypeScript Project
Section titled “JavaScript/TypeScript Project”PHP Project
Section titled “PHP Project”Go Project
Section titled “Go Project”Validating Configuration
Section titled “Validating Configuration”Check your configuration before pushing to CI:
This validates:
- JSON syntax
- Required fields present
- Valid metric references
- Unit types correct
Testing Metric Collection
Section titled “Testing Metric Collection”Verify all metrics collect successfully:
Example output:
Note that test runs locally, so - depending on your configuration - you may need to run tests or build artifacts first. Code size (loc) metrics require the scc tool to be installed.
Related Resources
Section titled “Related Resources”- Configuration Reference - Complete config schema
- Quality Gates Guide - Set thresholds for metrics
- CLI Commands Reference - Test and verify commands