-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use go-version-file in setup-go This way we do not need to keep these files sync'd. * Update go version Latest == greatest! * Use go run to run expected golangci-lint version Easier to just do what we want. * Update to golangci-lint v1.57 * Run through gofumpt and gci These are going to be enabled in the next commit when we switch to the .golangci.yml from metal-toolbox/golangci-lint-config. Better to do it before since it'll make the diff in that commit more meaningful. * Update .golangci.yml from metal-toolbox/golangci-lint-config And fix the errors of course, gotta keep CI green! Most of the class of changes are pretty small. The big one here is from contextcheck which definitely is correct that we should pass context.Context from calling functions down to called functions when the called function is using a context.Context. The question is are we *sure* we want to tie those function calls deep down with the top level context.Context? These all seem like the answer is yes which is why I did them, but will need to make sure reviewers are aware and take a good look. * Update codeql workflow Straight copy/paste from mctl.
- Loading branch information
Showing
46 changed files
with
1,457 additions
and
1,465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,93 @@ | ||
# | ||
# This file lives in the github.com/metal-toolbox/golangci-lint-config repo. | ||
# | ||
# Do not edit this file outside of this repo otherwise we will be grumpy. | ||
# Seriously though, this is meant to help promote a "standard" config and coding style. | ||
# If you don't like something, lets have a discussion in GitHub issues! | ||
# | ||
|
||
linters-settings: | ||
govet: | ||
# TODO: enable and fix struct alignments | ||
#enable: | ||
# - fieldalignment | ||
check-shadowing: true | ||
settings: | ||
printf: | ||
funcs: | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf | ||
golint: | ||
min-confidence: 0 | ||
gocyclo: | ||
min-complexity: 10 | ||
maligned: | ||
suggest-new: true | ||
dupl: | ||
threshold: 100 | ||
threshold: 125 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
depguard: | ||
list-type: blacklist | ||
packages: | ||
# logging is allowed only by logutils.Log, logrus | ||
# is allowed to use only in logutils package | ||
- github.com/sirupsen/logrus | ||
misspell: | ||
locale: US | ||
auto-fix: true | ||
lll: | ||
line-length: 140 | ||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
gocritic: | ||
enabled-tags: | ||
- experimental | ||
- performance | ||
- style | ||
- experimental | ||
disabled-checks: | ||
- whyNoLint | ||
- wrapperFunc | ||
gocyclo: | ||
min-complexity: 15 | ||
gofumpt: | ||
extra-rules: true | ||
govet: | ||
enable: | ||
- shadow | ||
lll: | ||
line-length: 140 | ||
misspell: | ||
locale: US | ||
revive: | ||
confidence: 0 | ||
|
||
linters: | ||
enable: | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- gofmt | ||
- gocyclo | ||
- ineffassign | ||
- stylecheck | ||
- misspell | ||
- staticcheck | ||
- unused | ||
- prealloc | ||
- typecheck | ||
# XXX: add me back! - revive | ||
# additional linters | ||
- bodyclose | ||
- gocritic | ||
- goerr113 | ||
- goimports | ||
enable-all: true | ||
disable-all: false | ||
# Linters we don't like | ||
# Comments help explain why its disabled or point at ones we should not disable but will take a little work | ||
# If its not commented its likely because its just too annoying or we don't find useful | ||
disable: | ||
- copyloopvar # requires go >=1.22 | ||
- cyclop | ||
- deadcode # deprecated | ||
- depguard | ||
- errname # maybe should be enabled | ||
- exhaustivestruct # deprecated | ||
- exhaustruct | ||
- forbidigo | ||
- funlen | ||
- gochecknoglobals | ||
- gochecknoinits | ||
- gocognit | ||
- goconst | ||
- godot | ||
- godox | ||
- golint # deprecated | ||
- gomnd | ||
- misspell | ||
- noctx | ||
- stylecheck | ||
- whitespace | ||
enable-all: false | ||
disable-all: true | ||
|
||
run: | ||
build-tags: | ||
- gingonic | ||
skip-dirs: | ||
- scripts | ||
- docker | ||
- samples | ||
#modules-download-mode: vendor | ||
- ifshort # deprecated | ||
- inamedparam | ||
- interfacebloat | ||
- interfacer # deprecated | ||
- intrange # requires go >=1.22 | ||
- ireturn # should be enabled, ironlib needs some changes | ||
- lll # not previously enabled, ironlib and mctl both fail this | ||
- maligned # deprecated | ||
- nestif | ||
- nilnil | ||
- nlreturn | ||
- nolintlint | ||
- nonamedreturns # should be enabled, probably | ||
- nosnakecase # deprecated | ||
- paralleltest | ||
- perfsprint | ||
- scopelint # deprecated | ||
- structcheck # deprecated | ||
- tagliatelle | ||
- tenv # should be enabled | ||
- testpackage | ||
- testifylint # should be enabled | ||
- thelper # should be enabled | ||
- varcheck # deprecated | ||
- varnamelen | ||
- wrapcheck | ||
- wsl | ||
|
||
issues: | ||
exclude-rules: | ||
- linters: | ||
- gosec | ||
text: "weak cryptographic primitive" | ||
|
||
- linters: | ||
- stylecheck | ||
text: "ST1016" | ||
exclude: | ||
# Default excludes from `golangci-lint run --help` with EXC0002 removed | ||
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok | ||
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked | ||
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments | ||
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form) | ||
# EXC0003 golint: False positive when tests are defined in package 'test' | ||
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this | ||
# EXC0004 govet: Common false positives | ||
- (possible misuse of unsafe.Pointer|should have signature) | ||
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore | ||
- ineffective break statement. Did you mean to break out of the outer loop | ||
# EXC0006 gosec: Too many false-positives on 'unsafe' usage | ||
- Use of unsafe calls should be audited | ||
# EXC0007 gosec: Too many false-positives for parametrized shell calls | ||
- Subprocess launch(ed with variable|ing should be audited) | ||
# EXC0008 gosec: Duplicated errcheck checks | ||
- (G104|G307) | ||
# EXC0009 gosec: Too many issues in popular repos | ||
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less) | ||
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)' | ||
- Potential file inclusion via variable | ||
exclude-use-default: false | ||
|
||
# golangci.com configuration | ||
# https://github.com/golangci/golangci/wiki/Configuration | ||
#service: | ||
# golangci-lint-version: 1.15.x # use the fixed version to not introduce new linters unexpectedly | ||
# prepare: | ||
# - echo "here I can run custom commands, but no preparation needed for this repo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
LINTER_EXPECTED_VERSION := "1.55.2" | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
## lint | ||
lint: | ||
(golangci-lint --version | grep -q "${LINTER_EXPECTED_VERSION}" && golangci-lint run --config .golangci.yml) \ | ||
|| echo "expected linter version: ${LINTER_EXPECTED_VERSION}" | ||
go run github.com/golangci/golangci-lint/cmd/[email protected] run --config .golangci.yml | ||
|
||
## Go test | ||
test: lint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,4 @@ func main() { | |
if err != nil { | ||
logger.Fatal(err) | ||
} | ||
|
||
} |
Oops, something went wrong.