Skip to content

Commit

Permalink
golangci-lint: add prealloc
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex committed Dec 18, 2023
1 parent 52a013c commit f77dc14
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion flow/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ linters:
- dupl
- gofumpt
- gosec
- gosimple
- misspell
- nakedret
- stylecheck
- unconvert
- unparam
- whitespace
- errcheck
- gosimple
- prealloc
- staticcheck
- ineffassign
- unused
Expand Down
4 changes: 2 additions & 2 deletions flow/connectors/snowflake/qrep_avro_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ func (c *SnowflakeConnector) GetCopyTransformation(
return nil, fmt.Errorf("failed to get columns from destination table: %w", colsErr)
}

var transformations []string
var columnOrder []string
transformations := make([]string, len(colInfo.ColumnMap))
columnOrder := make([]string, len(colInfo.ColumnMap))
for colName, colType := range colInfo.ColumnMap {
columnOrder = append(columnOrder, fmt.Sprintf("\"%s\"", colName))
switch colType {
Expand Down
2 changes: 1 addition & 1 deletion flow/connectors/sql/query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (g *GenericSQLQueryExecutor) RecreateSchema(schemaName string) error {
}

func (g *GenericSQLQueryExecutor) CreateTable(schema *model.QRecordSchema, schemaName string, tableName string) error {
var fields []string
fields := make([]string, len(schema.Fields))
for _, field := range schema.Fields {
dbType, ok := g.qvalueKindToDBType[field.Type]
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions flow/e2e/bigquery/bigquery_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func bqFieldSchemaToQField(fieldSchema *bigquery.FieldSchema) (model.QField, err

// bqSchemaToQRecordSchema converts a bigquery schema to a QRecordSchema.
func bqSchemaToQRecordSchema(schema bigquery.Schema) (*model.QRecordSchema, error) {
var fields []model.QField
fields := make([]model.QField, len(schema))
for _, fieldSchema := range schema {
qField, err := bqFieldSchemaToQField(fieldSchema)
if err != nil {
Expand Down Expand Up @@ -433,7 +433,7 @@ func qValueKindToBqColTypeString(val qvalue.QValueKind) (string, error) {
}

func (b *BigQueryTestHelper) CreateTable(tableName string, schema *model.QRecordSchema) error {
var fields []string
fields := make([]string, len(schema.Fields))
for _, field := range schema.Fields {
bqType, err := qValueKindToBqColTypeString(field.Type)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion flow/e2e/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func GetOwnersSchema() *model.QRecordSchema {

func GetOwnersSelectorString() string {
schema := GetOwnersSchema()
var fields []string
fields := make([]string, len(schema.Fields))
for _, field := range schema.Fields {
// append quoted field name
fields = append(fields, fmt.Sprintf(`"%s"`, field.Name))
Expand Down
2 changes: 1 addition & 1 deletion flow/model/qschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (q *QRecordSchema) EqualNames(other *QRecordSchema) bool {

// GetColumnNames returns a slice of column names.
func (q *QRecordSchema) GetColumnNames() []string {
var names []string
names := make([]string, len(q.Fields))
for _, field := range q.Fields {
names = append(names, field.Name)
}
Expand Down

0 comments on commit f77dc14

Please sign in to comment.