apex-code-coverage-transformer
Version:
Transform Salesforce Apex code coverage JSONs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.
51 lines (50 loc) • 1.65 kB
TypeScript
import { SimpleCovCoverageObject } from '../utils/types.js';
import { BaseHandler } from './BaseHandler.js';
/**
* Handler for generating SimpleCov JSON coverage reports.
*
* SimpleCov is a popular Ruby code coverage tool. This format is also
* accepted by Codecov and other coverage aggregation tools.
*
* **Format Origin**: SimpleCov (Ruby coverage tool)
*
* @see https://github.com/simplecov-ruby/simplecov
* @see https://github.com/vicentllongo/simplecov-json
* @see https://docs.codecov.com/docs/codecov-uploader
*
* **Format Structure**:
* The format uses an array of hit counts per line, with null for non-executable lines.
* Array indices are 0-based (index 0 = line 1, index 1 = line 2, etc.)
*
* **Apex-Specific Adaptations**:
* - Only lines present in Apex coverage data are tracked
* - Lines not in coverage data are marked as `null` (non-executable)
* - This works well with Apex since Salesforce only reports executable lines
*
* **Advantages for Apex**:
* - Simple, compact format
* - Direct mapping from Apex line coverage to SimpleCov format
* - Well-supported by Codecov and similar platforms
*
* Compatible with:
* - Codecov
* - SimpleCov analyzers
* - Ruby coverage tools
* - Custom parsers
*
* @example
* ```json
* {
* "coverage": {
* "path/to/file.cls": [1, 1, 0, 1, null, 1]
* },
* "timestamp": 1234567890
* }
* ```
*/
export declare class SimpleCovCoverageHandler extends BaseHandler {
private readonly coverageObj;
constructor();
processFile(filePath: string, _fileName: string, lines: Record<string, number>): void;
finalize(): SimpleCovCoverageObject;
}