Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all linter issues #16

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ jobs:
- name: Run linters
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
version: v1.45.0
only-new-issues: true
args: --enable-all

coverage:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions address_v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ func TestNewIPv4Address(t *testing.T) {
assert.Equal(t, uint(7), sut.Length)
assert.Equal(t, "1.35.69.103/7", sut.String())
assert.Equal(t, "1.35.69.103/7", (&sut).String())
//nolint
assert.Equal(t, "1.35.69.103/7", fmt.Sprintf("%s", sut))
//nolint
assert.Equal(t, "1.35.69.103/7", fmt.Sprintf("%s", &sut))
}

Expand Down
2 changes: 2 additions & 0 deletions address_v6_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ func TestNewIPv6Address(t *testing.T) {
assert.Equal(t, uint64(0x0123456789A0A1A2), sut.Left)
assert.Equal(t, uint64(0xA3A4A5A6A7A8A9B0), sut.Right)
assert.Equal(t, uint(117), sut.Length)
//nolint
assert.Equal(t, "123:4567:89a0:a1a2:a3a4:a5a6:a7a8:a9b0/117", fmt.Sprintf("%s", sut))
//nolint
assert.Equal(t, "123:4567:89a0:a1a2:a3a4:a5a6:a7a8:a9b0/117", fmt.Sprintf("%s", &sut))
assert.Equal(t, "123:4567:89a0:a1a2:a3a4:a5a6:a7a8:a9b0/117", (&sut).String())
assert.Equal(t, "123:4567:89a0:a1a2:a3a4:a5a6:a7a8:a9b0/117", sut.String())
Expand Down
19 changes: 0 additions & 19 deletions bits.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
package patricia

var _len8tab = [256]uint8{
0x00, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
}

var _leftMasks32 []uint32
var _leftMasks64 []uint64

Expand Down
4 changes: 3 additions & 1 deletion bool_tree/tree_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV4 struct {
// NewTreeV4 returns a new Tree
func NewTreeV4() *TreeV4 {
return &TreeV4{
nodes: make([]treeNodeV4, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV4, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]bool),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV4) FindDeepestTagsAppend(ret []bool, address patricia.IPv4Address)
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV4) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions bool_tree/tree_v4_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV4) newNode(address patricia.IPv4Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV4) print() {
buf := make([]bool, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion bool_tree/tree_v6_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV6 struct {
// NewTreeV6 returns a new Tree
func NewTreeV6() *TreeV6 {
return &TreeV6{
nodes: make([]treeNodeV6, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV6, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]bool),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV6) FindDeepestTagsAppend(ret []bool, address patricia.IPv6Address)
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV6) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions bool_tree/tree_v6_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV6) newNode(address patricia.IPv6Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV6) print() {
buf := make([]bool, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion byte_tree/tree_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV4 struct {
// NewTreeV4 returns a new Tree
func NewTreeV4() *TreeV4 {
return &TreeV4{
nodes: make([]treeNodeV4, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV4, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]byte),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV4) FindDeepestTagsAppend(ret []byte, address patricia.IPv4Address)
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV4) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions byte_tree/tree_v4_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV4) newNode(address patricia.IPv4Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV4) print() {
buf := make([]byte, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion byte_tree/tree_v6_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV6 struct {
// NewTreeV6 returns a new Tree
func NewTreeV6() *TreeV6 {
return &TreeV6{
nodes: make([]treeNodeV6, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV6, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]byte),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV6) FindDeepestTagsAppend(ret []byte, address patricia.IPv6Address)
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV6) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions byte_tree/tree_v6_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV6) newNode(address patricia.IPv6Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV6) print() {
buf := make([]byte, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion complex128_tree/tree_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV4 struct {
// NewTreeV4 returns a new Tree
func NewTreeV4() *TreeV4 {
return &TreeV4{
nodes: make([]treeNodeV4, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV4, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]complex128),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV4) FindDeepestTagsAppend(ret []complex128, address patricia.IPv4Ad
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV4) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions complex128_tree/tree_v4_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV4) newNode(address patricia.IPv4Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV4) print() {
buf := make([]complex128, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion complex128_tree/tree_v6_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV6 struct {
// NewTreeV6 returns a new Tree
func NewTreeV6() *TreeV6 {
return &TreeV6{
nodes: make([]treeNodeV6, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV6, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]complex128),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV6) FindDeepestTagsAppend(ret []complex128, address patricia.IPv6Ad
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV6) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions complex128_tree/tree_v6_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV6) newNode(address patricia.IPv6Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV6) print() {
buf := make([]complex128, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion complex64_tree/tree_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV4 struct {
// NewTreeV4 returns a new Tree
func NewTreeV4() *TreeV4 {
return &TreeV4{
nodes: make([]treeNodeV4, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV4, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]complex64),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV4) FindDeepestTagsAppend(ret []complex64, address patricia.IPv4Add
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV4) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions complex64_tree/tree_v4_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV4) newNode(address patricia.IPv4Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV4) print() {
buf := make([]complex64, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion complex64_tree/tree_v6_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV6 struct {
// NewTreeV6 returns a new Tree
func NewTreeV6() *TreeV6 {
return &TreeV6{
nodes: make([]treeNodeV6, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV6, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]complex64),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV6) FindDeepestTagsAppend(ret []complex64, address patricia.IPv6Add
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV6) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions complex64_tree/tree_v6_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV6) newNode(address patricia.IPv6Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV6) print() {
buf := make([]complex64, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion float32_tree/tree_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV4 struct {
// NewTreeV4 returns a new Tree
func NewTreeV4() *TreeV4 {
return &TreeV4{
nodes: make([]treeNodeV4, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV4, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]float32),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV4) FindDeepestTagsAppend(ret []float32, address patricia.IPv4Addre
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV4) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV4) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions float32_tree/tree_v4_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV4) newNode(address patricia.IPv4Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV4) print() {
buf := make([]float32, 0)
for i := range t.nodes {
Expand Down
4 changes: 3 additions & 1 deletion float32_tree/tree_v6_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TreeV6 struct {
// NewTreeV6 returns a new Tree
func NewTreeV6() *TreeV6 {
return &TreeV6{
nodes: make([]treeNodeV6, 2, 2), // index 0 is skipped, 1 is root
nodes: make([]treeNodeV6, 2), // index 0 is skipped, 1 is root
availableIndexes: make([]uint, 0),
tags: make(map[uint64]float32),
}
Expand Down Expand Up @@ -669,6 +669,7 @@ func (t *TreeV6) FindDeepestTagsAppend(ret []float32, address patricia.IPv6Addre
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countNodes(nodeIndex uint) int {
nodeCount := 1

Expand All @@ -683,6 +684,7 @@ func (t *TreeV6) countNodes(nodeIndex uint) int {
}

// note: this is only used for unit testing
//nolint
func (t *TreeV6) countTags(nodeIndex uint) int {
node := &t.nodes[nodeIndex]

Expand Down
1 change: 1 addition & 0 deletions float32_tree/tree_v6_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (t *TreeV6) newNode(address patricia.IPv6Address, prefixLength uint) uint {
return uint(len(t.nodes) - 1)
}

//nolint
func (t *TreeV6) print() {
buf := make([]float32, 0)
for i := range t.nodes {
Expand Down
Loading