Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Mar 14, 2024
1 parent cb74b27 commit 456ee52
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ build: .PHONY # compiles
test: .PHONY # tests the codebase
go test ./...

.PHONY: fix
fix: ## fix issues found by linters
golangci-lint run --fix ./...

release-vsn: # tags and pushes a new release
@read -p "Version: " tag; \
git checkout main; \
Expand Down
4 changes: 2 additions & 2 deletions algorithms/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestDFS(t *testing.T) {
return nil
}

DFS(1, neighbors, visit)
_ = DFS(1, neighbors, visit)
assert.Equal(t, res, []int{1, 2, 4, 3})
}

Expand All @@ -42,7 +42,7 @@ func TestBFS(t *testing.T) {
return nil
}

BFS(1, neighbors, visit)
_ = BFS(1, neighbors, visit)
assert.Equal(t, res, []int{1, 2, 3, 4})
}

Expand Down
12 changes: 6 additions & 6 deletions containers/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s Set[V]) Equal(other Set[V]) bool {
return false
}

for k, _ := range s {
for k := range s {
if !other.Has(k) {
return false
}
Expand All @@ -77,7 +77,7 @@ func (s Set[V]) Equal(other Set[V]) bool {
// s2.Difference(s1) = {a4, a5}
func (s Set[V]) Difference(other Set[V]) Set[V] {
new := NewSet[V]()
for v, _ := range s {
for v := range s {
if !other.Has(v) {
new.Add(v)
}
Expand All @@ -93,7 +93,7 @@ func (s Set[V]) Difference(other Set[V]) Set[V] {
// s2.Union(s1) = {a1, a2, a3, a4}
func (s Set[V]) Union(other Set[V]) Set[V] {
new := ToSet(s.List())
for v, _ := range other {
for v := range other {
new.Add(v)
}
return new
Expand All @@ -104,7 +104,7 @@ func Union[V comparable](sets ...Set[V]) Set[V] {

// use nested loops for a bit of extra efficiency
for _, s := range sets {
for v, _ := range s {
for v := range s {
res.Add(v)
}
}
Expand All @@ -119,7 +119,7 @@ func Union[V comparable](sets ...Set[V]) Set[V] {
// s1.Intersect(s2) = {a2}
func (s Set[V]) Intersect(other Set[V]) Set[V] {
res := NewSet[V]()
for v, _ := range s {
for v := range s {
if other.Has(v) {
res.Add(v)
}
Expand All @@ -134,7 +134,7 @@ func Intersect[V comparable](sets ...Set[V]) Set[V] {
return res
}
first, rest := sets[0], sets[1:]
for v, _ := range first {
for v := range first {
if lo.EveryBy(rest, func(s Set[V]) bool { return s.Has(v) }) {
res.Add(v)
}
Expand Down
4 changes: 2 additions & 2 deletions containers/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestStackToList(t *testing.T) {
s.Push(2)

assert.Equal(t, s.List(), []int{2, 3, 1})
s.Pop()
_, _ = s.Pop()
assert.Equal(t, s.List(), []int{3, 1})
s.Pop()
_, _ = s.Pop()
assert.Equal(t, s.List(), []int{1})
}
6 changes: 1 addition & 5 deletions retry/algorithms.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ func (exp *Exponential) Backoff(iter int) time.Duration {
}

func (exp *Exponential) Continue() bool {
if exp.max <= exp.start {
return false
}

return true
return exp.max > exp.start
}

type Constant struct {
Expand Down

0 comments on commit 456ee52

Please sign in to comment.