projectcontour / lint Goto Github PK
View Code? Open in Web Editor NEWGo code linters for Project Contour.
License: Apache License 2.0
Go code linters for Project Contour.
License: Apache License 2.0
What steps did you take and what happened:
package a
import (
wrong_alias "fmt"
alias_os "os"
)
panic: runtime error: index out of range [-1]
goroutine 2325 [running]:
github.com/projectcontour/lint/pkg/analysis/importalias.getAliasFix(0xc0058f7a90, 0x0, 0x0, 0xc0058f7a90, 0x0)
/home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:160 +0x1ca
github.com/projectcontour/lint/pkg/analysis/importalias.run.func1(0x73bde0, 0xc0062546f0)
/home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:96 +0x3f3
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc009fba5e8, 0xc0048beb48, 0x1, 0x1, 0xc0048beb38)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/ast/inspector/inspector.go:77 +0xa2
github.com/projectcontour/lint/pkg/analysis/importalias.run(0xc0058d8f70, 0xc0058d8f70, 0x0, 0x0, 0x0)
/home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:41 +0xcd
golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce(0xc0023c7180)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:691 +0x85f
sync.(*Once).doSlow(0xc0023c7180, 0xc000176790)
/home/ldez/.gvm/gos/go1.16/src/sync/once.go:68 +0xec
sync.(*Once).Do(...)
/home/ldez/.gvm/gos/go1.16/src/sync/once.go:59
golang.org/x/tools/go/analysis/internal/checker.(*action).exec(0xc0023c7180)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:579 +0x65
golang.org/x/tools/go/analysis/internal/checker.execAll.func1(0xc0023c7180)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:567 +0x34
created by golang.org/x/tools/go/analysis/internal/checker.execAll
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:573 +0x125
What did you expect to happen:
Don't panic
What steps did you take and what happened:
[A clear and concise description of what the bug is.]
I ran linter on contour project And got this:
internal/featuretests/tlsprotocolversion_test.go:20:2: version "auth" not specified in alias "envoy_api_v2_auth" for import path "github/com/envoyproxy/gocontrolplane/envoy/api/v2/auth"
internal/featuretests/tlsprotocolversion_test.go:21:2: version "listener" not specified in alias "envoy_api_v2_listener" for import path "github/com/envoyproxy/gocontrolplane/envoy/api/v2/listener"
What did you expect to happen:
package is couting listener as version, but it's not it should be v2.
After running with the -fix
option, the linter rewrites the import paths,
diff --git internal/k8s/log.go internal/k8s/log.go
index 8a6974fc..73899219 100644
--- internal/k8s/log.go
+++ internal/k8s/log.go
@@ -24,7 +24,7 @@ import (
"strings"
"github.com/sirupsen/logrus"
- klog "k8s.io/klog/v2"
+ klog_v2 "k8s.io/klog/v2"
)
type klogParams struct {
But all the symbols that are used from that package are still using the old import path. It's left to the maintainer to update each file that gets it import paths fixed.
This is OK for the CI use case since the goal there is to give automated style feedback to contributors (it's not too onerous for them to fix it by hand). It's a bit more onerous to get the existing codebase up to standard, but that's a one time cost.
So we could rewrite all the symbols, but if it's a lot of extra AST work, it might not be worth the effort.
Please describe the problem you have
We can use multicheker
to have -fix
flag.
Please describe the problem you have
Since this package is intended to be used as a golangci lint plugin it would be nice to have some sort of release automation like this:
.so
package file and upload it somewhere.What steps did you take and what happened:
package a
import (
_ "embed"
)
panic: runtime error: index out of range [-1]
goroutine 1838 [running]:
github.com/projectcontour/lint/pkg/analysis/importalias.getAliasFix(0xc0097dc8a0, 0x0, 0x0, 0xc0097dc8a0, 0x0)
/home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:160 +0x1ca
github.com/projectcontour/lint/pkg/analysis/importalias.run.func1(0x73bde0, 0xc0097df950)
/home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:96 +0x3f3
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc0097c0b70, 0xc000216b48, 0x1, 0x1, 0xc000216b38)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/ast/inspector/inspector.go:77 +0xa2
github.com/projectcontour/lint/pkg/analysis/importalias.run(0xc0097ad6c0, 0xc0097ad6c0, 0x0, 0x0, 0x0)
/home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:41 +0xcd
golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce(0xc0097648c0)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:691 +0x85f
sync.(*Once).doSlow(0xc0097648c0, 0xc000176790)
/home/ldez/.gvm/gos/go1.16/src/sync/once.go:68 +0xec
sync.(*Once).Do(...)
/home/ldez/.gvm/gos/go1.16/src/sync/once.go:59
golang.org/x/tools/go/analysis/internal/checker.(*action).exec(0xc0097648c0)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:579 +0x65
golang.org/x/tools/go/analysis/internal/checker.execAll.func1(0xc0097648c0)
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:567 +0x34
created by golang.org/x/tools/go/analysis/internal/checker.execAll
/home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:573 +0x125
What did you expect to happen:
Don't panic
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.