-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linting #359
Linting #359
Conversation
The linter checks if package imports are in a list of acceptable packages. The linter requires config file `.depguard.yml`. We don't need this at this moment.
The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner. The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner. Replaced by exportloopref. The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive. The linter 'ifshort' is deprecated (since v1.48.0) due to: The repository of the linter has been deprecated by the owner.
7ad2fcd
to
f615a6f
Compare
The quality of the linter is questionable. There are many false positives. For example: timakin/bodyclose#52
34a1488
to
2a6cb6d
Compare
The are many unchecked errors in the martian code. Most of are not dangerous e.g. come from messageview (printing http logs). Checking all these errors will increase the code complexity and decrease code readability.
Some of the issues need some discussion before the fix: internal/martian/proxy.go: G402: TLS MinVersion too low. (gosec) return &tls.Config{} internal/martian/mitm/mitm.go: G505: Blocklisted import crypto/sha1: weak cryptographic primitive (gosec) "crypto/sha1" internal/martian/mitm/mitm.go: G401: Use of weak cryptographic primitive (gosec) h := sha1.New()
Context key should have custom type to avoid collisions.
- increase number of func statements to 75 - increase allowed lines to 140
Function `func (a *adapter) Data(data []byte, streamEnded bool) error` from `martian/h2/grpc` has 49 complexity.
The linter wrongly interprets comments as code e.g. // GET http://example.com/ HTTP/1.1 // Host: example.com
Function `func (p *Proxy) handleConnectRequest` has nested if with complexity level 10 - `if p.mitm != nil {...}`.
- godot - misspell - dupword
After the golangci-lint version was bumped, the linter stopped working at the ci [1]. [1] golangci/golangci-lint-action#23
@mmatczuk I updated the linter and resolved its issues. I tried to split the work into specific commits in case we want to roll something back. If you feel the need to squash them somehow, let me know. Some of the linters were disabled as they need some discussion before fix, I believe. |
LGTM |
Fixes #340
Fixes #353