Skip to content

Commit 0fe6f58

Browse files
authored
chore: fix CI ang go1.22 support (#479)
* chore: update golangci-lint * chore: apply go-critic reports * attempt to fix alias
1 parent 5a36c24 commit 0fe6f58

File tree

8 files changed

+26
-32
lines changed

8 files changed

+26
-32
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{ name: "Check out code into the Go module directory", uses: "actions/checkout@v4" },
1212
{
1313
name: "Set up Go ${{ matrix.go-version }}",
14-
uses: "actions/setup-go@v4",
14+
uses: "actions/setup-go@v5",
1515
with: { "go-version": "${{ matrix.go-version }}" },
1616
id: "go",
1717
},

.golangci.yml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"run": {
33
# timeout for analysis, e.g. 30s, 5m, default is 1m
4-
"deadline": "3m",
4+
"timeout": "3m",
55
},
6-
"fast": false,
76
"linters": {
87
"enable": [
98
"errcheck",
@@ -22,29 +21,22 @@
2221
"unparam",
2322
"unused",
2423
],
24+
"disable": [
25+
"depguard",
26+
"dupl",
27+
"gocyclo",
28+
"lll",
29+
"prealloc",
30+
],
2531
},
26-
"disable": [
27-
"deadcode", # deprecated
28-
"depguard",
29-
"dupl",
30-
"exhaustivestruct", # deprecated
31-
"gocyclo",
32-
"golint", # deprecated
33-
"ifshort", # deprecated
34-
"interfacer", # deprecated
35-
"lll",
36-
"maligned", # deprecated
37-
"nosnakecase", # deprecated
38-
"prealloc",
39-
"scopelint", # deprecated
40-
"structcheck", # deprecated
41-
"varcheck", # deprecated
42-
],
4332
"linters-settings": {
4433
"gocritic": {
4534
"enabled-checks": [
4635
"commentedOutCode",
4736
],
4837
},
38+
"gosec": {
39+
"excludes": ["G115"]
40+
}
4941
},
5042
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test-release:
3232
@echo "everything is OK"
3333

3434
lint:
35-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH_DIR)/bin v1.54.0
35+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH_DIR)/bin v1.60.2
3636
$(GOPATH_DIR)/bin/golangci-lint run ./...
3737
go build -o go-ruleguard ./cmd/ruleguard
3838
./go-ruleguard -debug-imports -rules rules.go ./...

internal/xtypes/xtypes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func typeIdentical(x, y types.Type, p *ifacePair) bool {
223223

224224
case *types.Alias:
225225
// an alias type is identical if the type it's an alias of is identical to it.
226-
return typeIdentical(x.Rhs(), y, p)
226+
return typeIdentical(types.Unalias(x), y, p)
227227

228228
case nil:
229229
// avoid a crash in case of nil type

ruleguard/irconv/irconv.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,7 @@ func (conv *converter) convertFilterExprImpl(e ast.Expr) ir.FilterExpr {
618618
case *ast.UnaryExpr:
619619
x := conv.convertFilterExpr(e.X)
620620
args := []ir.FilterExpr{x}
621-
switch e.Op {
622-
case token.NOT:
621+
if e.Op == token.NOT {
623622
return ir.FilterExpr{Op: ir.FilterNotOp, Args: args}
624623
}
625624

ruleguard/irprint/irprint.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ func (p *printer) printReflectElemNoNewline(key string, v reflect.Value, insideL
9595
}
9696
}
9797

98-
if v.Type().Kind() == reflect.Struct {
98+
switch v.Type().Kind() {
99+
case reflect.Struct:
99100
if !insideList {
100101
p.buf.WriteString(v.Type().String())
101102
}
@@ -104,7 +105,8 @@ func (p *printer) printReflectElemNoNewline(key string, v reflect.Value, insideL
104105
p.printReflectElem(v.Type().Field(i).Name, v.Field(i), false)
105106
}
106107
p.writef("},")
107-
} else if v.Type().Kind() == reflect.Slice {
108+
109+
case reflect.Slice:
108110
if isCompactSlice(v) {
109111
p.writef("%s{", v.Type())
110112
for j := 0; j < v.Len(); j++ {
@@ -119,7 +121,7 @@ func (p *printer) printReflectElemNoNewline(key string, v reflect.Value, insideL
119121
p.writef("},")
120122
}
121123

122-
} else {
124+
default:
123125
switch val := v.Interface().(type) {
124126
case int64:
125127
p.writef("int64(%v),", val)

ruleguard/quasigo/compile.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,12 @@ func (cl *compiler) compileCall(key funcKey, sig *types.Signature, args []ast.Ex
605605
}
606606

607607
var op opcode
608-
if sig.Results().Len() == 0 {
608+
switch {
609+
case sig.Results().Len() == 0:
609610
op = opVoidCall
610-
} else if typeIsInt(sig.Results().At(0).Type()) {
611+
case typeIsInt(sig.Results().At(0).Type()):
611612
op = opIntCall
612-
} else {
613+
default:
613614
op = opCall
614615
}
615616

ruleguard/ruleguard_error_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ func TestParseFilterFuncError(t *testing.T) {
150150
}
151151

152152
for _, test := range tests {
153-
file := fmt.Sprintf(`
153+
file := `
154154
package gorules
155155
import "github.com/quasilyte/go-ruleguard/dsl"
156156
type Foo struct { X int }
157157
func (foo *Foo) String() string { return "" }
158158
func g(ctx *dsl.VarFilterContext) bool { return false }
159-
` + test.src)
159+
` + test.src
160160
e := NewEngine()
161161
ctx := &LoadContext{
162162
Fset: token.NewFileSet(),

0 commit comments

Comments
 (0)