Skip to content

Commit b613a5a

Browse files
authored
Make golangci-lint happy (#73)
1 parent 2dcd404 commit b613a5a

File tree

9 files changed

+25
-11
lines changed

9 files changed

+25
-11
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ formatters:
2323
- gofmt
2424
- gofumpt
2525
- goimports
26-
- golines
26+
- swaggo

and.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func And(es ...Endless) (CeilingFloorConstrainter, error) { //nolint:cyclop,iret
2424
if len(es) == 0 {
2525
return NewMatchAll(), nil
2626
}
27+
2728
if len(es) == 1 {
2829
return es[0], nil
2930
}
@@ -35,9 +36,11 @@ func And(es ...Endless) (CeilingFloorConstrainter, error) { //nolint:cyclop,iret
3536
// logic error! This should never happen
3637
return nilC, errUnexpectedAndLogic
3738
}
39+
3840
if ceilingOk && !floorOk {
3941
return ceiling, nil
4042
}
43+
4144
if !ceilingOk { // floorOk is always true here
4245
return floor, nil
4346
}

and_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ func Test_minBoundedCeiling(t *testing.T) {
446446
want Endless
447447
wantOk bool
448448
}
449+
449450
tests := []testCase{
450451
{
451452
name: "empty",
@@ -627,6 +628,7 @@ func Test_maxBoundedFloor(t *testing.T) {
627628
want Endless
628629
wantOk bool
629630
}
631+
630632
tests := []testCase{
631633
{
632634
name: "empty",

compact.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ func Compact(o Or) Constrainter { //nolint:cyclop,ireturn
1111
if len(o) == 0 {
1212
return Or{}
1313
}
14+
1415
if len(o) == 1 {
1516
return o[0]
1617
}
18+
1719
if slices.ContainsFunc(o, matchAll) {
1820
return NewMatchAll()
1921
}
@@ -45,6 +47,7 @@ func Compact(o Or) Constrainter { //nolint:cyclop,ireturn
4547
if floorOk {
4648
r = append(r, floor)
4749
}
50+
4851
if ceilingOk {
4952
r = append(r, ceiling)
5053
}

doc_example_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func Example_version() {
3737

3838
continue
3939
}
40+
4041
fmt.Printf("%-21q => %v\n", s, v)
4142
}
4243

op.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const (
55
greaterThan
66
lessThan
77
lessThanOrEqualTo
8-
9-
errUnexpectedOp stringError = "unexpected op"
108
)
119

10+
const errUnexpectedOp stringError = "unexpected op"
11+
1212
type op int8
1313

1414
func (o op) String() string {

or.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func (o Or) String() string {
2727
if i > 0 {
2828
s += " || "
2929
}
30+
3031
s += o[i].String()
3132
}
3233

version.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,37 +100,37 @@ func Parse(v string) (Version, error) { //nolint:cyclop,funlen
100100
} else if dm := dateOnlyVersioningRegexp.FindStringSubmatch(v); dm != nil {
101101
match = dm
102102
}
103+
103104
if match == nil || len(match) != 7 {
104105
return Version{}, &ParseError{original, errInvalidVersionString}
105106
}
106107

107108
var err error
108-
109-
if cv.major, err = strconv.ParseUint(match[1], 10, 64); err != nil {
109+
if cv.major, err = strconv.ParseUint(match[1], 10, 64); err != nil { //nolint:noinlineerr
110110
return Version{}, &ParseError{original, err}
111111
}
112112
// CalVer (as MAJOR) must be in YYYYMMDDhhmm or YYYYMMDD formats
113-
if s := strconv.FormatUint(cv.major, 10); len(s) > 12 || len(s) == 11 || len(s) == 9 ||
114-
len(s) == 7 {
113+
if s := strconv.FormatUint(cv.major, 10); len(s) > 12 || len(s) == 11 || len(s) == 9 || len(s) == 7 {
115114
return Version{}, &ParseError{original, errInvalidVersionString}
116115
}
117116

118-
if cv.minor, err = strconv.ParseUint(match[2], 10, 64); match[2] != "" && err != nil {
117+
if cv.minor, err = strconv.ParseUint(match[2], 10, 64); match[2] != "" && err != nil { //nolint:noinlineerr
119118
return Version{}, &ParseError{original, err}
120119
}
121120

122-
if cv.patch, err = strconv.ParseUint(match[3], 10, 64); match[3] != "" && err != nil {
121+
if cv.patch, err = strconv.ParseUint(match[3], 10, 64); match[3] != "" && err != nil { //nolint:noinlineerr
123122
return Version{}, &ParseError{original, err}
124123
}
125124

126125
if cv.major >= 1000_00 && match[4] != "" {
127126
return Version{}, &ParseError{original, errDateVersionWithFourBits}
128127
}
129-
if cv.tweak, err = strconv.ParseUint(match[4], 10, 64); match[4] != "" && err != nil {
128+
129+
if cv.tweak, err = strconv.ParseUint(match[4], 10, 64); match[4] != "" && err != nil { //nolint:noinlineerr
130130
return Version{}, &ParseError{original, err}
131131
}
132132

133-
if cv.modifier, err = newModifier(match[5]); err != nil {
133+
if cv.modifier, err = newModifier(match[5]); err != nil { //nolint:noinlineerr
134134
return Version{}, &ParseError{original, err}
135135
}
136136

version_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ func TestParse(t *testing.T) {
9696
if err != nil {
9797
t.Fatalf("Parse() error = %v, wantErr %v", err, nil)
9898
}
99+
99100
if gotString := got.String(); gotString != tt.want {
100101
t.Errorf("Parse().String() got = %q, want %v", gotString, tt.want)
101102
}
103+
102104
if gotOriginal := got.Original(); gotOriginal != tt.v {
103105
t.Errorf("Parse().Original() got = %q, want %v", gotOriginal, tt.v)
104106
}
@@ -118,6 +120,7 @@ func TestMustParse(t *testing.T) {
118120
if gotString := got.String(); gotString != tt.want {
119121
t.Errorf("MustParse().String() got = %q, want %v", gotString, tt.want)
120122
}
123+
121124
if gotOriginal := got.Original(); gotOriginal != tt.v {
122125
t.Errorf("MustParse().Original() got = %q, want %v", gotOriginal, tt.v)
123126
}
@@ -353,6 +356,7 @@ func TestVersion_Compare(t *testing.T) {
353356
if err != nil {
354357
t.Fatalf("Parse(%q) error = %v, wantErr %v", tt.v, err, nil)
355358
}
359+
356360
w, err := Parse(tt.w)
357361
if err != nil {
358362
t.Fatalf("Parse(%q) error = %v, wantErr %v", tt.w, err, nil)

0 commit comments

Comments
 (0)