pub struct LcovData {
pub functions: HashMap<PathBuf, Vec<FunctionCoverage>>,
pub total_lines: usize,
pub lines_hit: usize,
/* private fields */
}Expand description
Parsed LCOV coverage data.
Contains all coverage information extracted from an LCOV file, organized by file path for efficient lookup. Includes a pre-built index for O(1) function coverage lookups.
§Thread Safety
The coverage_index is wrapped in Arc for lock-free sharing across
threads during parallel analysis operations.
§Example
use std::path::Path;
use debtmap::risk::lcov::{parse_lcov_file, LcovData};
let data = parse_lcov_file(Path::new("coverage.info"))?;
println!("Total lines: {}", data.total_lines);
println!("Lines hit: {}", data.lines_hit);
println!("Coverage: {:.1}%", data.get_overall_coverage());Fields§
§functions: HashMap<PathBuf, Vec<FunctionCoverage>>Map of file paths to their function coverage data
total_lines: usizeTotal number of executable lines across all files
lines_hit: usizeNumber of lines that were executed
Implementations§
Source§impl LcovData
impl LcovData
Sourcepub fn with_loc_counter(self, loc_counter: LocCounter) -> Self
pub fn with_loc_counter(self, loc_counter: LocCounter) -> Self
Sourcepub fn loc_counter(&self) -> Option<&LocCounter>
pub fn loc_counter(&self) -> Option<&LocCounter>
Get the LOC counter instance if set.
Sourcepub fn recalculate_with_loc_counter(&mut self)
pub fn recalculate_with_loc_counter(&mut self)
Recalculate total lines using LOC counter for consistency.
This ensures coverage denominator matches the LOC count used elsewhere. Useful when you want the coverage percentage to align with LOC-based metrics.
Sourcepub fn get_function_coverage(
&self,
file: &Path,
function_name: &str,
) -> Option<f64>
pub fn get_function_coverage( &self, file: &Path, function_name: &str, ) -> Option<f64>
Get function coverage using O(1) indexed lookup.
This method uses the pre-built coverage index for fast lookups, avoiding the O(n) linear search through function arrays.
§Arguments
file- Path to the source filefunction_name- Name of the function
§Returns
Coverage as a fraction (0.0 to 1.0), or None if not found.
Sourcepub fn get_function_coverage_with_line(
&self,
file: &Path,
function_name: &str,
line: usize,
) -> Option<f64>
pub fn get_function_coverage_with_line( &self, file: &Path, function_name: &str, line: usize, ) -> Option<f64>
Get function coverage with line number fallback using O(log n) indexed lookup.
Tries exact function name match first (O(1)), then falls back to line-based lookup (O(log n)) if needed.
§Arguments
file- Path to the source filefunction_name- Name of the functionline- Line number for fallback lookup
§Returns
Coverage as a fraction (0.0 to 1.0), or None if not found.
Sourcepub fn get_function_coverage_with_bounds(
&self,
file: &Path,
function_name: &str,
_start_line: usize,
_end_line: usize,
) -> Option<f64>
pub fn get_function_coverage_with_bounds( &self, file: &Path, function_name: &str, _start_line: usize, _end_line: usize, ) -> Option<f64>
Get function coverage using exact boundaries from AST analysis.
This is more accurate than guessing boundaries from LCOV data alone. Uses path normalization (Spec 201) and function name matching (Spec 202) to find the correct function even when names don’t match exactly.
Integration of Specs 201, 202, and 203:
- Uses path normalization (Spec 201) to find matching files
- Uses function name matching (Spec 202) to find matching functions
- Returns 0.0 instead of None when LCOV provided but function not found (Spec 203)
- Logs diagnostics when DEBTMAP_COVERAGE_DEBUG is set (Spec 203)
§Arguments
file- Path to the source filefunction_name- Name of the function_start_line- Start line (reserved for future use)_end_line- End line (reserved for future use)
§Returns
Coverage as a fraction (0.0 to 1.0), or None if file not in LCOV data. Returns Some(0.0) if file is in LCOV but function not found.
Sourcepub fn get_overall_coverage(&self) -> f64
pub fn get_overall_coverage(&self) -> f64
Sourcepub fn get_file_coverage(&self, file: &Path) -> Option<f64>
pub fn get_file_coverage(&self, file: &Path) -> Option<f64>
Sourcepub fn get_function_uncovered_lines(
&self,
file: &Path,
function_name: &str,
line: usize,
) -> Option<Vec<usize>>
pub fn get_function_uncovered_lines( &self, file: &Path, function_name: &str, line: usize, ) -> Option<Vec<usize>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LcovData
impl RefUnwindSafe for LcovData
impl Send for LcovData
impl Sync for LcovData
impl Unpin for LcovData
impl UnsafeUnpin for LcovData
impl UnwindSafe for LcovData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnsureExt<T> for T
impl<T> EnsureExt<T> for T
Source§fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
Source§fn ensure_with<P, E, F>(
self,
predicate: P,
error_fn: F,
) -> Validation<T, NonEmptyVec<E>>
fn ensure_with<P, E, F>( self, predicate: P, error_fn: F, ) -> Validation<T, NonEmptyVec<E>>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more