projectanalysis

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package projectanalysis models immutable, tenant-scoped Project analysis snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis

type Analysis struct {
	ID             string                    `json:"id"`
	TenantID       string                    `json:"tenant_id"`
	ProjectID      string                    `json:"project_id"`
	ProjectKey     string                    `json:"project_key"`
	CreatedAt      time.Time                 `json:"created_at"`
	SourceRef      string                    `json:"source_ref,omitempty"`
	SourceCommit   string                    `json:"source_commit,omitempty"`
	Measures       qualitygate.Snapshot      `json:"measures"`
	Gate           qualitygate.Result        `json:"gate"`
	GateInfo       GateInfo                  `json:"gate_info"`
	Issues         Counts                    `json:"issues"`
	InternalIssues []Issue                   `json:"internal_issues"`
	NewCode        NewCode                   `json:"new_code"`
	Delta          *Delta                    `json:"delta"`
	Coverage       *measure.CoverageReport   `json:"coverage"`
	Duplication    measure.DuplicationReport `json:"duplication"`
	Rating         rating.Report             `json:"rating"`
	Hotspots       hotspot.Summary           `json:"hotspots"`
	NewHotspots    hotspot.Summary           `json:"new_hotspots"`
	Snapshot       measure.Snapshot          `json:"snapshot"`
}

Analysis is an append-only Project analysis snapshot. InternalIssues never crosses the HTTP boundary; it is only persisted to compute the next snapshot's identity set.

func Build

func Build(in Input) (Analysis, error)

Build returns one immutable snapshot and evaluates the built-in gate at creation.

func (*Analysis) UnmarshalJSON

func (a *Analysis) UnmarshalJSON(data []byte) error

UnmarshalJSON handles legacy decoding where Snapshot might be empty or missing.

type Counts

type Counts struct {
	Total      int            `json:"total"`
	ByKind     map[string]int `json:"by_kind"`
	BySeverity map[string]int `json:"by_severity"`
	ByStatus   map[string]int `json:"by_status"`
}

Counts groups issues along the dimensions exposed by Activity.

type Delta

type Delta struct {
	Issues   Counts             `json:"issues"`
	Measures map[string]float64 `json:"measures"`
	Ratings  map[string]int     `json:"ratings"`
}

Delta is a signed comparison with the immediately previous successful analysis.

type GateInfo

type GateInfo struct {
	Key    string `json:"key,omitempty"`
	Name   string `json:"name"`
	Source string `json:"source"`
}

GateInfo records which policy produced the immutable evaluated result.

type Input

type Input struct {
	ID           string
	TenantID     shared.ID
	ProjectID    shared.ID
	ProjectKey   string
	CreatedAt    time.Time
	SourceRef    string
	SourceCommit string
	Findings     []finding.Finding
	Gate         qualitygate.Gate
	GateSource   string
	GateExempt   map[string]bool
	LinesOfCode  int
	Coverage     *measure.CoverageReport
	Duplication  measure.DuplicationReport
	Previous     *Analysis
	Hotspots     hotspot.Summary
	NewHotspots  hotspot.Summary
	Snapshot     measure.Snapshot
}

Input supplies one completed scan's project-facing facts. Findings must be the merged root and code-quality findings, not two independently counted lists.

type Issue

type Issue struct {
	Key      string          `json:"key"`
	Kind     finding.Kind    `json:"kind"`
	Severity shared.Severity `json:"severity"`
	Status   finding.Status  `json:"status"`
}

Issue is the compact, stable identity retained to derive the next New Code period.

type NewCode

type NewCode struct {
	PreviousID string        `json:"previous_id,omitempty"`
	Counts     Counts        `json:"counts"`
	Rating     NewCodeRating `json:"rating"`
}

NewCode retains the derived period state used by the default gate.

type NewCodeRating

type NewCodeRating struct {
	Security        rating.Grade  `json:"security"`
	Reliability     rating.Grade  `json:"reliability"`
	Maintainability *rating.Grade `json:"maintainability"`
}

NewCodeRating omits maintainability until Project scans retain changed-line LOC.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL