sqllint

package
v1.3.0-rc.0...-d217119 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(data []byte) (map[string]Config, error)

func LoadConfigFromLocal

func LoadConfigFromLocal(filename string) (map[string]Config, error)

func Register

func Register(name string, factory Factory)

Types

type Collector

type Collector struct {
	sync.Map
}

func Get

func Get() *Collector

func (*Collector) Load

func (c *Collector) Load(name string) (Factory, bool)

func (*Collector) Range

func (c *Collector) Range(f func(key string, factory Factory) bool)

type Config

type Config struct {
	Name  string          `yaml:"name" json:"name"`
	Alias string          `yaml:"alias" json:"alias"`
	White *White          `yaml:"white" json:"white"`
	Meta  json.RawMessage `yaml:"meta" json:"meta"`
}

func (Config) DoNotLintOn

func (c Config) DoNotLintOn(moduleName, scriptName string) bool

type Factory

type Factory func(script script.Script, config Config) (rule Rule, err error)

Factory is a function that returns a Rule interface

type LintInfo

type LintInfo struct {
	Lints, Warns []error
}

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

func New

func New(configs map[string]Config) *Linter

func (*Linter) Errors

func (r *Linter) Errors() map[string]LintInfo

func (*Linter) Input

func (r *Linter) Input(moduleName, scriptName string, scriptData []byte) error

func (*Linter) Report

func (r *Linter) Report() string

type NodeRule

type NodeRule interface {
	Rule
	ast.Visitor
}

NodeRule is an Error and SQL ast visitor, can accept a SQL stmt and lint it.

type Rule

type Rule interface {
	Error() error
}

type ScriptRule

type ScriptRule interface {
	Rule

	LintOnScript()
}

type White

type White struct {
	Everything  bool     `json:"everything"`
	Modules     []string `yaml:"modules"`
	Filenames   []string `yaml:"filenames"`
	CommittedAt []string `yaml:"committedAt"`
	Patterns    []string `yaml:"patterns"`
}

func (White) Match

func (w White) Match(moduleName, scriptName string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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