analyzer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(s Severity) int

ExitCode maps severity to a CLI exit code.

Types

type AuditOptions

type AuditOptions struct {
	VacuumDays          int
	UnusedIndexMinBytes int64
	BloatMinBytes       int64
	ExcludeTables       []string
	ExcludeSchemas      []string
}

AuditOptions controls thresholds and exclusions for analysis.

func DefaultAuditOptions

func DefaultAuditOptions() AuditOptions

DefaultAuditOptions returns sensible defaults matching the config defaults.

type Finding

type Finding struct {
	Type     FindingType       `json:"type"`
	Severity Severity          `json:"severity"`
	Schema   string            `json:"schema"`
	Table    string            `json:"table"`
	Column   string            `json:"column,omitempty"`
	Index    string            `json:"index,omitempty"`
	Message  string            `json:"message"`
	Detail   map[string]string `json:"detail,omitempty"`
}

Finding represents a single audit or check result.

func Audit

func Audit(snap *postgres.Snapshot, opts AuditOptions) []Finding

Audit analyzes a catalog snapshot and returns findings.

func DetectUnindexedQueries

func DetectUnindexedQueries(columnRefs []scanner.ColumnRef, indexes []postgres.IndexInfo, tables []postgres.TableInfo) []Finding

DetectUnindexedQueries finds columns used in WHERE/ORDER BY/JOIN that lack indexes.

func Diff

func Diff(scan *scanner.ScanResult, snap *postgres.Snapshot, opts AuditOptions) []Finding

Diff compares code repo references against the live database snapshot. It also includes audit findings for cluster-only issues.

type FindingType

type FindingType string

FindingType identifies what kind of issue was detected.

const (
	FindingUnusedTable       FindingType = "UNUSED_TABLE"
	FindingUnusedIndex       FindingType = "UNUSED_INDEX"
	FindingBloatedIndex      FindingType = "BLOATED_INDEX"
	FindingMissingVacuum     FindingType = "MISSING_VACUUM"
	FindingNoPrimaryKey      FindingType = "NO_PRIMARY_KEY"
	FindingDuplicateIndex    FindingType = "DUPLICATE_INDEX"
	FindingMissingTable      FindingType = "MISSING_TABLE"
	FindingMissingColumn     FindingType = "MISSING_COLUMN"
	FindingUnreferencedTable FindingType = "UNREFERENCED_TABLE"
	FindingCodeMatch         FindingType = "CODE_MATCH"
	FindingUnindexedQuery    FindingType = "UNINDEXED_QUERY"
	FindingOK                FindingType = "OK"
)

type Severity

type Severity string

Severity indicates the risk level of a finding.

const (
	SeverityHigh   Severity = "high"
	SeverityMedium Severity = "medium"
	SeverityLow    Severity = "low"
	SeverityInfo   Severity = "info"
)

func MaxSeverity

func MaxSeverity(findings []Finding) Severity

MaxSeverity returns the highest severity among findings.

Jump to

Keyboard shortcuts

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