< Summary - Neospec Coverage

Information
Class: FileCoverage
Assembly: domain
File(s): /home/runner/work/neospec/neospec/internal/domain/coverage.go
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 81
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
HitLines0%00100%
TotalLines0%00100%
Percentage0%00100%

File(s)

/home/runner/work/neospec/neospec/internal/domain/coverage.go

#LineLine coverage
 1package domain
 2
 3// FileCoverage holds line-level execution counts for one source file.
 4// Lines is a map from 1-based line number to the number of times that line
 5// was executed during the test run.
 6type FileCoverage struct {
 7  // Path is the file path as reported by Lua's debug.getinfo, typically
 8  // relative to the project root.
 9  Path string
 10  // Lines maps 1-based line numbers to execution counts.
 11  Lines map[int]int
 12}
 13
 14// HitLines returns the number of lines executed at least once.
 715func (f *FileCoverage) HitLines() int {
 716  count := 0
 717  for _, hits := range f.Lines {
 1018    if hits > 0 {
 1019      count++
 1020    }
 21  }
 722  return count
 23}
 24
 25// TotalLines returns the number of instrumented lines.
 826func (f *FileCoverage) TotalLines() int {
 827  return len(f.Lines)
 828}
 29
 30// Percentage returns the line coverage percentage for this file, or 0 if there
 31// are no instrumented lines.
 432func (f *FileCoverage) Percentage() float64 {
 433  total := f.TotalLines()
 134  if total == 0 {
 135    return 0
 136  }
 337  return float64(f.HitLines()) / float64(total) * 100
 38}
 39
 40// CoverageData is the aggregated coverage for an entire test run.
 41type CoverageData struct {
 42  Files []*FileCoverage
 43}
 44
 45// TotalLines returns the total number of instrumented lines across all files.
 46func (c *CoverageData) TotalLines() int {
 47  n := 0
 48  for _, f := range c.Files {
 49    n += f.TotalLines()
 50  }
 51  return n
 52}
 53
 54// HitLines returns the total number of lines hit at least once across all files.
 55func (c *CoverageData) HitLines() int {
 56  n := 0
 57  for _, f := range c.Files {
 58    n += f.HitLines()
 59  }
 60  return n
 61}
 62
 63// Percentage returns the overall line coverage percentage across all files,
 64// or 0 if no lines are instrumented.
 65func (c *CoverageData) Percentage() float64 {
 66  total := c.TotalLines()
 67  if total == 0 {
 68    return 0
 69  }
 70  return float64(c.HitLines()) / float64(total) * 100
 71}
 72
 73// FileByPath returns the FileCoverage for a given path, or nil.
 74func (c *CoverageData) FileByPath(path string) *FileCoverage {
 75  for _, f := range c.Files {
 76    if f.Path == path {
 77      return f
 78    }
 79  }
 80  return nil
 81}

Methods/Properties

HitLines
TotalLines
Percentage