Fix linter warnings

This commit is contained in:
Daniel 2023-09-14 15:58:32 +02:00
parent 25ffffecf9
commit c5bca9c8a2
7 changed files with 13 additions and 6 deletions

View file

@ -57,6 +57,7 @@ type (
writeConn *sqlite.Conn
}
// BatchExecute executes multiple queries in one transaction.
BatchExecute struct {
ID string
SQL string

View file

@ -461,6 +461,7 @@ func getKind(val reflect.Value) reflect.Kind {
return NormalizeKind(kind)
}
// NormalizeKind returns a normalized kind of the given kind.
func NormalizeKind(kind reflect.Kind) reflect.Kind {
switch {
case kind >= reflect.Int && kind <= reflect.Int64:

View file

@ -183,7 +183,7 @@ func DatetimeEncoder(loc *time.Location) EncodeFunc {
case (normalizedKind == reflect.Int || normalizedKind == reflect.Uint || normalizedKind == reflect.Float64) && colDef.IsTime:
seconds := int64(0)
switch normalizedKind {
switch normalizedKind { //nolint:exhaustive // Previous switch case assures these types.
case reflect.Int:
seconds = val.Int()
case reflect.Uint:

View file

@ -311,7 +311,7 @@ func (match Matcher) toSQLConditionClause(ctx context.Context, suffix string, co
for idx, value := range values {
var (
encodedValue any = value
encodedValue any
err error
)
@ -344,7 +344,7 @@ func (match Matcher) toSQLConditionClause(ctx context.Context, suffix string, co
// NOTE(ppacher): for now we assume that the type of each element of values
// is the same. We also can be sure that there is always at least one value.
//
// FIXME(ppacher): if we start supporting values of different types here
// TODO(ppacher): if we start supporting values of different types here
// we need to revisit the whole behavior as we might need to do more boolean
// expression nesting to support that.
kind := orm.NormalizeKind(reflect.TypeOf(values[0]).Kind())

View file

@ -12,6 +12,7 @@ import (
"github.com/hashicorp/go-multierror"
servertiming "github.com/mitchellh/go-server-timing"
"github.com/safing/portbase/log"
"github.com/safing/portmaster/netquery/orm"
)
@ -27,6 +28,8 @@ type (
Database *Database
}
// BatchQueryHandler implements http.Handler and allows to perform SQL
// query and aggregate functions on Database in batches.
BatchQueryHandler struct {
IsDevMode func() bool
Database *Database
@ -116,8 +119,8 @@ func (qh *QueryHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
return
}
}
func (batch *BatchQueryHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
timing := servertiming.FromContext(req.Context())

View file

@ -5,11 +5,13 @@ import (
"fmt"
"strings"
"github.com/safing/portmaster/netquery/orm"
"golang.org/x/exp/slices"
"github.com/safing/portmaster/netquery/orm"
)
type (
// QueryRequestPayload describes the payload of a netquery query.
QueryRequestPayload struct {
Select Selects `json:"select"`
Query Query `json:"query"`

View file

@ -119,7 +119,7 @@ func TestPublicSuffix(t *testing.T) {
testSuffix(t, "golang.dev.", "golang.dev.", true)
testSuffix(t, "golang.net.", "golang.net.", true)
testSuffix(t, "play.golang.org.", "golang.org.", true)
testSuffix(t, "gophers.in.space.museum.", "in.space.museum.", true)
testSuffix(t, "gophers.in.space.museum.", "space.museum.", true)
testSuffix(t, "0emm.com.", "0emm.com.", true)
testSuffix(t, "a.0emm.com.", "", true)
testSuffix(t, "b.c.d.0emm.com.", "c.d.0emm.com.", true)