Skip to content

Commit

Permalink
Merge branch 'master' into path-filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
pohly committed Feb 17, 2023
2 parents 33826ae + 69e5481 commit 933ba6f
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 54 deletions.
24 changes: 12 additions & 12 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1924,48 +1924,48 @@ linters-settings:
# this is set to true - the append call must append either a variable
# assigned, called or used on the line above.
strict-append: true

# Allows assignments to be cuddled with variables used in calls on
# line above and calls to be cuddled with assignments of variables
# used in call on line above.
allow-assign-and-call: true

# Allows assignments to be cuddled with anything.
allow-assign-and-anything: false

# Allows cuddling to assignments even if they span over multiple lines.
allow-multiline-assign: true

# If the number of lines in a case block is equal to or lager than this
# number, the case *must* end white a newline.
force-case-trailing-whitespace: 0

# Allow blocks to end with comments.
allow-trailing-comment: false

# Allow multiple comments in the beginning of a block separated with newline.
allow-separated-leading-comment: false

# Allow multiple var/declaration statements to be cuddled.
allow-cuddle-declarations: false

# A list of call idents that everything can be cuddled with.
# Defaults to calls looking like locks.
allow-cuddle-with-calls: [ "Lock", "RLock" ]

# AllowCuddleWithRHS is a list of right hand side variables that is allowed
# to be cuddled with anything. Defaults to assignments or calls looking
# like unlocks.
allow-cuddle-with-rhs: [ "Unlock", "RUnlock" ]

# Causes an error when an If statement that checks an error variable doesn't
# cuddle with the assignment of that variable.
force-err-cuddling: false

# When force-err-cuddling is enabled this is a list of names
# used for error variables to check for in the conditional.
error-variable-names: [ "err" ]

# Causes an error if a short declaration (:=) cuddles with anything other than
# another short declaration.
# This logic overrides force-err-cuddling among others.
Expand Down
4 changes: 4 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ changelog:
- Merge pull request
- Merge branch

source:
enabled: true
name_template: '{{ .ProjectName }}-{{ .Version }}-source'

brews:
- tap:
owner: golangci
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at idenx@yandex.com. All
reported by contacting the project team at info@golangci.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand Down
12 changes: 6 additions & 6 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/src/docs/contributing/architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (cl *ContextLoader) Load(ctx context.Context, linters []*linter.Config) (*l
```

First, we find a load mode as union of load modes for all enabled linters.
We use [go/packages](https://godoc.org/golang.org/x/tools/go/packages) for packages loading and use it's enum `packages.Need*` for load modes.
We use [go/packages](https://pkg.go.dev/golang.org/x/tools/go/packages) for packages loading and use it's enum `packages.Need*` for load modes.
Load mode sets which data does a linter needs for execution.

A linter that works only with AST need minimum of information: only filenames and AST. There is no need for
Expand Down Expand Up @@ -165,7 +165,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithLoadForGoAnalysis().
WithPresets(linter.PresetBugs).
WithAlternativeNames("vet", "vetshadow").
WithURL("https://golang.org/cmd/vet/"),
WithURL("https://pkg.go.dev/cmd/vet"),
linter.NewConfig(golinters.NewBodyclose()).
WithLoadForGoAnalysis().
WithPresets(linter.PresetPerformance, linter.PresetBugs).
Expand Down Expand Up @@ -208,10 +208,10 @@ Currently, all linters except `unused` can be merged into this meta linter.
The `unused` isn't merged because it has high memory usage.

Linters execution starts in `runAnalyzers`. It's the most complex part of the `golangci-lint`.
We use custom [go/analysis](https://godoc.org/golang.org/x/tools/go/analysis) runner there. It runs as much as it can in parallel. It lazy-loads as much as it can
We use custom [go/analysis](https://pkg.go.dev/golang.org/x/tools/go/analysis) runner there. It runs as much as it can in parallel. It lazy-loads as much as it can
to reduce memory usage. Also, it sets all heavyweight data to `nil` as becomes unneeded to save memory.

We don't use existing [multichecker](https://godoc.org/golang.org/x/tools/go/analysis/multichecker) because
We don't use existing [multichecker](https://pkg.go.dev/golang.org/x/tools/go/analysis/multichecker) because
it doesn't use caching and doesn't have some important performance optimizations.

All found by linters issues are represented with `result.Issue` struct:
Expand Down
4 changes: 2 additions & 2 deletions docs/src/docs/contributing/workflow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ conduct](https://github.com/golangci/golangci-lint/blob/master/CODE_OF_CONDUCT.m

## Setup your machine

`golangci-lint` is written in [Go](https://golang.org/).
`golangci-lint` is written in [Go](https://go.dev).

Prerequisites:

- `make`
- [Go](https://golang.org/doc/install)
- [Go](https://go.dev/doc/install)

Fork and clone [golangci-lint](https://github.com/golangci/golangci-lint) repository.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/usage/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ the `go tool trace` command and visualization tool.

## Cache

GolangCI-Lint stores its cache in the subdirectory `golangci-lint` inside the [default user cache directory](https://golang.org/pkg/os/#UserCacheDir).
GolangCI-Lint stores its cache in the subdirectory `golangci-lint` inside the [default user cache directory](https://pkg.go.dev/os#UserCacheDir).

You can override the default cache directory with the environment variable `GOLANGCI_LINT_CACHE`; the path must be absolute.
2 changes: 1 addition & 1 deletion docs/src/docs/usage/performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Performance

## Memory Usage

A trade-off between memory usage and execution time can be controlled by [`GOGC`](https://golang.org/pkg/runtime/#hdr-Environment_Variables) environment variable.
A trade-off between memory usage and execution time can be controlled by [`GOGC`](https://pkg.go.dev/runtime#hdr-Environment_Variables) environment variable.
Less `GOGC` values trigger garbage collection more frequently and golangci-lint consumes less memory and more CPU. Below is the trade-off table for running on this repo:

| `GOGC` | Peak Memory, GB | Execution Time, s |
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/OpenPeeDeeP/depguard v1.1.1
github.com/alexkohler/prealloc v1.0.0
github.com/alingse/asasalint v0.0.11
github.com/ashanbrown/forbidigo v1.3.0
github.com/ashanbrown/forbidigo v1.4.0
github.com/ashanbrown/makezero v1.1.1
github.com/bkielbasa/cyclop v1.2.0
github.com/blizzy78/varnamelen v0.8.0
Expand Down Expand Up @@ -52,7 +52,7 @@ require (
github.com/jingyugao/rowserrcheck v1.1.1
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af
github.com/julz/importas v0.1.0
github.com/junk1tm/musttag v0.4.4
github.com/junk1tm/musttag v0.4.5
github.com/kisielk/errcheck v1.6.3
github.com/kkHAIKE/contextcheck v1.1.3
github.com/kulti/thelper v0.6.3
Expand All @@ -76,7 +76,7 @@ require (
github.com/nishanths/predeclared v0.2.2
github.com/nunnatsa/ginkgolinter v0.8.1
github.com/pkg/errors v0.9.1
github.com/polyfloyd/go-errorlint v1.0.6
github.com/polyfloyd/go-errorlint v1.1.0
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/ryancurrah/gomodguard v1.3.0
github.com/ryanrolds/sqlclosecheck v0.4.0
Expand Down Expand Up @@ -110,9 +110,9 @@ require (
github.com/yagipy/maintidx v1.0.0
github.com/yeya24/promlinter v0.2.0
gitlab.com/bosi/decorder v0.2.3
golang.org/x/tools v0.5.0
golang.org/x/tools v0.6.0
gopkg.in/yaml.v3 v3.0.1
honnef.co/go/tools v0.4.0
honnef.co/go/tools v0.4.2
mvdan.cc/gofumpt v0.4.0
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d
Expand Down Expand Up @@ -180,9 +180,9 @@ require (
go.uber.org/zap v1.17.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.6.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
28 changes: 15 additions & 13 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/golinters/forbidigo.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func runForbidigo(pass *analysis.Pass, settings *config.ForbidigoSettings) ([]go

var issues []goanalysis.Issue
for _, file := range pass.Files {
hints, err := forbid.Run(pass.Fset, file)
hints, err := forbid.RunWithConfig(forbidigo.RunConfig{Fset: pass.Fset}, file)
if err != nil {
return nil, errors.Wrapf(err, "forbidigo linter failed on file %q", file.Name.String())
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/golinters/govet.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var (
unusedwrite.Analyzer,
}

// https://github.com/golang/go/blob/879db69ce2de814bc3203c39b45617ba51cc5366/src/cmd/vet/main.go#L40-L68
// https://github.com/golang/go/blob/9f834a559c9ed6cdf883e29b36e21e5f956df74f/src/cmd/vet/main.go#L46-L76
defaultAnalyzers = []*analysis.Analyzer{
asmdecl.Analyzer,
assign.Analyzer,
Expand All @@ -114,6 +114,7 @@ var (
structtag.Analyzer,
testinggoroutine.Analyzer,
tests.Analyzer,
timeformat.Analyzer,
unmarshal.Analyzer,
unreachable.Analyzer,
unsafeptr.Analyzer,
Expand Down

0 comments on commit 933ba6f

Please sign in to comment.