< Summary - Neospec Coverage

Information
Class: CoverageData
Assembly: domain
File(s): /home/runner/work/neospec/neospec/internal/domain/coverage.go
Line coverage
100%
Covered lines: 24
Uncovered lines: 0
Coverable lines: 24
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
TotalLines0%00100%
HitLines0%00100%
Percentage0%00100%
FileByPath0%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.
 15func (f *FileCoverage) HitLines() int {
 16  count := 0
 17  for _, hits := range f.Lines {
 18    if hits > 0 {
 19      count++
 20    }
 21  }
 22  return count
 23}
 24
 25// TotalLines returns the number of instrumented lines.
 26func (f *FileCoverage) TotalLines() int {
 27  return len(f.Lines)
 28}
 29
 30// Percentage returns the line coverage percentage for this file, or 0 if there
 31// are no instrumented lines.
 32func (f *FileCoverage) Percentage() float64 {
 33  total := f.TotalLines()
 34  if total == 0 {
 35    return 0
 36  }
 37  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.
 346func (c *CoverageData) TotalLines() int {
 347  n := 0
 348  for _, f := range c.Files {
 449    n += f.TotalLines()
 450  }
 351  return n
 52}
 53
 54// HitLines returns the total number of lines hit at least once across all files.
 255func (c *CoverageData) HitLines() int {
 256  n := 0
 257  for _, f := range c.Files {
 458    n += f.HitLines()
 459  }
 260  return n
 61}
 62
 63// Percentage returns the overall line coverage percentage across all files,
 64// or 0 if no lines are instrumented.
 265func (c *CoverageData) Percentage() float64 {
 266  total := c.TotalLines()
 167  if total == 0 {
 168    return 0
 169  }
 170  return float64(c.HitLines()) / float64(total) * 100
 71}
 72
 73// FileByPath returns the FileCoverage for a given path, or nil.
 274func (c *CoverageData) FileByPath(path string) *FileCoverage {
 275  for _, f := range c.Files {
 176    if f.Path == path {
 177      return f
 178    }
 79  }
 180  return nil
 81}