Skip to content

Commit

Permalink
Fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Sep 14, 2023
1 parent 25ffffe commit c5bca9c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions netquery/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type (
writeConn *sqlite.Conn
}

// BatchExecute executes multiple queries in one transaction.
BatchExecute struct {
ID string
SQL string
Expand Down
1 change: 1 addition & 0 deletions netquery/orm/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion netquery/orm/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions netquery/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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())
Expand Down
5 changes: 4 additions & 1 deletion netquery/query_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down Expand Up @@ -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())

Expand Down
4 changes: 3 additions & 1 deletion netquery/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c5bca9c

Please sign in to comment.