scanner

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanLine

func ScanLine(line string) []tableMatch

ScanLine extracts table references from a single line of code.

func ScanLineColumns

func ScanLineColumns(line string) []columnMatch

ScanLineColumns extracts column references from a single line of code.

Types

type ColumnRef

type ColumnRef struct {
	Table      string  `json:"table"`
	Column     string  `json:"column"`
	Schema     string  `json:"schema,omitempty"`
	File       string  `json:"file"`
	Line       int     `json:"line"`
	Context    Context `json:"context"`
	Suppressed bool    `json:"suppressed,omitempty"`
}

ColumnRef is a single reference to a database column found in code.

type Context

type Context string

Context describes the SQL operation context.

const (
	ContextSelect  Context = "SELECT"
	ContextInsert  Context = "INSERT"
	ContextUpdate  Context = "UPDATE"
	ContextDelete  Context = "DELETE"
	ContextDDL     Context = "DDL"
	ContextWhere   Context = "WHERE"
	ContextOrderBy Context = "ORDER_BY"
	ContextUnknown Context = "UNKNOWN"
)

type PatternType

type PatternType string

PatternType identifies how a table reference was detected.

const (
	PatternSQL       PatternType = "sql"
	PatternORM       PatternType = "orm"
	PatternMigration PatternType = "migration"
)

type ScanResult

type ScanResult struct {
	RepoPath     string      `json:"repoPath"`
	Refs         []TableRef  `json:"refs"`
	ColumnRefs   []ColumnRef `json:"columnRefs,omitempty"`
	Tables       []string    `json:"tables"`
	Columns      []string    `json:"columns,omitempty"`
	FilesScanned int         `json:"filesScanned"`
	FilesSkipped int         `json:"filesSkipped,omitempty"`
}

ScanResult holds all table and column references found in a code repository.

func Scan

func Scan(repoPath string) (ScanResult, error)

Scan walks a code repository and extracts SQL table references.

func ScanParallel

func ScanParallel(repoPath string, workers int) (ScanResult, error)

ScanParallel walks a code repository using N goroutines. workers=0 means runtime.NumCPU(). workers=1 is sequential.

type TableRef

type TableRef struct {
	Table      string      `json:"table"`
	Schema     string      `json:"schema,omitempty"`
	File       string      `json:"file"`
	Line       int         `json:"line"`
	Pattern    PatternType `json:"pattern"`
	Context    Context     `json:"context"`
	Suppressed bool        `json:"suppressed,omitempty"`
}

TableRef is a single reference to a database table found in code.

Jump to

Keyboard shortcuts

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