Skip to content
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

prealloc: false positive #633

Closed
carnott-snap opened this issue Aug 7, 2019 · 1 comment
Closed

prealloc: false positive #633

carnott-snap opened this issue Aug 7, 2019 · 1 comment
Labels
dependencies Relates to an upstream dependency false positive An error is reported when one does not exist

Comments

@carnott-snap
Copy link

  1. Version of golangci-lint: golangci-lint --version (or git commit if you don't use binary distribution)
golangci-lint has version v1.17.1 built from (unknown, mod sum: "h1:lc8Hf9GPCjIr0hg3S/xhvFT1+Hydass8F1xchr8jkME=") on (unknown)
  1. Config file: cat .golangci.toml
[linters]
disable-all = true
enable = ["prealloc"]
  1. Go environment: go version && go env
go version go1.12.7 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY=""
GORACE=""
GOROOT="/home/user/.local/share/umake/go/go-lang"
GOTMPDIR=""
GOTOOLDIR="/home/user/.local/share/umake/go/go-lang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build952158134=/tmp/go-build -gno-record-gcc-switches"
  1. Verbose output of running: golangci-lint run -v
INFO [config_reader] Config search paths: [./ /tmp/test /tmp /] 
INFO [config_reader] Used config file .golangci.toml 
INFO [lintersdb] Active 1 linters: [prealloc]     
INFO [loader] Go packages loading at mode load files took 39.075415ms 
INFO [runner] worker.1 took 2.247µs               
INFO [runner] worker.3 took 5.257µs               
INFO [runner] worker.4 took 16.694µs              
INFO [runner] worker.2 took 95.789µs with stages: prealloc: 56.232µs 
INFO [runner] Workers idle times: #1: 41.617µs, #3: 21.566µs, #4: 9.983µs 
INFO [runner] processing took 266.368µs with stages: exclude: 90.072µs, identifier_marker: 77.485µs, source_code: 36.31µs, skip_dirs: 14.474µs, nolint: 11.319µs, autogenerated_exclude: 11.138µs, cgo: 8.666µs, path_prettifier: 7.254µs, uniq_by_line: 2.226µs, max_same_issues: 1.884µs, path_shortener: 1.619µs, max_from_linter: 1.141µs, filename_unadjuster: 990ns, max_per_file_from_linter: 884ns, diff: 437ns, skip_files: 277ns, exclude-rules: 192ns 
main.go:4:2: Consider preallocating `a` (prealloc)
        var a []int
        ^
INFO File cache stats: 1 entries of total size 135B 
INFO Memory: 2 samples, avg is 68.9MB, max is 68.9MB 
INFO Execution took 78.8856ms                     
  1. This issue was also reported upstream: line of sight loops trick prealloc alexkohler/prealloc#16
var a []int
for i := range []struct{}{{}, {}, {}} {
        if i < 1 {
              continue
        } 
        a = append(a, i)
}
@tpounds tpounds added the false positive An error is reported when one does not exist label Sep 25, 2019
@tpounds tpounds added the dependencies Relates to an upstream dependency label Oct 6, 2019
@jirfag
Copy link
Member

jirfag commented Oct 15, 2019

Thank you, please reopen when upstream will be fixed to update it

@jirfag jirfag closed this as completed Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Relates to an upstream dependency false positive An error is reported when one does not exist
Projects
None yet
Development

No branches or pull requests

3 participants