mirror of
https://github.com/SigNoz/signoz.git
synced 2026-04-28 19:22:06 -05:00
chore: enable forbidigo and noerrors in depguard (#9047)
* chore: enable forbidgo * chore: enable forbidgo
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
package sqlitesqlschema
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/SigNoz/signoz/pkg/errors"
|
||||
|
||||
"github.com/SigNoz/signoz/pkg/sqlschema"
|
||||
)
|
||||
|
||||
// Inspired by https://github.com/go-gorm/sqlite
|
||||
|
||||
var (
|
||||
ErrCodeInvalidDDL = errors.MustNewCode("invalid_ddl")
|
||||
sqliteSeparator = "`|\"|'|\t"
|
||||
sqliteIdentQuote = "`|\"|'"
|
||||
uniqueRegexp = regexp.MustCompile(fmt.Sprintf(`^(?:CONSTRAINT [%v]?[\w-]+[%v]? )?UNIQUE (.*)$`, sqliteSeparator, sqliteSeparator))
|
||||
@@ -40,12 +42,12 @@ const (
|
||||
func parseCreateTable(str string, fmter sqlschema.SQLFormatter) (*sqlschema.Table, []*sqlschema.UniqueConstraint, error) {
|
||||
sections := tableRegexp.FindStringSubmatch(str)
|
||||
if len(sections) == 0 {
|
||||
return nil, nil, errors.New("invalid DDL")
|
||||
return nil, nil, errors.New(errors.TypeInternal, ErrCodeInvalidDDL, "invalid DDL")
|
||||
}
|
||||
|
||||
tableNameSections := tableNameRegexp.FindStringSubmatch(str)
|
||||
if len(tableNameSections) == 0 {
|
||||
return nil, nil, errors.New("invalid DDL")
|
||||
return nil, nil, errors.New(errors.TypeInternal, ErrCodeInvalidDDL, "invalid DDL")
|
||||
}
|
||||
|
||||
tableName := sqlschema.TableName(tableNameSections[1])
|
||||
@@ -97,14 +99,14 @@ func parseCreateTable(str string, fmter sqlschema.SQLFormatter) (*sqlschema.Tabl
|
||||
}
|
||||
|
||||
if bracketLevel < 0 {
|
||||
return nil, nil, errors.New("invalid DDL, unbalanced brackets")
|
||||
return nil, nil, errors.New(errors.TypeInternal, ErrCodeInvalidDDL, "invalid DDL, unbalanced brackets")
|
||||
}
|
||||
|
||||
buf += string(c)
|
||||
}
|
||||
|
||||
if bracketLevel != 0 {
|
||||
return nil, nil, errors.New("invalid DDL, unbalanced brackets")
|
||||
return nil, nil, errors.New(errors.TypeInternal, ErrCodeInvalidDDL, "invalid DDL, unbalanced brackets")
|
||||
}
|
||||
|
||||
if buf != "" {
|
||||
@@ -300,14 +302,14 @@ func parseAllColumns(in string) ([]sqlschema.ColumnName, error) {
|
||||
state = parseAllColumnsState_State_End
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected token: %s", string(s[i]))
|
||||
return nil, errors.Newf(errors.TypeInternal, ErrCodeInvalidDDL, "unexpected token: %s", string(s[i]))
|
||||
case parseAllColumnsState_State_End:
|
||||
// break is automatic in Go switch statements
|
||||
}
|
||||
}
|
||||
|
||||
if state != parseAllColumnsState_State_End {
|
||||
return nil, errors.New("unexpected end")
|
||||
return nil, errors.New(errors.TypeInternal, ErrCodeInvalidDDL, "unexpected end")
|
||||
}
|
||||
|
||||
return columns, nil
|
||||
|
||||
Reference in New Issue
Block a user