Update golangci-lint and turn it on in CI

This commit is contained in:
Dmitry Kropachev
2024-06-14 13:07:21 -04:00
committed by Sylwia Szunejko
parent a9ab270196
commit ab80d70106
37 changed files with 225 additions and 151 deletions

View File

@@ -18,21 +18,21 @@ import (
// BatchBuilder builds CQL BATCH statements.
type BatchBuilder struct {
unlogged bool
counter bool
using using
stmts []string
names []string
using using
unlogged bool
counter bool
}
// Batch returns a new BatchBuilder.
// BatchBuilder encapsulates batch cqls as one ordinary gocql.Query for convenience.
// Below are the limitations of encapsulating batch cqls based on gocql.Query instead of gocql.Batch:
// * gocql.Batch has some more batch specific check, such as BatchSize(65535).
// * gocql.Batch use BatchObserver instead of QueryObserver.
// * gocql.Batch has cancelBatch call back.
// * gocql.Batch prepares the included statements separately, which is more efficient.
// In contrast, gocqlx.qb.BatchBuilder, which is based on gocql.Query, prepares the whole batch statements as one ordinary query.
// - gocql.Batch has some more batch specific check, such as BatchSize(65535).
// - gocql.Batch use BatchObserver instead of QueryObserver.
// - gocql.Batch has cancelBatch call back.
// - gocql.Batch prepares the included statements separately, which is more efficient.
// In contrast, gocqlx.qb.BatchBuilder, which is based on gocql.Query, prepares the whole batch statements as one ordinary query.
//
// Deprecated: Please use gocql.Session.NewBatch() instead.
func Batch() *BatchBuilder {

View File

@@ -39,7 +39,8 @@ func TestBatchBuilder(t *testing.T) {
B: Batch().
AddWithPrefix("a", m).
AddWithPrefix("b", m),
S: "BEGIN BATCH INSERT INTO cycling.cyclist_name (id,user_uuid,firstname) VALUES (?,?,?) ; INSERT INTO cycling.cyclist_name (id,user_uuid,firstname) VALUES (?,?,?) ; APPLY BATCH ",
S: "BEGIN BATCH INSERT INTO cycling.cyclist_name (id,user_uuid,firstname) VALUES (?,?,?) ; " +
"INSERT INTO cycling.cyclist_name (id,user_uuid,firstname) VALUES (?,?,?) ; APPLY BATCH ",
N: []string{"a.id", "a.user_uuid", "a.firstname", "b.id", "b.user_uuid", "b.firstname"},
},
// Add UNLOGGED
@@ -64,7 +65,7 @@ func TestBatchBuilder(t *testing.T) {
},
// Add TIMESTAMP
{
B: Batch().Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: Batch().Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "BEGIN BATCH USING TIMESTAMP 1115251200000000 APPLY BATCH ",
},
{

View File

@@ -26,9 +26,9 @@ const (
// Cmp if a filtering comparator that is used in WHERE and IF clauses.
type Cmp struct {
op op
column string
value value
column string
op op
}
func (c Cmp) writeCql(cql *bytes.Buffer) (names []string) {

View File

@@ -165,8 +165,6 @@ func TestCmp(t *testing.T) {
S: "like LIKE (?,?)",
N: []string{"name[0]", "name[1]"},
},
// Custom bind names on tuples
{
C: EqTupleNamed("eq", 2, "name"),

View File

@@ -19,9 +19,9 @@ import (
type DeleteBuilder struct {
table string
columns columns
using using
where where
_if _if
using using
exists bool
}

View File

@@ -69,7 +69,7 @@ func TestDeleteBuilder(t *testing.T) {
},
// Add TIMESTAMP
{
B: Delete("cycling.cyclist_name").Where(w).Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: Delete("cycling.cyclist_name").Where(w).Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "DELETE FROM cycling.cyclist_name USING TIMESTAMP 1115251200000000 WHERE id=? ",
N: []string{"expr"},
},

View File

@@ -17,16 +17,16 @@ import (
// initializer specifies an value for a column in an insert operation.
type initializer struct {
column string
value value
column string
}
// InsertBuilder builds CQL INSERT statements.
type InsertBuilder struct {
table string
columns []initializer
unique bool
using using
unique bool
json bool
}

View File

@@ -17,7 +17,6 @@ func TestInsertBuilder(t *testing.T) {
N []string
S string
}{
// Basic test for insert
{
B: Insert("cycling.cyclist_name").Columns("id", "user_uuid", "firstname"),
@@ -67,7 +66,7 @@ func TestInsertBuilder(t *testing.T) {
},
// Add TIMESTAMP
{
B: Insert("cycling.cyclist_name").Columns("id", "user_uuid", "firstname").Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: Insert("cycling.cyclist_name").Columns("id", "user_uuid", "firstname").Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "INSERT INTO cycling.cyclist_name (id,user_uuid,firstname) VALUES (?,?,?) USING TIMESTAMP 1115251200000000 ",
N: []string{"id", "user_uuid", "firstname"},
},
@@ -78,7 +77,7 @@ func TestInsertBuilder(t *testing.T) {
},
// Add TIMESTAMP
{
B: Insert("cycling.cyclist_name").Columns("id", "user_uuid", "firstname").Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: Insert("cycling.cyclist_name").Columns("id", "user_uuid", "firstname").Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "INSERT INTO cycling.cyclist_name (id,user_uuid,firstname) VALUES (?,?,?) USING TIMESTAMP 1115251200000000 ",
N: []string{"id", "user_uuid", "firstname"},
},
@@ -89,7 +88,7 @@ func TestInsertBuilder(t *testing.T) {
},
// Add TIMESTAMP
{
B: Insert("cycling.cyclist_name").Columns("id", "user_uuid", "firstname").Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: Insert("cycling.cyclist_name").Columns("id", "user_uuid", "firstname").Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "INSERT INTO cycling.cyclist_name (id,user_uuid,firstname) VALUES (?,?,?) USING TIMESTAMP 1115251200000000 ",
N: []string{"id", "user_uuid", "firstname"},
},

View File

@@ -34,15 +34,15 @@ func (o Order) String() string {
// SelectBuilder builds CQL SELECT statements.
type SelectBuilder struct {
limit limit
limitPerPartition limit
table string
columns columns
distinct columns
using using
where where
groupBy columns
orderBy columns
limit limit
limitPerPartition limit
columns columns
distinct columns
using using
allowFiltering bool
bypassCache bool
json bool
@@ -132,7 +132,7 @@ func (b *SelectBuilder) From(table string) *SelectBuilder {
}
// Json sets the clause of the query.
func (b *SelectBuilder) Json() *SelectBuilder {
func (b *SelectBuilder) Json() *SelectBuilder { // nolint: revive
b.json = true
return b
}

View File

@@ -32,10 +32,10 @@ func (a assignment) writeCql(cql *bytes.Buffer) (names []string) {
// UpdateBuilder builds CQL UPDATE statements.
type UpdateBuilder struct {
table string
using using
assignments []assignment
where where
_if _if
using using
exists bool
}

View File

@@ -117,7 +117,7 @@ func TestUpdateBuilder(t *testing.T) {
},
// Add TIMESTAMP
{
B: Update("cycling.cyclist_name").Set("id", "user_uuid", "firstname").Where(w).Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: Update("cycling.cyclist_name").Set("id", "user_uuid", "firstname").Where(w).Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "UPDATE cycling.cyclist_name USING TIMESTAMP 1115251200000000 SET id=?,user_uuid=?,firstname=? WHERE id=? ",
N: []string{"id", "user_uuid", "firstname", "expr"},
},

View File

@@ -21,12 +21,12 @@ func Timestamp(t time.Time) int64 {
}
type using struct {
ttl int64
ttlName string
timestamp int64
timestampName string
timeout time.Duration
timeoutName string
ttl int64
timestamp int64
timeout time.Duration
}
func (u *using) TTL(d time.Duration) *using {

View File

@@ -43,7 +43,7 @@ func TestUsing(t *testing.T) {
},
// Timestamp
{
B: new(using).Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: new(using).Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "USING TIMESTAMP 1115251200000000 ",
},
// TimestampNamed
@@ -65,7 +65,7 @@ func TestUsing(t *testing.T) {
},
// TTL Timestamp
{
B: new(using).TTL(time.Second).Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: new(using).TTL(time.Second).Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "USING TTL 1 AND TIMESTAMP 1115251200000000 ",
},
// TTL TimestampNamed
@@ -82,7 +82,7 @@ func TestUsing(t *testing.T) {
},
// TTLNamed Timestamp
{
B: new(using).TTLNamed("ttl").Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: new(using).TTLNamed("ttl").Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "USING TTL ? AND TIMESTAMP 1115251200000000 ",
N: []string{"ttl"},
},
@@ -99,7 +99,7 @@ func TestUsing(t *testing.T) {
},
// TTL Timestamp Timeout
{
B: new(using).TTL(time.Second).Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)).Timeout(time.Second),
B: new(using).TTL(time.Second).Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)).Timeout(time.Second),
S: "USING TTL 1 AND TIMESTAMP 1115251200000000 AND TIMEOUT 1s ",
},
// TTL with no duration
@@ -129,13 +129,13 @@ func TestUsing(t *testing.T) {
},
// Timestamp TimestampNamed
{
B: new(using).Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)).TimestampNamed("ts"),
B: new(using).Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)).TimestampNamed("ts"),
S: "USING TIMESTAMP ? ",
N: []string{"ts"},
},
// TimestampNamed Timestamp
{
B: new(using).TimestampNamed("ts").Timestamp(time.Date(2005, 05, 05, 0, 0, 0, 0, time.UTC)),
B: new(using).TimestampNamed("ts").Timestamp(time.Date(2005, 5, 5, 0, 0, 0, 0, time.UTC)),
S: "USING TIMESTAMP 1115251200000000 ",
},
}