lint

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ENABLE_PGSQL_CHECK = "CREATE EXTENSION IF NOT EXISTS plpgsql_check"

Variables

View Source
var (
	AllowedLevels = []string{
		"warning",
		"error",
	}
)

Functions

func ConnectLocalPostgres

func ConnectLocalPostgres(ctx context.Context, host string, port uint, database string, options ...func(*pgx.ConnConfig)) (*pgx.Conn, error)

Connnect to local Postgres with optimised settings. The caller is responsible for closing the connection returned.

func Run

func Run(ctx context.Context, schema []string, level string, fsys afero.Fs, opts ...func(*pgx.ConnConfig)) error

Types

type Issue

type Issue struct {
	Level     string     `json:"level"`
	Message   string     `json:"message"`
	Statement *Statement `json:"statement,omitempty"`
	Query     *Query     `json:"query,omitempty"`
	Hint      string     `json:"hint,omitempty"`
	Detail    string     `json:"detail,omitempty"`
	Context   string     `json:"context,omitempty"`
	SQLState  string     `json:"sqlState,omitempty"`
}

type LintLevel

type LintLevel int

type Query

type Query struct {
	Position string `json:"position"`
	Text     string `json:"text"`
}

type Result

type Result struct {
	Function string  `json:"function"`
	Issues   []Issue `json:"issues"`
}

func LintDatabase

func LintDatabase(ctx context.Context, conn *pgx.Conn, schema []string) ([]Result, error)

type Statement

type Statement struct {
	LineNumber string `json:"lineNumber"`
	Text       string `json:"text"`
}

Jump to

Keyboard shortcuts

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