linters

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateDatabaseStmt uint64 = 1 << iota
	AlterDatabaseStmt
	DropDatabaseStmt
	CreateTableStmt
	DropTableStmt
	DropSequenceStmt
	RenameTableStmt
	CreateViewStmt
	CreateSequenceStmt
	CreateIndexStmt
	DropIndexStmt
	LockTablesStmt
	UnlockTablesStmt
	CleanupTableLockStmt
	RepairTableStmt
	TruncateTableStmt
	RecoverTableStmt
	FlashBackTableStmt

	AlterTableOption
	AlterTableAddColumns
	AlterTableAddConstraint
	AlterTableDropColumn
	AlterTableDropPrimaryKey
	AlterTableDropIndex
	AlterTableDropForeignKey
	AlterTableModifyColumn
	AlterTableChangeColumn
	AlterTableRenameColumn
	AlterTableRenameTable
	AlterTableAlterColumn
	AlterTableLock
	AlterTableAlgorithm
	AlterTableRenameIndex
	AlterTableForce
	AlterTableAddPartitions
	AlterTableCoalescePartitions
	AlterTableDropPartition
	AlterTableTruncatePartition
	AlterTablePartition
	AlterTableEnableKeys
	AlterTableDisableKeys
	AlterTableRemovePartitioning
	AlterTableWithValidation
	AlterTableWithoutValidation
	AlterTableSecondaryLoad
	AlterTableSecondaryUnload
	AlterTableRebuildPartition
	AlterTableReorganizePartition
	AlterTableCheckPartitions
	AlterTableExchangePartition
	AlterTableOptimizePartition
	AlterTableRepairPartition
	AlterTableImportPartitionTablespace
	AlterTableDiscardPartitionTablespace
	AlterTableAlterCheck
	AlterTableDropCheck
	AlterTableImportTablespace
	AlterTableDiscardTablespace
	AlterTableIndexInvisible
	AlterTableOrderByColumns
	AlterTableSetTiFlashReplica
)
View Source
const (
	SelectStmt uint64 = 1 << iota
	UnionStmt
	LoadDataStmt
	InsertStmt
	DeleteStmt
	UpdateStmt
	ShowStmt
	SplitRegionStmt
)
View Source
const (
	AlterTableStmt = AlterTableOption | AlterTableAddColumns | AlterTableAddConstraint |
		AlterTableDropColumn | AlterTableDropPrimaryKey | AlterTableDropIndex |
		AlterTableDropForeignKey | AlterTableModifyColumn |
		AlterTableChangeColumn | AlterTableRenameColumn | AlterTableRenameTable | AlterTableAlterColumn |
		AlterTableLock | AlterTableAlgorithm | AlterTableRenameIndex |
		AlterTableForce | AlterTableAddPartitions | AlterTableCoalescePartitions |
		AlterTableDropPartition | AlterTableTruncatePartition | AlterTablePartition |
		AlterTableEnableKeys | AlterTableDisableKeys | AlterTableRemovePartitioning |
		AlterTableWithValidation | AlterTableWithoutValidation | AlterTableSecondaryLoad |
		AlterTableSecondaryUnload | AlterTableRebuildPartition | AlterTableReorganizePartition |
		AlterTableCheckPartitions | AlterTableExchangePartition | AlterTableOptimizePartition |
		AlterTableRepairPartition | AlterTableImportPartitionTablespace | AlterTableDiscardPartitionTablespace |
		AlterTableAlterCheck | AlterTableDropCheck | AlterTableImportTablespace |
		AlterTableDiscardTablespace | AlterTableIndexInvisible | AlterTableOrderByColumns |
		AlterTableSetTiFlashReplica

	DDLStmt = CreateDatabaseStmt | AlterDatabaseStmt | DropDatabaseStmt |
		CreateTableStmt | DropTableStmt | DropSequenceStmt |
		RenameTableStmt | CreateViewStmt | CreateSequenceStmt |
		CreateIndexStmt | DropIndexStmt | LockTablesStmt |
		UnlockTablesStmt | CleanupTableLockStmt | RepairTableStmt |
		TruncateTableStmt | RecoverTableStmt | FlashBackTableStmt |
		AlterTableStmt

	DMLStmt = SelectStmt | UnionStmt | LoadDataStmt |
		InsertStmt | DeleteStmt | UpdateStmt |
		ShowStmt | SplitRegionStmt
)
View Source
const UTF8MB4 = "utf8mb4"

Variables

This section is empty.

Functions

func NewAllowedStmtLinter

func NewAllowedStmtLinter(allowedDDLs, allowedDMLs uint64) rules.Ruler

func NewBooleanFieldLinter

func NewBooleanFieldLinter(script script.Script) rules.Rule

func NewCharsetLinter

func NewCharsetLinter(script script.Script) rules.Rule

func NewColumnCommentLinter

func NewColumnCommentLinter(script script.Script) rules.Rule

func NewColumnNameLinter

func NewColumnNameLinter(script script.Script) rules.Rule

func NewCompleteInsertLinter

func NewCompleteInsertLinter(script script.Script) rules.Rule

NewCompleteInsertLinter returns a CompleteInsertLinter CompleteInsertLinter lint if the INSERT statement is complete-insert.

e.g. NOT OK: INSERT INTO table_name VALUES (value1,value2,value3,...);

OK: INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...);

func NewCreatedAtDefaultValueLinter

func NewCreatedAtDefaultValueLinter(script script.Script) rules.Rule

func NewCreatedAtExistsLinter

func NewCreatedAtExistsLinter(script script.Script) rules.Rule

func NewCreatedAtTypeLinter

func NewCreatedAtTypeLinter(script script.Script) rules.Rule

func NewDDLDMLLinter

func NewDDLDMLLinter(script script.Script) rules.Rule

func NewDestructLinter

func NewDestructLinter(script script.Script) rules.Rule

func NewExplicitCollationLinter

func NewExplicitCollationLinter(script script.Script) rules.Rule

NewExplicitCollationLinter returns an ExplicitCollationLinter

func NewFloatDoubleLinter

func NewFloatDoubleLinter(script script.Script) rules.Rule

func NewForeignKeyLinter

func NewForeignKeyLinter(script script.Script) rules.Rule

func NewIDExistsLinter

func NewIDExistsLinter(script script.Script) rules.Rule

func NewIDIsPrimaryLinter

func NewIDIsPrimaryLinter(script script.Script) rules.Rule

func NewIDTypeLinter

func NewIDTypeLinter(script script.Script) rules.Rule

func NewIndexLengthLinter

func NewIndexLengthLinter(script script.Script) rules.Rule

func NewIndexNameLinter

func NewIndexNameLinter(script script.Script) rules.Rule

func NewKeywordsLinter

func NewKeywordsLinter(script script.Script) rules.Rule

func NewManualTimeSetterLinter

func NewManualTimeSetterLinter(script script.Script) rules.Rule

NewManualTimeSetterLinter returns a ManualTimeSetterLinter ManualTimeSetterLinter lints if the user manually set the column created_at, updated_at

func NewNotNullLinter

func NewNotNullLinter(script script.Script) rules.Rule

func NewTableCommentLinter

func NewTableCommentLinter(script script.Script) rules.Rule

func NewTableNameLinter

func NewTableNameLinter(script script.Script) rules.Rule

func NewUpdatedAtDefaultValueLinter

func NewUpdatedAtDefaultValueLinter(script script.Script) rules.Rule

func NewUpdatedAtExistsLinter

func NewUpdatedAtExistsLinter(script script.Script) rules.Rule

func NewUpdatedAtOnUpdateLinter

func NewUpdatedAtOnUpdateLinter(script script.Script) rules.Rule

func NewUpdatedAtTypeLinter

func NewUpdatedAtTypeLinter(script script.Script) rules.Rule

func NewVarcharLengthLinter

func NewVarcharLengthLinter(script script.Script) rules.Rule

Types

type AllowedStmt

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

func (*AllowedStmt) Enter

func (l *AllowedStmt) Enter(in ast.Node) (ast.Node, bool)

func (*AllowedStmt) Error

func (l *AllowedStmt) Error() error

func (*AllowedStmt) Leave

func (l *AllowedStmt) Leave(in ast.Node) (ast.Node, bool)

type BooleanFieldLinter

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

func (*BooleanFieldLinter) Enter

func (l *BooleanFieldLinter) Enter(in ast.Node) (ast.Node, bool)

func (*BooleanFieldLinter) Error

func (l *BooleanFieldLinter) Error() error

func (*BooleanFieldLinter) Leave

func (l *BooleanFieldLinter) Leave(in ast.Node) (ast.Node, bool)

type CharsetLinter

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

func (*CharsetLinter) Enter

func (l *CharsetLinter) Enter(in ast.Node) (ast.Node, bool)

func (*CharsetLinter) Error

func (l *CharsetLinter) Error() error

func (*CharsetLinter) Leave

func (l *CharsetLinter) Leave(in ast.Node) (ast.Node, bool)

type ColumnCommentLinter

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

func (*ColumnCommentLinter) Enter

func (l *ColumnCommentLinter) Enter(in ast.Node) (ast.Node, bool)

func (*ColumnCommentLinter) Error

func (l *ColumnCommentLinter) Error() error

func (*ColumnCommentLinter) Leave

func (l *ColumnCommentLinter) Leave(in ast.Node) (ast.Node, bool)

type ColumnNameLinter

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

func (*ColumnNameLinter) Enter

func (l *ColumnNameLinter) Enter(in ast.Node) (ast.Node, bool)

func (*ColumnNameLinter) Error

func (l *ColumnNameLinter) Error() error

func (*ColumnNameLinter) Leave

func (l *ColumnNameLinter) Leave(in ast.Node) (ast.Node, bool)

type CompleteInsertLinter

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

CompleteInsertLinter lints if the INSERT statement is complete

func (*CompleteInsertLinter) Enter

func (l *CompleteInsertLinter) Enter(in ast.Node) (node ast.Node, skipChildren bool)

func (CompleteInsertLinter) Error

func (b CompleteInsertLinter) Error() error

func (*CompleteInsertLinter) Leave

func (l *CompleteInsertLinter) Leave(in ast.Node) (node ast.Node, ok bool)

type CreatedAtDefaultValueLinter

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

func (*CreatedAtDefaultValueLinter) Enter

func (l *CreatedAtDefaultValueLinter) Enter(in ast.Node) (ast.Node, bool)

func (*CreatedAtDefaultValueLinter) Error

func (*CreatedAtDefaultValueLinter) Leave

func (l *CreatedAtDefaultValueLinter) Leave(in ast.Node) (ast.Node, bool)

type CreatedAtExistsLinter

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

func (*CreatedAtExistsLinter) Enter

func (l *CreatedAtExistsLinter) Enter(in ast.Node) (ast.Node, bool)

func (*CreatedAtExistsLinter) Error

func (l *CreatedAtExistsLinter) Error() error

func (*CreatedAtExistsLinter) Leave

func (l *CreatedAtExistsLinter) Leave(in ast.Node) (ast.Node, bool)

type CreatedAtTypeLinter

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

func (*CreatedAtTypeLinter) Enter

func (l *CreatedAtTypeLinter) Enter(in ast.Node) (ast.Node, bool)

func (*CreatedAtTypeLinter) Error

func (l *CreatedAtTypeLinter) Error() error

func (*CreatedAtTypeLinter) Leave

func (l *CreatedAtTypeLinter) Leave(in ast.Node) (ast.Node, bool)

type DDLDMLLinter

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

func (*DDLDMLLinter) Enter

func (l *DDLDMLLinter) Enter(in ast.Node) (ast.Node, bool)

func (*DDLDMLLinter) Error

func (l *DDLDMLLinter) Error() error

func (*DDLDMLLinter) Leave

func (l *DDLDMLLinter) Leave(in ast.Node) (ast.Node, bool)

type DestructLinter

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

func (*DestructLinter) Enter

func (l *DestructLinter) Enter(in ast.Node) (ast.Node, bool)

func (*DestructLinter) Error

func (l *DestructLinter) Error() error

func (*DestructLinter) Leave

func (l *DestructLinter) Leave(in ast.Node) (ast.Node, bool)

type ExplicitCollationLinter

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

ExplicitCollationLinter lints if user set the collation explicitly

func (*ExplicitCollationLinter) Enter

func (l *ExplicitCollationLinter) Enter(in ast.Node) (node ast.Node, skipChildren bool)

func (ExplicitCollationLinter) Error

func (b ExplicitCollationLinter) Error() error

func (*ExplicitCollationLinter) Leave

func (l *ExplicitCollationLinter) Leave(in ast.Node) (node ast.Node, ok bool)

type FloatDoubleLinter

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

func (*FloatDoubleLinter) Enter

func (l *FloatDoubleLinter) Enter(in ast.Node) (ast.Node, bool)

func (*FloatDoubleLinter) Error

func (l *FloatDoubleLinter) Error() error

func (*FloatDoubleLinter) Leave

func (l *FloatDoubleLinter) Leave(in ast.Node) (ast.Node, bool)

type ForeignKeyLinter

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

func (*ForeignKeyLinter) Enter

func (l *ForeignKeyLinter) Enter(in ast.Node) (ast.Node, bool)

func (*ForeignKeyLinter) Error

func (l *ForeignKeyLinter) Error() error

func (*ForeignKeyLinter) Leave

func (l *ForeignKeyLinter) Leave(in ast.Node) (ast.Node, bool)

type IDExistsLinter

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

func (*IDExistsLinter) Enter

func (l *IDExistsLinter) Enter(in ast.Node) (ast.Node, bool)

func (*IDExistsLinter) Error

func (l *IDExistsLinter) Error() error

func (*IDExistsLinter) Leave

func (l *IDExistsLinter) Leave(in ast.Node) (ast.Node, bool)

type IDIsPrimaryLinter

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

func (*IDIsPrimaryLinter) Enter

func (l *IDIsPrimaryLinter) Enter(in ast.Node) (ast.Node, bool)

func (*IDIsPrimaryLinter) Error

func (l *IDIsPrimaryLinter) Error() error

func (*IDIsPrimaryLinter) Leave

func (l *IDIsPrimaryLinter) Leave(in ast.Node) (ast.Node, bool)

type IDTypeLinter

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

func (*IDTypeLinter) Enter

func (l *IDTypeLinter) Enter(in ast.Node) (ast.Node, bool)

func (*IDTypeLinter) Error

func (l *IDTypeLinter) Error() error

func (*IDTypeLinter) Leave

func (l *IDTypeLinter) Leave(in ast.Node) (ast.Node, bool)

type IndexLengthLinter

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

func (*IndexLengthLinter) Enter

func (l *IndexLengthLinter) Enter(in ast.Node) (ast.Node, bool)

func (*IndexLengthLinter) Error

func (l *IndexLengthLinter) Error() error

func (*IndexLengthLinter) Leave

func (l *IndexLengthLinter) Leave(in ast.Node) (ast.Node, bool)

type IndexNameLinter

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

func (*IndexNameLinter) Enter

func (l *IndexNameLinter) Enter(in ast.Node) (ast.Node, bool)

func (*IndexNameLinter) Error

func (l *IndexNameLinter) Error() error

func (*IndexNameLinter) Leave

func (l *IndexNameLinter) Leave(in ast.Node) (ast.Node, bool)

type KeywordsLinter

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

func (*KeywordsLinter) Enter

func (l *KeywordsLinter) Enter(in ast.Node) (ast.Node, bool)

func (*KeywordsLinter) Error

func (l *KeywordsLinter) Error() error

func (*KeywordsLinter) Leave

func (l *KeywordsLinter) Leave(in ast.Node) (ast.Node, bool)

type ManualTimeSetterLinter

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

ManualTimeSetterLinter lints if the user manually set the column created_at, updated_at

func (*ManualTimeSetterLinter) Enter

func (l *ManualTimeSetterLinter) Enter(in ast.Node) (out ast.Node, skipChildren bool)

func (ManualTimeSetterLinter) Error

func (b ManualTimeSetterLinter) Error() error

func (*ManualTimeSetterLinter) Leave

func (l *ManualTimeSetterLinter) Leave(in ast.Node) (out ast.Node, ok bool)

type NotNullLinter

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

func (*NotNullLinter) Enter

func (l *NotNullLinter) Enter(in ast.Node) (out ast.Node, skip bool)

func (*NotNullLinter) Error

func (l *NotNullLinter) Error() error

func (*NotNullLinter) Leave

func (l *NotNullLinter) Leave(in ast.Node) (ast.Node, bool)

type TableCommentLinter

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

func (*TableCommentLinter) Enter

func (l *TableCommentLinter) Enter(in ast.Node) (ast.Node, bool)

func (*TableCommentLinter) Error

func (l *TableCommentLinter) Error() error

func (*TableCommentLinter) Leave

func (l *TableCommentLinter) Leave(in ast.Node) (ast.Node, bool)

type TableNameLinter

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

func (*TableNameLinter) Enter

func (l *TableNameLinter) Enter(in ast.Node) (ast.Node, bool)

func (*TableNameLinter) Error

func (l *TableNameLinter) Error() error

func (*TableNameLinter) Leave

func (l *TableNameLinter) Leave(in ast.Node) (ast.Node, bool)

type UpdatedAtDefaultValueLinter

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

func (*UpdatedAtDefaultValueLinter) Enter

func (l *UpdatedAtDefaultValueLinter) Enter(in ast.Node) (ast.Node, bool)

func (*UpdatedAtDefaultValueLinter) Error

func (*UpdatedAtDefaultValueLinter) Leave

func (l *UpdatedAtDefaultValueLinter) Leave(in ast.Node) (ast.Node, bool)

type UpdatedAtExistsLinter

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

func (*UpdatedAtExistsLinter) Enter

func (l *UpdatedAtExistsLinter) Enter(in ast.Node) (ast.Node, bool)

func (*UpdatedAtExistsLinter) Error

func (l *UpdatedAtExistsLinter) Error() error

func (*UpdatedAtExistsLinter) Leave

func (l *UpdatedAtExistsLinter) Leave(in ast.Node) (ast.Node, bool)

type UpdatedAtOnUpdateLinter

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

func (*UpdatedAtOnUpdateLinter) Enter

func (l *UpdatedAtOnUpdateLinter) Enter(in ast.Node) (ast.Node, bool)

func (*UpdatedAtOnUpdateLinter) Error

func (l *UpdatedAtOnUpdateLinter) Error() error

func (*UpdatedAtOnUpdateLinter) Leave

func (l *UpdatedAtOnUpdateLinter) Leave(in ast.Node) (ast.Node, bool)

type UpdatedAtTypeLinter

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

func (*UpdatedAtTypeLinter) Enter

func (l *UpdatedAtTypeLinter) Enter(in ast.Node) (ast.Node, bool)

func (*UpdatedAtTypeLinter) Error

func (l *UpdatedAtTypeLinter) Error() error

func (*UpdatedAtTypeLinter) Leave

func (l *UpdatedAtTypeLinter) Leave(in ast.Node) (ast.Node, bool)

type VarcharLengthLinter

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

func (*VarcharLengthLinter) Enter

func (l *VarcharLengthLinter) Enter(in ast.Node) (ast.Node, bool)

func (*VarcharLengthLinter) Error

func (l *VarcharLengthLinter) Error() error

func (*VarcharLengthLinter) Leave

func (l *VarcharLengthLinter) Leave(in ast.Node) (ast.Node, bool)

Jump to

Keyboard shortcuts

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