Documentation
¶
Overview ¶
Package projectuc implements project application logic.
Index ¶
- func ValidateCursorSecret(key []byte) error
- type AnalysisMetadata
- type ChildCollection
- type ComplexityMeasures
- type CountMetric
- type CoverageMeasures
- type CreateInput
- type DebtMeasures
- type DuplicationMeasures
- type IssueMeasures
- type LatestAnalysis
- type MeasureAvailabilityState
- type MeasureCountMetric
- type MeasureCursor
- type MeasureDecimalMetric
- type MeasureGradeMetric
- type MeasureNode
- type MetricAvailability
- type Overview
- type OverviewAnalysis
- type OverviewGate
- type OverviewGateCondition
- type OverviewGateOperator
- type OverviewGateSource
- type OverviewGateStatus
- type OverviewGrade
- type OverviewIssueSummary
- type OverviewLens
- type OverviewNewCodePeriod
- type OverviewProject
- type OverviewState
- type PercentageMetric
- type ProjectMeasureResponse
- type ProjectNodeInfo
- type ProjectSummary
- type RatingMetric
- type RatingsMeasures
- type Service
- func (s *Service) AnalysisStatus(ctx context.Context, tenantID shared.ID, key string) (ports.ScanJob, error)
- func (s *Service) AssignGate(ctx context.Context, actor string, tenantID shared.ID, key, gateID string) (*project.Project, error)
- func (s *Service) Create(ctx context.Context, in CreateInput) (*project.Project, error)
- func (s *Service) CreateFromArchive(ctx context.Context, in CreateInput, filename string, src io.Reader) (*project.Project, error)
- func (s *Service) Delete(ctx context.Context, actor string, tenantID shared.ID, key string) error
- func (s *Service) Get(ctx context.Context, tenantID shared.ID, key string) (*project.Project, error)
- func (s *Service) GetAnalysis(ctx context.Context, tenantID shared.ID, key, id string) (projectanalysis.Analysis, error)
- func (s *Service) GetHotspot(ctx context.Context, tenantID shared.ID, key string, hotspotID shared.ID) (hotspot.Hotspot, error)
- func (s *Service) GetIssue(ctx context.Context, tenantID shared.ID, key string, issueID shared.ID) (issue.Issue, error)
- func (s *Service) GetMeasures(ctx context.Context, tenantID, projectKey, path string, domains []string, ...) (ProjectMeasureResponse, error)
- func (s *Service) HotspotHistory(ctx context.Context, tenantID shared.ID, key string, hotspotID shared.ID) ([]hotspot.ReviewEvent, error)
- func (s *Service) IssueHistory(ctx context.Context, tenantID shared.ID, key string, issueID shared.ID) ([]issue.ReviewEvent, error)
- func (s *Service) LatestAnalysis(ctx context.Context, tenantID shared.ID, key string) (LatestAnalysis, error)
- func (s *Service) List(ctx context.Context, tenantID shared.ID) ([]*project.Project, error)
- func (s *Service) ListAnalyses(ctx context.Context, tenantID shared.ID, key string, limit int, ...) ([]projectanalysis.Analysis, bool, error)
- func (s *Service) ListHotspots(ctx context.Context, tenantID shared.ID, key string, filter hotspot.ListFilter) (hotspot.Page, error)
- func (s *Service) ListIssues(ctx context.Context, tenantID shared.ID, key string, filter issue.ListFilter) (issue.Page, error)
- func (s *Service) ListSummaries(ctx context.Context, tenantID shared.ID) ([]ProjectSummary, error)
- func (s *Service) Overview(ctx context.Context, tenantID shared.ID, key string) (Overview, error)
- func (s *Service) RecordProjectAnalysis(ctx context.Context, engagementID shared.ID, jobID string, ...) error
- func (s *Service) SetAnalysisStore(store ports.ProjectAnalysisStore)
- func (s *Service) SetArchiveStore(store ports.ProjectArchiveStore)
- func (s *Service) SetCursorSecret(secret []byte) error
- func (s *Service) SetFindingRepository(repo ports.FindingRepository)
- func (s *Service) SetHotspotStore(store ports.ProjectHotspotStore)
- func (s *Service) SetIssueStore(store ports.ProjectIssueStore)
- func (s *Service) SetQualityGateMutator(mutator ports.QualityGateMutator)
- func (s *Service) SetQualityGates(gates *qualitygatesuc.Service)
- func (s *Service) SetQualityProfiles(profiles *qualityprofilesuc.Service)
- func (s *Service) SetRuleCatalog(catalog ports.RuleCatalog)
- func (s *Service) SetScanner(scanner *scauc.Service)
- func (s *Service) StartAnalysis(ctx context.Context, actor string, tenantID shared.ID, key string, ...) (ports.ScanJob, error)
- func (s *Service) TransitionHotspot(ctx context.Context, actor string, tenantID shared.ID, key string, ...) (hotspot.Hotspot, hotspot.ReviewEvent, error)
- func (s *Service) TransitionIssue(ctx context.Context, actor string, tenantID shared.ID, key string, ...) (issue.Issue, issue.ReviewEvent, error)
- type SizeMeasures
- type UnavailableReason
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateCursorSecret ¶
ValidateCursorSecret returns an error when key is nil or shorter than 32 bytes.
Types ¶
type AnalysisMetadata ¶
type AnalysisMetadata struct {
ID string `json:"id"`
CreatedAt time.Time `json:"created_at"`
SourceRef string `json:"source_ref,omitempty"`
SourceCommit string `json:"source_commit,omitempty"`
}
AnalysisMetadata provides contextual information about the analysis snapshot.
type ChildCollection ¶
type ChildCollection struct {
Items []MeasureNode `json:"items"`
NextCursor *string `json:"next_cursor"`
}
ChildCollection wraps a paginated list of immediate child nodes.
type ComplexityMeasures ¶
type ComplexityMeasures struct {
Cyclomatic MeasureCountMetric `json:"cyclomatic"`
Cognitive MeasureCountMetric `json:"cognitive"`
}
ComplexityMeasures encapsulates structural complexity metrics.
type CountMetric ¶
type CountMetric struct {
Availability MetricAvailability
Value *int
}
type CoverageMeasures ¶
type CoverageMeasures struct {
CoveredLines MeasureCountMetric `json:"covered_lines"`
CoverableLines MeasureCountMetric `json:"coverable_lines"`
Coverage MeasureDecimalMetric `json:"coverage"`
NewCodeCoverage MeasureDecimalMetric `json:"new_code_coverage"`
}
CoverageMeasures encapsulates code coverage metrics.
type CreateInput ¶
type DebtMeasures ¶
type DebtMeasures struct {
RemediationEffortMinutes MeasureCountMetric `json:"remediation_effort_minutes"`
}
DebtMeasures encapsulates technical debt metrics.
type DuplicationMeasures ¶
type DuplicationMeasures struct {
DuplicatedLines MeasureCountMetric `json:"duplicated_lines"`
DuplicationBlocks MeasureCountMetric `json:"duplication_blocks"`
DuplicationDensity MeasureDecimalMetric `json:"duplication_density"`
}
DuplicationMeasures encapsulates source code duplication metrics.
type IssueMeasures ¶
type IssueMeasures struct {
ByType map[string]MeasureCountMetric `json:"by_type"`
BySeverity map[string]MeasureCountMetric `json:"by_severity"`
}
IssueMeasures encapsulates finding counts broken down by type and severity.
type LatestAnalysis ¶
type LatestAnalysis struct {
Analysis projectanalysis.Analysis
Result []byte
}
type MeasureAvailabilityState ¶
type MeasureAvailabilityState string
MeasureAvailabilityState describes whether a measure has a meaningful value.
const ( // AvailabilityAvailable indicates the measure value is present and valid. AvailabilityAvailable MeasureAvailabilityState = "available" AvailabilityUnavailable MeasureAvailabilityState = "unavailable" // AvailabilityNotApplicable indicates the measure does not apply to this node type. AvailabilityNotApplicable MeasureAvailabilityState = "not_applicable" )
type MeasureCountMetric ¶
type MeasureCountMetric struct {
Availability MeasureAvailabilityState `json:"availability"`
Value *int `json:"value"`
Reason *string `json:"unavailable_reason"`
}
MeasureCountMetric represents an integer measure and its availability state.
type MeasureCursor ¶
type MeasureCursor struct {
Version int `json:"v"`
AnalysisID string `json:"a"`
Path string `json:"r"`
LastKindRank int `json:"k"`
LastChildPath string `json:"l"`
}
MeasureCursor is the opaque pagination token used to iterate through children.
func DecodeMeasureCursor ¶
func DecodeMeasureCursor(s string, secret []byte) (*MeasureCursor, error)
DecodeMeasureCursor decodes, verifies the signature, and validates the integrity of a pagination cursor.
func (*MeasureCursor) Encode ¶
func (c *MeasureCursor) Encode(secret []byte) string
Encode serializes the cursor and cryptographically signs it to prevent tampering.
type MeasureDecimalMetric ¶
type MeasureDecimalMetric struct {
Availability MeasureAvailabilityState `json:"availability"`
Value *float64 `json:"value"`
Reason *string `json:"unavailable_reason"`
}
MeasureDecimalMetric represents a floating-point measure and its availability state.
type MeasureGradeMetric ¶
type MeasureGradeMetric struct {
Availability MeasureAvailabilityState `json:"availability"`
Grade *string `json:"grade"`
Reason *string `json:"unavailable_reason"`
}
MeasureGradeMetric represents a letter grade (e.g., A, B, C) and its availability state.
type MeasureNode ¶
type MeasureNode struct {
Path string `json:"path"`
Name string `json:"name"`
Kind measure.NodeKind `json:"kind"`
Language string `json:"language,omitempty"`
Size *SizeMeasures `json:"size,omitempty"`
Complexity *ComplexityMeasures `json:"complexity,omitempty"`
Coverage *CoverageMeasures `json:"coverage,omitempty"`
Duplication *DuplicationMeasures `json:"duplication,omitempty"`
Issues *IssueMeasures `json:"issues,omitempty"`
Debt *DebtMeasures `json:"debt,omitempty"`
Ratings *RatingsMeasures `json:"ratings,omitempty"`
}
MeasureNode represents a single directory, file, or project root with its computed measures.
type MetricAvailability ¶
type MetricAvailability string
const ( MetricAvailable MetricAvailability = "available" MetricNotSupplied MetricAvailability = "not_supplied" MetricNotApplicable MetricAvailability = "not_applicable" )
type Overview ¶
type Overview struct {
State OverviewState
Project OverviewProject
LatestAnalysis *OverviewAnalysis
Gate *OverviewGate
IssueSummary OverviewIssueSummary
Overall OverviewLens
NewCode OverviewLens
}
type OverviewAnalysis ¶
type OverviewGate ¶
type OverviewGate struct {
Status OverviewGateStatus
Key *string
Name *string
Source *OverviewGateSource
FailedConditions []OverviewGateCondition
}
type OverviewGateCondition ¶
type OverviewGateCondition struct {
Metric string
Operator OverviewGateOperator
Threshold float64
Actual float64
}
type OverviewGateOperator ¶
type OverviewGateOperator string
const ( OverviewGateOperatorLE OverviewGateOperator = "<=" OverviewGateOperatorGE OverviewGateOperator = ">=" OverviewGateOperatorEQ OverviewGateOperator = "==" OverviewGateOperatorLT OverviewGateOperator = "<" OverviewGateOperatorGT OverviewGateOperator = ">" )
type OverviewGateSource ¶
type OverviewGateSource string
const ( OverviewGateSourceDefault OverviewGateSource = "default" OverviewGateSourceRepository OverviewGateSource = "repository" OverviewGateSourceManaged OverviewGateSource = "managed" )
type OverviewGateStatus ¶
type OverviewGateStatus string
const ( OverviewGatePassed OverviewGateStatus = "passed" OverviewGateFailed OverviewGateStatus = "failed" )
type OverviewGrade ¶
type OverviewGrade string
const ( OverviewGradeA OverviewGrade = "A" OverviewGradeB OverviewGrade = "B" OverviewGradeC OverviewGrade = "C" OverviewGradeD OverviewGrade = "D" OverviewGradeE OverviewGrade = "E" )
type OverviewIssueSummary ¶
type OverviewIssueSummary struct {
NewCodeTotal CountMetric
AcceptedOverallTotal CountMetric
}
type OverviewLens ¶
type OverviewLens struct {
Security RatingMetric
Reliability RatingMetric
Maintainability RatingMetric
SecurityHotspotsReviewed PercentageMetric
Coverage PercentageMetric
Duplications PercentageMetric
}
type OverviewNewCodePeriod ¶
type OverviewProject ¶
type OverviewState ¶
type OverviewState string
const ( OverviewStateNotAnalyzed OverviewState = "not_analyzed" OverviewStateAnalyzed OverviewState = "analyzed" )
type PercentageMetric ¶
type PercentageMetric struct {
Availability MetricAvailability
Value *float64
Grade *OverviewGrade
}
type ProjectMeasureResponse ¶
type ProjectMeasureResponse struct {
State string `json:"state"` // "analyzed", "not_analyzed"
Project ProjectNodeInfo `json:"project"`
Analysis *AnalysisMetadata `json:"analysis"`
Path string `json:"path"`
IncludedDomains []string `json:"included_domains"`
Node *MeasureNode `json:"node"`
Children ChildCollection `json:"children"`
}
ProjectMeasureResponse is the root response payload for the measures API endpoint.
type ProjectNodeInfo ¶
ProjectNodeInfo provides basic identifying information about the project.
type ProjectSummary ¶
type ProjectSummary struct {
Project *project.Project
LatestAnalysis *projectanalysis.Analysis
LatestJob *ports.ScanJob
}
ProjectSummary combines a Project with its latest decision record and active job.
type RatingMetric ¶
type RatingMetric struct {
Availability MetricAvailability
Grade *OverviewGrade
}
type RatingsMeasures ¶
type RatingsMeasures struct {
Security MeasureGradeMetric `json:"security"`
Reliability MeasureGradeMetric `json:"reliability"`
Maintainability MeasureGradeMetric `json:"maintainability"`
}
RatingsMeasures encapsulates high-level grades for security, reliability, and maintainability.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo ports.ProjectRepository, engagements ports.EngagementRepository, clock ports.Clock, ids ports.IDGenerator, audit ports.AuditLogger, allowLocalSource bool) *Service
func (*Service) AnalysisStatus ¶
func (*Service) AssignGate ¶
func (*Service) CreateFromArchive ¶
func (*Service) GetAnalysis ¶
func (s *Service) GetAnalysis(ctx context.Context, tenantID shared.ID, key, id string) (projectanalysis.Analysis, error)
GetAnalysis returns one snapshot without disclosing another Project's history.
func (*Service) GetHotspot ¶
func (s *Service) GetHotspot(ctx context.Context, tenantID shared.ID, key string, hotspotID shared.ID) (hotspot.Hotspot, error)
GetHotspot returns one projection only after the Project has been resolved in the caller's tenant.
func (*Service) GetIssue ¶
func (s *Service) GetIssue(ctx context.Context, tenantID shared.ID, key string, issueID shared.ID) (issue.Issue, error)
GetIssue returns one issue only after the Project is resolved in the caller's tenant.
func (*Service) GetMeasures ¶
func (s *Service) GetMeasures(ctx context.Context, tenantID, projectKey, path string, domains []string, limit int, cursorStr string) (ProjectMeasureResponse, error)
GetMeasures retrieves the measure node and its direct children for a specific path.
func (*Service) HotspotHistory ¶
func (s *Service) HotspotHistory(ctx context.Context, tenantID shared.ID, key string, hotspotID shared.ID) ([]hotspot.ReviewEvent, error)
HotspotHistory returns the immutable review event history of a hotspot.
func (*Service) IssueHistory ¶
func (s *Service) IssueHistory(ctx context.Context, tenantID shared.ID, key string, issueID shared.ID) ([]issue.ReviewEvent, error)
IssueHistory returns the immutable, append-only lifecycle history of an issue.
func (*Service) LatestAnalysis ¶
func (*Service) ListAnalyses ¶
func (s *Service) ListAnalyses(ctx context.Context, tenantID shared.ID, key string, limit int, beforeCreatedAt time.Time, beforeID shared.ID) ([]projectanalysis.Analysis, bool, error)
ListAnalyses returns one immutable Project history page, newest first.
func (*Service) ListHotspots ¶
func (s *Service) ListHotspots(ctx context.Context, tenantID shared.ID, key string, filter hotspot.ListFilter) (hotspot.Page, error)
ListHotspots returns projections belonging to the requested tenant and Project for the current analysis lens.
func (*Service) ListIssues ¶
func (s *Service) ListIssues(ctx context.Context, tenantID shared.ID, key string, filter issue.ListFilter) (issue.Page, error)
ListIssues returns the tenant- and Project-scoped code-quality issues for the faceted explorer. Cross-tenant/unknown projects resolve to not-found via Get.
func (*Service) ListSummaries ¶
ListSummaries serves the unpaginated Project portfolio without browser-side N+1 requests. add cursor pagination plus server-side filters when returning a tenant's full searchable portfolio becomes materially expensive.
func (*Service) RecordProjectAnalysis ¶
func (s *Service) RecordProjectAnalysis(ctx context.Context, engagementID shared.ID, jobID string, completedAt time.Time, result *scauc.ScanResult) error
RecordProjectAnalysis is called by SCA only after a successful pipeline and before its ScanJob becomes succeeded. Non-Project scans intentionally no-op.
func (*Service) SetAnalysisStore ¶
func (s *Service) SetAnalysisStore(store ports.ProjectAnalysisStore)
func (*Service) SetArchiveStore ¶
func (s *Service) SetArchiveStore(store ports.ProjectArchiveStore)
func (*Service) SetCursorSecret ¶
SetCursorSecret injects the HMAC signing key for pagination cursors. Returns an error when the key is absent or shorter than 32 bytes. The byte slice is copied so later caller mutation cannot alter the service key.
func (*Service) SetFindingRepository ¶
func (s *Service) SetFindingRepository(repo ports.FindingRepository)
func (*Service) SetHotspotStore ¶
func (s *Service) SetHotspotStore(store ports.ProjectHotspotStore)
func (*Service) SetIssueStore ¶
func (s *Service) SetIssueStore(store ports.ProjectIssueStore)
func (*Service) SetQualityGateMutator ¶
func (s *Service) SetQualityGateMutator(mutator ports.QualityGateMutator)
func (*Service) SetQualityGates ¶
func (s *Service) SetQualityGates(gates *qualitygatesuc.Service)
func (*Service) SetQualityProfiles ¶
func (s *Service) SetQualityProfiles(profiles *qualityprofilesuc.Service)
func (*Service) SetRuleCatalog ¶
func (s *Service) SetRuleCatalog(catalog ports.RuleCatalog)
func (*Service) SetScanner ¶
func (*Service) StartAnalysis ¶
func (*Service) TransitionHotspot ¶
func (s *Service) TransitionHotspot(ctx context.Context, actor string, tenantID shared.ID, key string, hotspotID shared.ID, to hotspot.Status, rationale string, expectedVersion int) (hotspot.Hotspot, hotspot.ReviewEvent, error)
TransitionHotspot applies a human review decision to a hotspot.
func (*Service) TransitionIssue ¶
func (s *Service) TransitionIssue(ctx context.Context, actor string, tenantID shared.ID, key string, issueID shared.ID, to issue.Status, rationale string, expectedVersion int) (issue.Issue, issue.ReviewEvent, error)
TransitionIssue applies an attributable, gate-affecting triage decision to an issue.
type SizeMeasures ¶
type SizeMeasures struct {
Files MeasureCountMetric `json:"files"`
NCLOC MeasureCountMetric `json:"ncloc"`
CommentLines MeasureCountMetric `json:"comment_lines"`
BlankLines MeasureCountMetric `json:"blank_lines"`
Functions MeasureCountMetric `json:"functions"`
CommentDensity MeasureDecimalMetric `json:"comment_density"`
}
SizeMeasures encapsulates size-related metrics such as line counts and functions.
type UnavailableReason ¶
type UnavailableReason string
const ( ReasonNoAnalysis UnavailableReason = "no_analysis" ReasonRatingNotAvailable UnavailableReason = "rating_not_available" ReasonIssueLifecycleNotAvailable UnavailableReason = "issue_lifecycle_not_available" ReasonSecurityHotspotsNotAvailable UnavailableReason = "security_hotspots_not_available" ReasonChangedLineMetricsNotAvailable UnavailableReason = "changed_line_metrics_not_available" ReasonCoverageNotSupplied UnavailableReason = "coverage_not_supplied" ReasonNoExecutableLines UnavailableReason = "no_executable_lines" ReasonDuplicationNotAvailable UnavailableReason = "duplication_not_available" )