Skip to content

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

chore: enable the exported name comments check (#1255)

Yilong Li99e4845b0d52
diff --git a/.golangci.yaml b/.golangci.yaml
index 792b12a368..fed456ea80 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -9,6 +9,12 @@ linters:
# golangci-lint run --exclude="Rollback,logger.Sync,pgInstance.Stop"
issues:
+ include:
+ # https://golangci-lint.run/usage/configuration/#command-line-options
+ - EXC0012
+ - EXC0013
+ - EXC0014
+ - EXC0015
exclude:
- Rollback
- logger.Sync
@@ -16,3 +22,11 @@ issues:
run:
timeout: 5m
+
+linters-settings:
+ revive:
+ rules:
+ - name: exported
+ arguments:
+ - checkPrivateReceivers
+ - sayRepetitiveInsteadOfStutters
diff --git a/plugin/advisor/mysql/advisor_column_required.go b/plugin/advisor/mysql/advisor_column_required.go
index f0f93b21d3..b55d8fc1d3 100644
--- a/plugin/advisor/mysql/advisor_column_required.go
+++ b/plugin/advisor/mysql/advisor_column_required.go
@@ -64,6 +64,7 @@ type columnRequirementChecker struct {
tables tableState
}
+// Enter implements the ast.Visitor interface
func (v *columnRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {
switch node := in.(type) {
// CREATE TABLE
@@ -94,6 +95,7 @@ func (v *columnRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {
return in, false
}
+// Leave implements the ast.Visitor interface
func (v *columnRequirementChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
diff --git a/plugin/advisor/mysql/advisor_migration_compatibility.go b/plugin/advisor/mysql/advisor_migration_compatibility.go
index e334ec722f..b7928a3793 100644
--- a/plugin/advisor/mysql/advisor_migration_compatibility.go
+++ b/plugin/advisor/mysql/advisor_migration_compatibility.go
@@ -49,6 +49,7 @@ type compatibilityChecker struct {
adviceList []advisor.Advice
}
+// Enter implements the ast.Visitor interface
func (v *compatibilityChecker) Enter(in ast.Node) (ast.Node, bool) {
code := common.Ok
switch node := in.(type) {
@@ -147,6 +148,7 @@ func (v *compatibilityChecker) Enter(in ast.Node) (ast.Node, bool) {
return in, false
}
+// Leave implements the ast.Visitor interface
func (v *compatibilityChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
diff --git a/plugin/advisor/mysql/advisor_naming_column.go b/plugin/advisor/mysql/advisor_naming_column.go
index 1be906709f..09075711bd 100644
--- a/plugin/advisor/mysql/advisor_naming_column.go
+++ b/plugin/advisor/mysql/advisor_naming_column.go
@@ -68,6 +68,7 @@ type namingColumnConventionChecker struct {
tables tableState
}
+// Enter implements the ast.Visitor interface
func (v *namingColumnConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
var columnList []string
var tableName string
@@ -112,6 +113,7 @@ func (v *namingColumnConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
return in, false
}
+// Leave implements the ast.Visitor interface
func (v *namingColumnConventionChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
diff --git a/plugin/advisor/mysql/advisor_naming_table.go b/plugin/advisor/mysql/advisor_naming_table.go
index 97e32c8286..d0f441a5df 100644
--- a/plugin/advisor/mysql/advisor_naming_table.go
+++ b/plugin/advisor/mysql/advisor_naming_table.go
@@ -64,6 +64,7 @@ type namingTableConventionChecker struct {
format *regexp.Regexp
}
+// Enter implements the ast.Visitor interface
func (v *namingTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
var tableNames []string
switch node := in.(type) {
@@ -99,6 +100,7 @@ func (v *namingTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {
return in, false
}
+// Leave implements the ast.Visitor interface
func (v *namingTableConventionChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
diff --git a/plugin/advisor/mysql/advisor_stmt_where_required.go b/plugin/advisor/mysql/advisor_stmt_where_required.go
index d1af99cea2..3fe819cc00 100644
--- a/plugin/advisor/mysql/advisor_stmt_where_required.go
+++ b/plugin/advisor/mysql/advisor_stmt_where_required.go
@@ -55,6 +55,7 @@ type whereRequirementChecker struct {
level advisor.Status
}
+// Enter implements the ast.Visitor interface
func (v *whereRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {
code := common.Ok
switch node := in.(type) {
@@ -81,6 +82,7 @@ func (v *whereRequirementChecker) Enter(in ast.Node) (ast.Node, bool) {
return in, false
}
+// Leave implements the ast.Visitor interface
func (v *whereRequirementChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
diff --git a/server/server.go b/server/server.go
index 0705c38f6a..7d956f6766 100644
--- a/server/server.go
+++ b/server/server.go
@@ -97,7 +97,7 @@ func NewServer(ctx context.Context, prof Profile, logger *zap.Logger, loggerLeve
s.metaDB, err = store.NewMetadataDBWithExternalPg(logger, prof.PgURL, prof.DemoDataDir, prof.Mode)
}
if err != nil {
- return nil, fmt.Errorf("cannot create metadatadb instance, error: %w", err)
+ return nil, fmt.Errorf("cannot create MetadataDB instance, error: %w", err)
}
// New store.DB instance that represents the db connection.
diff --git a/store/metadb.go b/store/metadb.go
index 044f32dd6d..5890b0c483 100644
--- a/store/metadb.go
+++ b/store/metadb.go
@@ -13,6 +13,7 @@ import (
"go.uber.org/zap"
)
+// MetadataDB abstracts the underlying Postgres instance
type MetadataDB struct {
l *zap.Logger
mode common.ReleaseMode
@@ -39,10 +40,10 @@ func NewMetadataDBWithEmbedPg(logger *zap.Logger, pgUser, dataDir, demoDataDir s
}
resourceDir := path.Join(dataDir, "resources")
pgDataDir := common.GetPostgresDataDir(dataDir)
- fmt.Println("-----Embedded Postgres Config BEGIN-----")
- fmt.Printf("resourceDir=%s\n", resourceDir)
- fmt.Printf("pgdataDir=%s\n", pgDataDir)
- fmt.Println("-----Embedded Postgres Config END-----")
+ logger.Info("-----Embedded Postgres Config BEGIN-----")
+ logger.Info(fmt.Sprintf("resourceDir=%s\n", resourceDir))
+ logger.Info(fmt.Sprintf("pgdataDir=%s\n", pgDataDir))
+ logger.Info("-----Embedded Postgres Config END-----")
logger.Info("Preparing embedded PostgreSQL instance...")
// Installs the Postgres binary and creates the 'activeProfile.pgUser' user/database
@@ -56,6 +57,7 @@ func NewMetadataDBWithEmbedPg(logger *zap.Logger, pgUser, dataDir, demoDataDir s
return mgr, nil
}
+// NewMetadataDBWithExternalPg constructs a new MetadataDB instance pointing to an external Postgres instance
func NewMetadataDBWithExternalPg(logger *zap.Logger, pgURL, demoDataDir string, mode common.ReleaseMode) (*MetadataDB, error) {
return &MetadataDB{
l: logger,
@@ -66,6 +68,7 @@ func NewMetadataDBWithExternalPg(logger *zap.Logger, pgURL, demoDataDir string,
}, nil
}
+// Connect connects to the underlying Postgres instance
func (m *MetadataDB) Connect(datastorePort int, readonly bool, version string) (*DB, error) {
if m.embed {
return m.connectEmbed(datastorePort, m.pgUser, readonly, m.demoDataDir, version, m.mode)
diff --git a/tests/tests.go b/tests/tests.go
index b11cf476cb..b78b13cc2a 100644
--- a/tests/tests.go
+++ b/tests/tests.go
@@ -308,6 +308,7 @@ func (ctl *controller) waitForHealthz() error {
}
+// Close closes long running resources
func (ctl *controller) Close(ctx context.Context) error {
var e error
if ctl.server != nil {