mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Fix linter warnings
This commit is contained in:
parent
25ffffecf9
commit
c5bca9c8a2
7 changed files with 13 additions and 6 deletions
|
@ -57,6 +57,7 @@ type (
|
|||
writeConn *sqlite.Conn
|
||||
}
|
||||
|
||||
// BatchExecute executes multiple queries in one transaction.
|
||||
BatchExecute struct {
|
||||
ID string
|
||||
SQL string
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue