< Summary - Neospec Coverage

Line coverage
100%
Covered lines: 60
Uncovered lines: 0
Coverable lines: 60
Total lines: 179
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
File 1: BadgeColor0%00100%
File 1: BadgeLabel0%00100%
File 2: ParseVersion0%00100%
File 2: BinaryName0%00100%
File 3: CurrentPlatform0%00100%
File 3: parsePlatform0%00100%

File(s)

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

#LineLine coverage
 1package domain
 2
 3import "fmt"
 4
 5// BadgeColor returns the shields.io color name for a given coverage percentage.
 6// The thresholds mirror common open-source conventions.
 117func BadgeColor(pct float64) string {
 118  switch {
 39  case pct >= 90:
 310    return "brightgreen"
 211  case pct >= 75:
 212    return "green"
 213  case pct >= 60:
 214    return "yellow"
 215  case pct >= 40:
 216    return "orange"
 217  default:
 218    return "red"
 19  }
 20}
 21
 22// BadgeLabel returns the display label for a coverage percentage, e.g. "87.5%".
 423func BadgeLabel(pct float64) string {
 424  return fmt.Sprintf("%.1f%%", pct)
 425}

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

#LineLine coverage
 1package domain
 2
 3import (
 4  "fmt"
 5  "regexp"
 6  "strconv"
 7)
 8
 9// Version represents a Neovim release version. The Tag field is the canonical
 10// form used in GitHub release URLs (e.g. "v0.10.4", "stable", "nightly").
 11type Version struct {
 12  Major int
 13  Minor int
 14  Patch int
 15  // Tag is the GitHub release tag, e.g. "stable", "nightly", or "v0.10.4".
 16  Tag string
 17}
 18
 19var semverRe = regexp.MustCompile(`^v?(\d+)\.(\d+)\.(\d+)$`)
 20
 21// ParseVersion parses a version string. It accepts:
 22//   - "stable" and "nightly" as special tags with zero Major/Minor/Patch
 23//   - semantic version strings like "0.10.4" or "v0.10.4"
 1224func ParseVersion(s string) (Version, error) {
 525  if s == "stable" || s == "nightly" {
 526    return Version{Tag: s}, nil
 527  }
 28
 729  m := semverRe.FindStringSubmatch(s)
 230  if m == nil {
 231    return Version{}, fmt.Errorf("invalid neovim version %q: want \"stable\", \"nightly\", or semver like \"0.10.4\"", s
 232  }
 33
 534  major, _ := strconv.Atoi(m[1])
 535  minor, _ := strconv.Atoi(m[2])
 536  patch, _ := strconv.Atoi(m[3])
 537
 538  tag := s
 339  if s[0] != 'v' {
 340    tag = "v" + s
 341  }
 42
 543  return Version{Major: major, Minor: minor, Patch: patch, Tag: tag}, nil
 44}
 45
 46// String returns the canonical version tag.
 47func (v Version) String() string {
 48  return v.Tag
 49}
 50
 51// AssetName returns the filename of the Neovim release archive for a given platform.
 52// These match the actual asset names used in Neovim GitHub releases.
 53func (v Version) AssetName(p Platform) string {
 54  switch p.OS {
 55  case OSDarwin:
 56    // As of Neovim 0.10, GitHub releases ship separate x86_64 and arm64
 57    // tarballs for macOS rather than a single universal binary.
 58    if p.Arch == ArchARM64 {
 59      return "nvim-macos-arm64.tar.gz"
 60    }
 61    return "nvim-macos-x86_64.tar.gz"
 62  case OSLinux:
 63    switch p.Arch {
 64    case ArchARM64:
 65      return "nvim-linux-arm64.tar.gz"
 66    default:
 67      return "nvim-linux-x86_64.tar.gz"
 68    }
 69  case OSWindows:
 70    return "nvim-win64.zip"
 71  }
 72  return ""
 73}
 74
 75// BinaryName returns the Neovim executable name for a platform.
 376func BinaryName(p Platform) string {
 177  if p.OS == OSWindows {
 178    return "nvim.exe"
 179  }
 280  return "nvim"
 81}

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

#LineLine coverage
 1// Package domain contains the core data types and pure business logic for neospec.
 2// Nothing in this package performs I/O or depends on external packages — it is
 3// the stable heart of the application that all other packages point toward.
 4package domain
 5
 6import (
 7  "fmt"
 8  "runtime"
 9)
 10
 11// OS represents a target operating system.
 12type OS string
 13
 14// Supported operating systems.
 15const (
 16  OSLinux   OS = "linux"
 17  OSDarwin  OS = "darwin"
 18  OSWindows OS = "windows"
 19)
 20
 21// Arch represents a CPU architecture.
 22type Arch string
 23
 24// Supported CPU architectures.
 25const (
 26  ArchAMD64 Arch = "x86_64"
 27  ArchARM64 Arch = "arm64"
 28)
 29
 30// Platform combines an OS and architecture for use in Neovim release asset selection.
 31type Platform struct {
 32  OS   OS
 33  Arch Arch
 34}
 35
 36// CurrentPlatform returns the Platform for the running process.
 137func CurrentPlatform() (Platform, error) {
 138  return parsePlatform(runtime.GOOS, runtime.GOARCH)
 139}
 40
 41// parsePlatform maps a GOOS/GOARCH pair to a Platform. It is the testable
 42// inner function for CurrentPlatform — callers that need to simulate unusual
 43// or unsupported platforms can call it directly in white-box tests.
 1144func parsePlatform(goos, goarch string) (Platform, error) {
 1145  var os OS
 1146  switch goos {
 547  case "linux":
 548    os = OSLinux
 249  case "darwin":
 250    os = OSDarwin
 151  case "windows":
 152    os = OSWindows
 353  default:
 354    return Platform{}, fmt.Errorf("unsupported OS: %s", goos)
 55  }
 56
 857  var arch Arch
 858  switch goarch {
 459  case "amd64":
 460    arch = ArchAMD64
 261  case "arm64":
 262    arch = ArchARM64
 263  default:
 264    return Platform{}, fmt.Errorf("unsupported architecture: %s", goarch)
 65  }
 66
 667  return Platform{OS: os, Arch: arch}, nil
 68}
 69
 70// String returns a human-readable platform string, e.g. "linux/x86_64".
 71func (p Platform) String() string {
 72  return fmt.Sprintf("%s/%s", p.OS, p.Arch)
 73}