Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, there are 2 problems:
typecheck
usesLoadModeTypesInfo
andWithLoadForGoAnalysis
.So the load mode of the linter config for the
metalinter
is alwaysLoadModeTypesInfo
and neverLoadModeSyntax
.metalinter
has a hardcoded call toWithLoadForGoAnalysis
, then the types are always loaded.As a consequence, the "fast" linters (like
lll
,gofmt
,misspell
, etc.) are slower than expected when either they are running alone or only "fast" linters are run.This PR changes the config linter load mode of
typecheck
toLoadModeNone
and removesWithLoadForGoAnalysis
for this fake linter.The
metalinter
goanalysis load mode is computed based on linters.typecheck
doesn't need an explicit load mode because it is never run alone, then at the end, the load mode will depend on the load mode of the real linters.Same thing for the goanalysis load mode.
FYI, there are 2 load modes:
LoadModeTypesInfo
,LoadModeSyntax
, etc.)WithLoadForGoAnalysis
,WithLoadFiles
)They are used for different purposes.
Based on local tests (verbose mode), the performances are improved (~50%).
On golangci-lint code
Current version:
golangci-lint cache clean; golangci-lint run --enable-only misspell --enable-only lll -v
With the PR:
golangci-lint cache clean; ./golangci-lint run --enable-only misspell --enable-only lll -v
On Traefik code
Current version:
golangci-lint cache clean; golangci-lint run --enable-only gofmt --enable-only misspell -v
Current version:
golangci-lint cache clean; ./golangci-lint run --enable-only gofmt --enable-only misspell -v
Fixes #2914
Fixes #4639