< Summary - Repometa Coverage

Information
Class: rustDetector
Assembly: repometa
File(s): /home/runner/work/repometa/repometa/detect_rust.go
Line coverage
55%
Covered lines: 24
Uncovered lines: 19
Coverable lines: 43
Total lines: 71
Line coverage: 55.8%
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
detect0%0055.81%

File(s)

/home/runner/work/repometa/repometa/detect_rust.go

#LineLine coverage
 1package repometa
 2
 3import (
 4  "path/filepath"
 5
 6  "github.com/BurntSushi/toml"
 7)
 8
 9type rustDetector struct{}
 10
 11type cargoTOML struct {
 12  Package   *cargoPackage   `toml:"package"`
 13  Workspace *cargoWorkspace `toml:"workspace"`
 14}
 15
 16type cargoPackage struct {
 17  Name string `toml:"name"`
 18}
 19
 20type cargoWorkspace struct {
 21  Members []string `toml:"members"`
 22}
 23
 8424func (rustDetector) detect(dv dirVisit, cfg options) []finding {
 8125  if !hasFile(dv.files, "Cargo.toml") {
 8126    return nil
 8127  }
 328  path := filepath.Join(dv.abs, "Cargo.toml")
 329  data, err := readManifest(path, cfg)
 030  if err != nil {
 031    return []finding{{
 032      Kind:       KindRustCrate,
 033      Confidence: confidenceUnreadable,
 034      Evidence:   []Evidence{evidenceUnreadable(dv.rel, "Cargo.toml", err)},
 035    }}
 036  }
 37
 338  var manifest cargoTOML
 039  if err := toml.Unmarshal(data, &manifest); err != nil {
 040    // Rust keeps its own bespoke parse-failure Evidence rather than
 041    // using evidenceUnparsable: BurntSushi/toml's error text is noisy
 042    // and the historical Evidence line omits it entirely. Preserve
 043    // current behavior — bring this into the shared helper only if
 044    // consumers ask for the extra detail.
 045    return []finding{{
 046      Kind:       KindRustCrate,
 047      Confidence: confidenceUnparsable,
 048      Evidence:   []Evidence{{Path: relJoin(dv.rel, "Cargo.toml"), Reason: "Cargo.toml at directory root (parse error)"}
 049    }}
 050  }
 51
 352  kind := KindRustCrate
 353  reason := "Cargo.toml with [package] section"
 154  if manifest.Package == nil {
 155    kind = KindRustWorkspace
 156    reason = "Cargo.toml with [workspace] section, no [package] — virtual workspace"
 157  }
 58
 359  var workspaces []Workspace
 160  if manifest.Workspace != nil {
 161    members := expandMembers(dv.abs, manifest.Workspace.Members, dv.rel)
 162    workspaces = append(workspaces, Workspace{Kind: WorkspaceCargo, Members: members})
 163  }
 64
 365  return []finding{{
 366    Kind:       kind,
 367    Confidence: 1.0,
 368    Evidence:   []Evidence{{Path: relJoin(dv.rel, "Cargo.toml"), Reason: reason}},
 369    Workspaces: workspaces,
 370  }}
 71}

Methods/Properties

detect