You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started a brand new linter config for some projects, take some time configuring all of these in golangci-lint when I saw this bug.
If i have something like this:
//PrintMeUp will print text to the consolefuncPrintMeUp(textstring) {
fmt.Println(text)
}
And activate gocriticandgoimports in my config. Launch lint with golangci-lint run -v --fix, this will remove the comment instead of adding a whitespace between // and the sentence.
If I deactivate one of the two linters, it works like a charm.
I added a reproducible repository in the Code example or link to a public repository section below.
Thanks in advance !
Version of golangci-lint
$ golangci-lint --version
# golangci-lint has version v1.51.2 built from (unknown, mod sum: "h1:yIcsT1X9ZYHdSpeWXRT1ORC/FPGSqDHbHsu9uk4FK7M=") on (unknown)
Configuration file
$ cat .golangci.yml
run:
concurrency: 4# timeout for analysis, e.g. 30s, 5m, default is 1mtimeout: 5m# exit code when at least one issue was found, default is 1issues-exit-code: 1# include test files or not, default is truetests: falseskip-dirs:
- build/...
- vendor/...# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":# If invoked with -mod=readonly, the go command is disallowed from the implicit# automatic updating of go.mod described above. Instead, it fails when any changes# to go.mod are needed. This setting is most useful to check that go.mod does# not need updates, such as in a continuous integration and testing system.# If invoked with -mod=vendor, the go command assumes that the vendor# directory holds the correct copies of dependencies and ignores# the dependency descriptions in go.mod.modules-download-mode: vendor# all available settings of specific linterslinters-settings:
gocritic:
# Settings passed to gocritic.# The settings key is the name of a supported gocritic checker.# The list of supported checkers can be find in https://go-critic.github.io/overview.# disabled-checks:# - commentFormattingsettings:
captLocal:
# Whether to restrict checker to params only.# Default: trueparamsOnly: falseunderef:
# Whether to skip (*x).method() calls where x is a pointer receiver.# Default: trueskipRecvDeref: falselinters:
enable:
- gocritic # provides diagnostics that check for bugs, performance and style issues
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmtenable-all: falsedisable-all: truefast: falseissues:
# Excluding configuration per-path, per-linter, per-text and per-sourceexclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.golinters:
# - gocyclo
- errcheck
- dupl
- gosec
- funlen
- goconst
- gochecknoglobals
- gocritic
- lll
- noctx
- wrapcheck
- path: testsutils/linters:
# - gocyclo
- errcheck
- dupl
- gosec
- funlen
- gochecknoglobals
- gocritic
- lll
- wrapcheck
- path: internal/version/linters:
- gochecknoglobals
- source: "//noinspection"linters: [ gocritic ]# Exclude `lll` issues for long lines with `go:generate`.
- source: "^//go:generate "linters:
- lll
- source: "(noinspection|TODO)"linters: [ godot, lll ]exclude-use-default: falsenew-from-rev: ""
Go environment
$ go version && go envgo version go1.20 linux/amd64GO111MODULE=""GOARCH="amd64"GOBIN=""GOCACHE="/home/pawndev/.cache/go-build"GOENV="/home/pawndev/.config/go/env"GOEXE=""GOEXPERIMENT=""GOFLAGS=""GOHOSTARCH="amd64"GOHOSTOS="linux"GOINSECURE=""GOMODCACHE="/home/pawndev/workspace/go/pkg/mod"GONOPROXY=""GONOSUMDB=""GOOS="linux"GOPATH="/home/pawndev/workspace/go:/usr/lib/go"GOPRIVATE=""GOPROXY="https://proxy.golang.org,direct"GOROOT="/usr/lib/go"GOSUMDB="sum.golang.org"GOTMPDIR=""GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"GOVCS=""GOVERSION="go1.20"GCCGO="gccgo"GOAMD64="v1"AR="ar"CC="gcc"CXX="g++"CGO_ENABLED="1"GOMOD="/home/pawndev/workspace/go/golangci-lint-conflict-goimports-gocritic/go.mod"GOWORK=""CGO_CFLAGS="-O2 -g"CGO_CPPFLAGS=""CGO_CXXFLAGS="-O2 -g"CGO_FFLAGS="-O2 -g"CGO_LDFLAGS="-O2 -g"PKG_CONFIG="pkg-config"GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build909477859=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/pawndev/workspace/go/golangci-lint-conflict-goimports-gocritic /home/pawndev/workspace/go /home/pawndev/workspace /home/pawndev /home /] INFO [config_reader] Used config file .golangci.yml INFO [lintersdb] Active 2 linters: [gocritic goimports] INFO [loader] Go packages loading at mode 575 (imports|types_sizes|compiled_files|deps|exports_file|files|name) took 71.200352ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 96.673µs INFO [linters_context/goanalysis] analyzers took 4.110431ms with top 10 stages: gocritic: 3.191592ms, goimports: 918.839µs INFO [runner] Issues before processing: 2, after processing: 1 INFO [runner] Processors filtering stat (out/in): diff: 1/1, source_code: 1/1, path_shortener: 1/1, path_prefixer: 1/1, path_prettifier: 2/2, skip_dirs: 2/2, identifier_marker: 2/2, nolint: 2/2, uniq_by_line: 1/2, max_from_linter: 1/1, severity-rules: 1/1, sort_results: 1/1, filename_unadjuster: 2/2, autogenerated_exclude: 2/2, exclude-rules: 2/2, max_same_issues: 1/1, cgo: 2/2, exclude: 2/2, max_per_file_from_linter: 1/1, skip_files: 2/2 INFO [runner] processing took 83.609µs with stages: identifier_marker: 26.928µs, nolint: 14.526µs, path_prettifier: 12.211µs, autogenerated_exclude: 8.99µs, skip_dirs: 8.235µs, exclude-rules: 6.763µs, max_same_issues: 1.039µs, source_code: 958ns, uniq_by_line: 839ns, cgo: 824ns, max_from_linter: 466ns, filename_unadjuster: 364ns, skip_files: 346ns, path_shortener: 315ns, max_per_file_from_linter: 186ns, exclude: 184ns, severity-rules: 179ns, sort_results: 98ns, diff: 88ns, path_prefixer: 70ns INFO [runner] linters took 187.741069ms with stages: goanalysis_metalinter: 187.619692ms custom/print.go:5:1: commentFormatting: put a space between `//` and comment text (gocritic)//PrintMeUp will print text to the console^INFO File cache stats: 1 entries of total size 124B INFO Memory: 4 samples, avg is 50.0MB, max is 60.7MB INFO Execution took 263.381749m
Welcome
Description of the problem
Hi, in advance sorry for my bad english,
I started a brand new linter config for some projects, take some time configuring all of these in golangci-lint when I saw this bug.
If i have something like this:
And activate
gocritic
andgoimports
in my config. Launch lint withgolangci-lint run -v --fix
, this will remove the comment instead of adding a whitespace between//
and the sentence.If I deactivate one of the two linters, it works like a charm.
I added a reproducible repository in the
Code example or link to a public repository
section below.Thanks in advance !
Version of golangci-lint
Configuration file
$ cat .golangci.yml
Go environment
Verbose output of running
Code example or link to a public repository
Reproducible repository
The text was updated successfully, but these errors were encountered: