Skip to content

Commit f215efb

Browse files
committed
wip
1 parent b5f7f6a commit f215efb

File tree

9 files changed

+32
-25
lines changed

9 files changed

+32
-25
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ issues:
3030
- dupl
3131
- lll
3232
- funlen
33+
- maintidx
34+
- path: '(.+)_example_test\.go'
35+
linters:
36+
- gochecknoglobals

and.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func And(es ...Endless) (CeilingFloorConstrainter, error) {
3030
return es[0], nil
3131
}
3232

33-
floor, floorOk := maxBoundedFloor(es)
34-
ceiling, ceilingOk := minBoundedCeiling(es)
33+
floor, floorOk := maxBoundedFloor(es...)
34+
ceiling, ceilingOk := minBoundedCeiling(es...)
3535

3636
if !floorOk && !ceilingOk {
3737
var c CeilingFloorConstrainter

ceilinger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ type ceilinger interface {
66
ceiling() Endless
77
}
88

9-
func minBoundedCeiling[S ~[]T, T ceilinger](cs S) (T, bool) {
10-
cs = slices.Clone(cs)
9+
func minBoundedCeiling(es ...Endless) (Endless, bool) {
10+
es = slices.Clone(es)
1111

12-
bcs := slices.DeleteFunc(cs, func(b T) bool {
12+
bcs := slices.DeleteFunc(es, func(b Endless) bool {
1313
return b.ceiling().version == nil
1414
})
1515

1616
if len(bcs) == 0 {
17-
var c T
17+
var c Endless
1818
return c, false
1919
}
2020

21-
return slices.MinFunc(bcs, func(a, b T) int {
21+
return slices.MinFunc(bcs, func(a, b Endless) int {
2222
return a.ceiling().compare(b.ceiling())
2323
}), true
2424
}

ceilinger_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
func Test_minBoundedCeiling(t *testing.T) {
1111
t.Parallel()
1212

13-
type testCase[T ceilinger] struct {
13+
type testCase struct {
1414
name string
15-
cs []T
16-
want ceilinger
15+
cs []Endless
16+
want Endless
1717
wantOk bool
1818
}
19-
tests := []testCase[Endless]{
19+
tests := []testCase{
2020
{
2121
name: "empty",
2222
cs: []Endless{},
@@ -163,7 +163,7 @@ func Test_minBoundedCeiling(t *testing.T) {
163163

164164
original := slices.Clone(tt.cs)
165165

166-
got, gotOk := minBoundedCeiling(tt.cs)
166+
got, gotOk := minBoundedCeiling(tt.cs...)
167167

168168
if gotOk != tt.wantOk {
169169
t.Fatalf("minBoundedCeiling() gotOk = %v, want %v", gotOk, tt.wantOk)

endless.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ func NewGreaterThanOrEqualTo(v Version) Endless {
4040
}
4141

4242
func NewWildcard() Endless {
43-
return Endless{}
43+
return Endless{ //nolint:exhaustruct
44+
version: nil,
45+
}
4446
}
4547

4648
// Check reports whether a [Version] satisfies the constraint.

floorer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ type floorer interface {
66
floor() Endless
77
}
88

9-
func maxBoundedFloor[S ~[]T, T floorer](fs S) (T, bool) {
10-
fs = slices.Clone(fs)
9+
func maxBoundedFloor(es ...Endless) (Endless, bool) {
10+
es = slices.Clone(es)
1111

12-
bfs := slices.DeleteFunc(fs, func(c T) bool {
12+
bfs := slices.DeleteFunc(es, func(c Endless) bool {
1313
return c.floor().wildcard()
1414
})
1515

1616
if len(bfs) == 0 {
17-
var f T
17+
var f Endless
1818
return f, false
1919
}
2020

21-
return slices.MaxFunc(bfs, func(a, b T) int {
21+
return slices.MaxFunc(bfs, func(a, b Endless) int {
2222
return a.floor().compare(b.floor())
2323
}), true
2424
}

floorer_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
func Test_maxBoundedFloor(t *testing.T) {
1111
t.Parallel()
1212

13-
type testCase[T floorer] struct {
13+
type testCase struct {
1414
name string
15-
fs []T
16-
want floorer
15+
fs []Endless
16+
want Endless
1717
wantOk bool
1818
}
19-
tests := []testCase[Endless]{
19+
tests := []testCase{
2020
{
2121
name: "empty",
2222
fs: []Endless{},
@@ -163,7 +163,7 @@ func Test_maxBoundedFloor(t *testing.T) {
163163

164164
original := slices.Clone(tt.fs)
165165

166-
got, gotOk := maxBoundedFloor(tt.fs)
166+
got, gotOk := maxBoundedFloor(tt.fs...)
167167

168168
if gotOk != tt.wantOk {
169169
t.Fatalf("maxBoundedFloor() gotOk = %v, want %v", gotOk, tt.wantOk)

or.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func Compact(o Or) Constrainter { // TODO: Test me.
7777
return compare(a, b) == 0
7878
})
7979

80-
r := make(Or, 0, len(o)+2)
80+
r := make(Or, 0, len(o)+2) //nolint:mnd
8181
if len(o) != 0 {
8282
p := o[0]
8383
for i := range o {

or_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package comver
22

33
import (
4-
"github.com/google/go-cmp/cmp"
54
"math/rand/v2"
65
"reflect"
76
"slices"
87
"testing"
8+
9+
"github.com/google/go-cmp/cmp"
910
)
1011

1112
func TestCompact(t *testing.T) {

0 commit comments

Comments
 (0)