Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: rename variables in plugin/advisor (#1227)

rebeliceae5c20f08918
diff --git a/plugin/advisor/advisor.go b/plugin/advisor/advisor.go
index 4272951d6f..85f2451896 100644
--- a/plugin/advisor/advisor.go
+++ b/plugin/advisor/advisor.go
@@ -59,8 +59,8 @@ const (
MySQLMigrationCompatibility Type = "bb.plugin.advisor.mysql.migration-compatibility"
// MySQLWhereRequirement is an advisor type for MySQL WHERE clause requirement.
MySQLWhereRequirement Type = "bb.plugin.advisor.mysql.where.require"
- // MySQLTableNamingConvention is an advisor type for MySQL table naming convention.
- MySQLTableNamingConvention Type = "bb.plugin.advisor.mysql.naming.table"
+ // MySQLNamingTableConvention is an advisor type for MySQL table naming convention.
+ MySQLNamingTableConvention Type = "bb.plugin.advisor.mysql.naming.table"
// MySQLColumnRequirement is an advisor type for MySQL column requirement.
MySQLColumnRequirement Type = "bb.plugin.advisor.mysql.column.require"
)
diff --git a/plugin/advisor/mysql/advisor_column_required.go b/plugin/advisor/mysql/advisor_column_required.go
index ce90a08e26..a0c25e7e8a 100644
--- a/plugin/advisor/mysql/advisor_column_required.go
+++ b/plugin/advisor/mysql/advisor_column_required.go
@@ -61,7 +61,7 @@ type columnSet map[string]bool
type tableState map[string]columnSet
type columnRequirementChecker struct {
- advisorList []advisor.Advice
+ adviceList []advisor.Advice
level advisor.Status
requiredColumns columnSet
tables tableState
@@ -119,7 +119,7 @@ func (v *columnRequirementChecker) generateAdvisorList() []advisor.Advice {
if len(missingColumns) > 0 {
// Order it cause the random iteration order in Go, see https://go.dev/blog/maps
sort.Strings(missingColumns)
- v.advisorList = append(v.advisorList, advisor.Advice{
+ v.adviceList = append(v.adviceList, advisor.Advice{
Status: v.level,
Code: common.NoRequiredColumn,
Title: "Require columns",
@@ -128,15 +128,15 @@ func (v *columnRequirementChecker) generateAdvisorList() []advisor.Advice {
}
}
- if len(v.advisorList) == 0 {
- v.advisorList = append(v.advisorList, advisor.Advice{
+ if len(v.adviceList) == 0 {
+ v.adviceList = append(v.adviceList, advisor.Advice{
Status: advisor.Success,
Code: common.Ok,
Title: "OK",
Content: "",
})
}
- return v.advisorList
+ return v.adviceList
}
// initEmptyTable will initialize a table without any required columns.
diff --git a/plugin/advisor/mysql/advisor_migration_compatibility.go b/plugin/advisor/mysql/advisor_migration_compatibility.go
index cfa355ee2c..e334ec722f 100644
--- a/plugin/advisor/mysql/advisor_migration_compatibility.go
+++ b/plugin/advisor/mysql/advisor_migration_compatibility.go
@@ -35,18 +35,18 @@ func (adv *CompatibilityAdvisor) Check(ctx advisor.Context, statement string) ([
(stmtNode).Accept(c)
}
- if len(c.advisorList) == 0 {
- c.advisorList = append(c.advisorList, advisor.Advice{
+ if len(c.adviceList) == 0 {
+ c.adviceList = append(c.adviceList, advisor.Advice{
Status: advisor.Success,
Code: common.Ok,
Title: "OK",
Content: "Migration is backward compatible"})
}
- return c.advisorList, nil
+ return c.adviceList, nil
}
type compatibilityChecker struct {
- advisorList []advisor.Advice
+ adviceList []advisor.Advice
}
func (v *compatibilityChecker) Enter(in ast.Node) (ast.Node, bool) {
@@ -137,7 +137,7 @@ func (v *compatibilityChecker) Enter(in ast.Node) (ast.Node, bool) {
}
if code != common.Ok {
- v.advisorList = append(v.advisorList, advisor.Advice{
+ v.adviceList = append(v.adviceList, advisor.Advice{
Status: advisor.Warn,
Code: code,
Title: "Potential incompatible migration",
diff --git a/plugin/advisor/mysql/advisor_naming_table.go b/plugin/advisor/mysql/advisor_naming_table.go
index c5a97e25be..61578498d6 100644
--- a/plugin/advisor/mysql/advisor_naming_table.go
+++ b/plugin/advisor/mysql/advisor_naming_table.go
@@ -12,20 +12,20 @@ import (
)
var (
- _ advisor.Advisor = (*TableNamingConventionAdvisor)(nil)
+ _ advisor.Advisor = (*NamingTableConventionAdvisor)(nil)
)
func init() {
- advisor.Register(db.MySQL, advisor.MySQLTableNamingConvention, &TableNamingConventionAdvisor{})
- advisor.Register(db.TiDB, advisor.MySQLTableNamingConvention, &TableNamingConventionAdvisor{})
+ advisor.Register(db.MySQL, advisor.MySQLNamingTableConvention, &NamingTableConventionAdvisor{})
+ advisor.Register(db.TiDB, advisor.MySQLNamingTableConvention, &NamingTableConventionAdvisor{})
}
-// TableNamingConventionAdvisor is the advisor checking for table naming convention.
-type TableNamingConventionAdvisor struct {
+// NamingTableConventionAdvisor is the advisor checking for table naming convention.
+type NamingTableConventionAdvisor struct {
}
// Check checks for table naming convention.
-func (adv *TableNamingConventionAdvisor) Check(ctx advisor.Context, statement string) ([]advisor.Advice, error) {
+func (adv *NamingTableConventionAdvisor) Check(ctx advisor.Context, statement string) ([]advisor.Advice, error) {
root, errAdvice := parseStatement(statement, ctx.Charset, ctx.Collation)
if errAdvice != nil {
return errAdvice, nil
@@ -39,7 +39,7 @@ func (adv *TableNamingConventionAdvisor) Check(ctx advisor.Context, statement st
if err != nil {
return nil, err
}
- checker := &tableNamingConventionChecker{
+ checker := &namingTableConventionChecker{
level: level,
format: format,
}
@@ -47,25 +47,25 @@ func (adv *TableNamingConventionAdvisor) Check(ctx advisor.Context, statement st
(stmtNode).Accept(checker)
}
- if len(checker.advisorList) == 0 {
- checker.advisorList = append(checker.advisorList, advisor.Advice{
+ if len(checker.adviceList) == 0 {
+ checker.adviceList = append(checker.adviceList, advisor.Advice{
Status: advisor.Success,
Code: common.Ok,
Title: "OK",
Content: "",
})
}
- return checker.advisorList, nil
+ return checker.adviceList, nil
}
-type tableNamingConventionChecker struct {
- advisorList []advisor.Advice
- level advisor.Status
- format *regexp.Regexp
+type namingTableConventionChecker struct {
+ adviceList []advisor.Advice
+ level advisor.Status
+ format *regexp.Regexp
}
-func (v *tableNamingConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
- tableNames := make([]string, 0)
+func (v *namingTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
+ var tableNames []string
switch node := in.(type) {
// CREATE TABLE
case *ast.CreateTableStmt:
@@ -96,7 +96,7 @@ func (v *tableNamingConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
}
if code != common.Ok {
- v.advisorList = append(v.advisorList, advisor.Advice{
+ v.adviceList = append(v.adviceList, advisor.Advice{
Status: v.level,
Code: code,
Title: "Mismatch table naming convention",
@@ -106,6 +106,6 @@ func (v *tableNamingConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
return in, false
}
-func (v *tableNamingConventionChecker) Leave(in ast.Node) (ast.Node, bool) {
+func (v *namingTableConventionChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
diff --git a/plugin/advisor/mysql/advisor_naming_table_test.go b/plugin/advisor/mysql/advisor_naming_table_test.go
index 80b0afc5be..45dc61a07b 100644
--- a/plugin/advisor/mysql/advisor_naming_table_test.go
+++ b/plugin/advisor/mysql/advisor_naming_table_test.go
@@ -83,7 +83,7 @@ func TestTableNamingRequirement(t *testing.T) {
Format: "^[a-z]+(_[a-z]+)?$",
})
require.NoError(t, err)
- runSchemaReviewRuleTests(t, tests, &TableNamingConventionAdvisor{}, &api.SchemaReviewRule{
+ runSchemaReviewRuleTests(t, tests, &NamingTableConventionAdvisor{}, &api.SchemaReviewRule{
Type: api.SchemaRuleTableNaming,
Level: api.SchemaRuleLevelError,
Payload: string(payload),
diff --git a/plugin/advisor/mysql/advisor_stmt_where_required.go b/plugin/advisor/mysql/advisor_stmt_where_required.go
index 7521af1caa..d1af99cea2 100644
--- a/plugin/advisor/mysql/advisor_stmt_where_required.go
+++ b/plugin/advisor/mysql/advisor_stmt_where_required.go
@@ -39,20 +39,20 @@ func (adv *WhereRequirementAdvisor) Check(ctx advisor.Context, statement string)
(stmtNode).Accept(we)
}
- if len(we.advisorList) == 0 {
- we.advisorList = append(we.advisorList, advisor.Advice{
+ if len(we.adviceList) == 0 {
+ we.adviceList = append(we.adviceList, advisor.Advice{
Status: advisor.Success,
Code: common.Ok,
Title: "OK",
Content: "",
})
}
- return we.advisorList, nil
+ return we.adviceList, nil
}
type whereRequirementChecker struct {
- advisorList []advisor.Advice
- level advisor.Status
+ adviceList []advisor.Advice
+ level advisor.Status
}
func (v *whereRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {
@@ -71,7 +71,7 @@ func (v *whereRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {
}
if code != common.Ok {
- v.advisorList = append(v.advisorList, advisor.Advice{
+ v.adviceList = append(v.adviceList, advisor.Advice{
Status: v.level,
Code: code,
Title: "Require WHERE clause",
diff --git a/plugin/advisor/mysql/advisor_syntax.go b/plugin/advisor/mysql/advisor_syntax.go
index 6ec225fadf..b049b5e50e 100644
--- a/plugin/advisor/mysql/advisor_syntax.go
+++ b/plugin/advisor/mysql/advisor_syntax.go
@@ -35,9 +35,9 @@ func (adv *SyntaxAdvisor) Check(ctx advisor.Context, statement string) ([]adviso
}, nil
}
- var advisorList []advisor.Advice
+ var adviceList []advisor.Advice
for _, warn := range warns {
- advisorList = append(advisorList, advisor.Advice{
+ adviceList = append(adviceList, advisor.Advice{
Status: advisor.Warn,
Code: common.DbStatementSyntaxError,
Title: "Syntax Warning",
@@ -45,10 +45,10 @@ func (adv *SyntaxAdvisor) Check(ctx advisor.Context, statement string) ([]adviso
})
}
- advisorList = append(advisorList, advisor.Advice{
+ adviceList = append(adviceList, advisor.Advice{
Status: advisor.Success,
Code: common.Ok,
Title: "Syntax OK",
Content: "OK"})
- return advisorList, nil
+ return adviceList, nil
}
diff --git a/server/task_check_executor_statement_advisor_composite.go b/server/task_check_executor_statement_advisor_composite.go
index e6babe02f3..64737715ab 100644
--- a/server/task_check_executor_statement_advisor_composite.go
+++ b/server/task_check_executor_statement_advisor_composite.go
@@ -126,7 +126,7 @@ func getAdvisorTypeByRule(ruleType api.SchemaReviewRuleType, engine db.Type) (ad
case api.SchemaRuleTableNaming:
switch engine {
case db.MySQL, db.TiDB:
- return advisor.MySQLTableNamingConvention, nil
+ return advisor.MySQLNamingTableConvention, nil
}
case api.SchemaRuleRequiredColumn:
switch engine {