Documentation
¶
Overview ¶
Package yze is the analyzer catalog for the yze family: it aggregates every yze-<name> analyzer's registration and filters the set by category. The cmd/yze binary drives this catalog through the go-yze runner.
Index ¶
- Constants
- func ApplySQLConfig(analyzers []SQLAnalyzer, settings goyze.Settings) error
- func Emit(w io.Writer, format Format, report goyze.Report) error
- func EmitRules(w io.Writer, format RuleFormat, rules []Rule) error
- func Filter(regs []goyze.Registration, categories []goyze.Category) []goyze.Registration
- func LoadConfig(read func(path string) ([]byte, error), path ConfigPath) (goyze.Settings, error)
- func Registrations() []goyze.Registration
- func RootsOf(patterns []goyze.Pattern) []string
- func RunSQL(read goyze.FileReader, walk WalkDir, analyzers []SQLAnalyzer, roots []string) (goyze.Report, error)
- type ConfigPath
- type Format
- type Rule
- type RuleFormat
- type SQLAnalyzer
- type WalkDir
Constants ¶
const ( // ErrConfig reports a yze configuration file that cannot be read or parsed. ErrConfig errs.Const = "cannot load yze config" // ErrSQLSetting reports a config setting supplied for a bundled SQL analyzer, // none of which defines any settings. ErrSQLSetting errs.Const = "SQL analyzer settings are not supported" )
Configuration errors.
const ( // ErrSQLWalk reports that walking a root for .sql files failed. ErrSQLWalk errs.Const = "cannot walk for SQL files" // ErrSQLRead reports that a .sql file could not be read. ErrSQLRead errs.Const = "cannot read SQL file" )
SQL run errors.
const ErrUnknownFormat errs.Const = "unknown output format"
ErrUnknownFormat reports an output format the aggregator does not support.
const ErrUnknownRuleFormat errs.Const = "unknown rule-export format"
ErrUnknownRuleFormat reports a rule-export format the aggregator does not support.
Variables ¶
This section is empty.
Functions ¶
func ApplySQLConfig ¶ added in v0.24.1
func ApplySQLConfig(analyzers []SQLAnalyzer, settings goyze.Settings) error
ApplySQLConfig checks settings against the suite's SQL analyzers, mirroring goyze.ApplyConfig's semantics: an unknown analyzer name is ignored (a config may target a larger suite than is present), but a setting supplied for a known analyzer must be one it defines — and the SQL analyzers define none, so any setting targeting one is ErrSQLSetting rather than a silent no-op.
func EmitRules ¶ added in v0.8.0
func EmitRules(w io.Writer, format RuleFormat, rules []Rule) error
EmitRules writes the rule catalog to w in the named format.
func Filter ¶
func Filter(regs []goyze.Registration, categories []goyze.Category) []goyze.Registration
Filter selects the registrations matching the given categories. An empty category set matches every analyzer; otherwise a registration matches when it carries any of the categories.
func LoadConfig ¶ added in v0.2.0
func Registrations ¶
func Registrations() []goyze.Registration
Registrations returns every analyzer in the suite, in stable rule-id order.
func RootsOf ¶ added in v0.10.0
RootsOf turns package patterns into the directories to walk for .sql files: the recursive "/..." suffix is dropped, and a bare or empty pattern becomes ".".
func RunSQL ¶ added in v0.10.0
func RunSQL(read goyze.FileReader, walk WalkDir, analyzers []SQLAnalyzer, roots []string) (goyze.Report, error)
RunSQL finds every .sql file under the roots and runs the analyzers over each, returning the merged diagnostics. A walk or read failure aborts the run.
Types ¶
type ConfigPath ¶ added in v0.21.0
type ConfigPath string
LoadConfig reads and parses a yze config file into per-analyzer settings keyed by analyzer name then setting name, ready for go-yze's ApplyConfig. The reader is injected so callers control filesystem access. ConfigPath is the path to a yze per-analyzer config file.
type Rule ¶ added in v0.24.1
Rule is one catalog entry: the language-neutral metadata a rule export carries. Both the Go analyzer registrations (via GoRules) and the SQL analyzers (via SQLRules) reduce to this shape, so the exported catalog always describes the whole suite — every rule id a diagnostic can carry has a catalog entry.
func CatalogRules ¶ added in v0.24.1
func CatalogRules(regs []goyze.Registration, analyzers []SQLAnalyzer) []Rule
CatalogRules merges the Go and SQL analyzers' rules into the one catalog `--emit-rules` exports, sorted by rule id so the export order is deterministic regardless of which language contributed an entry.
func GoRules ¶ added in v0.24.1
func GoRules(regs []goyze.Registration) []Rule
GoRules maps the Go analyzer registrations onto their catalog rules.
func SQLRules ¶ added in v0.24.1
func SQLRules(analyzers []SQLAnalyzer) []Rule
SQLRules maps the SQL analyzers onto their catalog rules, under the same "yze/<name>" rule-id scheme their diagnostics carry.
type RuleFormat ¶ added in v0.8.0
type RuleFormat string
RuleFormat names a way the suite's rule catalog is exported. The catalog is built from catalog metadata (id, name, doc, url, categories) — never from analyzer logic — so it carries no per-analyzer machinery.
const ( // RuleFormatSARIF exports a SARIF 2.1.0 tool.driver.rules catalog for code // scanning / editor rule registration. RuleFormatSARIF RuleFormat = "sarif" // RuleFormatGrit exports a GritQL-style markdown registry. The analyzers are // AST-based, not pattern rewrites, so this is a documentation catalog (rule id, // description, docs link, categories) — not executable rewrite patterns. RuleFormatGrit RuleFormat = "grit" )
The rule-export formats `yze --emit-rules` supports.
type SQLAnalyzer ¶ added in v0.10.0
type SQLAnalyzer struct {
Analyze func(path, source string) ([]goyze.Diagnostic, error)
Name goyze.AnalyzerName
Doc string
URL goyze.HelpURL
Categories []goyze.Category
}
SQLAnalyzer is a source analyzer the suite runs over .sql files, as opposed to the go/analysis analyzers it runs over Go packages. Its diagnostics already use the shared go-yze contract, so they merge into the same report; Doc and URL are the catalog metadata mirroring goyze.Registration, so the rule exports list SQL rules alongside the Go ones.
func FilterSQL ¶ added in v0.10.0
func FilterSQL(analyzers []SQLAnalyzer, categories []goyze.Category) []SQLAnalyzer
FilterSQL selects the SQL analyzers matching the given categories, mirroring Filter. An empty category set matches every analyzer.
func SQLAnalyzers ¶ added in v0.10.0
func SQLAnalyzers() []SQLAnalyzer
SQLAnalyzers returns every SQL source analyzer bundled into the suite, in stable rule-id order.
func (SQLAnalyzer) RuleID ¶ added in v0.24.1
func (a SQLAnalyzer) RuleID() string
RuleID returns the stable rule identifier "yze/<name>" carried by every diagnostic the analyzer emits, mirroring goyze.Registration.RuleID so both languages share one flat id scheme.
type WalkDir ¶ added in v0.10.0
type WalkDir func(root string, fn fs.WalkDirFunc) error
WalkDir is fs.WalkDir's signature. It's injected so a test can drive the file walk without a real directory tree.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
yze
command
Command yze runs the gomatic yze analyzer suite over the given package patterns and emits a normalized report (the stickler-json contract by default).
|
Command yze runs the gomatic yze analyzer suite over the given package patterns and emits a normalized report (the stickler-json contract by default). |