Skip to content

Commit

Permalink
all: imp lint, names, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Mar 21, 2024
1 parent 284f8c7 commit 87bad8c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
9 changes: 8 additions & 1 deletion bamboo-specs/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@
set -e -f -u -x
make VERBOSE=1 go-deps go-tools go-lint go-test
make\
GOMAXPROCS=1\
VERBOSE=1\
go-deps go-tools go-lint
make\
VERBOSE=1\
go-test
'final-tasks':
- 'clean'
'requirements':
Expand Down
2 changes: 1 addition & 1 deletion internal/filtering/idgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (g *idGenerator) fix(flts []FilterYAML) {
}

log.Info(
"filtering: warning: filter at index %d has duplicated id %d; reassigning to %d",
"filtering: warning: filter at index %d has duplicate id %d; reassigning to %d",
i,
id,
newID,
Expand Down
13 changes: 6 additions & 7 deletions internal/filtering/idgenerator_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package filtering
import (
"testing"

"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
"github.com/AdguardTeam/AdGuardHome/internal/filtering/rulelist"
"github.com/stretchr/testify/assert"
)

func TestIDGenerator_Fix(t *testing.T) {
Expand Down Expand Up @@ -77,13 +79,10 @@ func TestIDGenerator_Fix(t *testing.T) {
func assertUniqueIDs(t testing.TB, flts []FilterYAML) {
t.Helper()

set := map[rulelist.URLFilterID]struct{}{}
uc := aghalg.UniqChecker[rulelist.URLFilterID]{}
for _, f := range flts {
id := f.ID
if _, ok := set[id]; ok {
t.Errorf("duplicated id %d", id)
}

set[id] = struct{}{}
uc.Add(f.ID)
}

assert.NoError(t, uc.Validate())
}
4 changes: 2 additions & 2 deletions internal/querylog/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ var resultHandlers = map[string]logEntryHandler{
return nil
}

id64, err := n.Int64()
id, err := n.Int64()
if err != nil {
return err
}
Expand All @@ -595,7 +595,7 @@ var resultHandlers = map[string]logEntryHandler{
l++
}

ent.Result.Rules[l-1].FilterListID = rulelist.URLFilterID(id64)
ent.Result.Rules[l-1].FilterListID = rulelist.URLFilterID(id)

return nil
},
Expand Down

0 comments on commit 87bad8c

Please sign in to comment.