Skip to content

whitespace: failed to get line path/parse/yaccpar:329 #3967

@theory

Description

@theory

Welcome

Description of the problem

Similar to #2788, but chokes on files generated by goyacc, it chokes on lines like this:

//line yaccpar:1

Oddly, if I remove lines starting with //line yacc, I get a different error, where it looks like golangci-lint tries to validate the .y grammar file? The error is:

can't run linter goanalysis_metalinter: whitespace: failed to get line goyacc-tutorial/calculator/grammar_03_final.y:462: invalid file line index0 (461) >= len(fc) (59)

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.53.3 built with go1.20.5 from 2dcd82f on 2023-06-14T21:13:17Z

Configuration

linters:
  enable-all: true
  disable:
    - funlen
    - varnamelen
    - cyclop
    - exhaustruct
    - testpackage
    - gomnd # Failed to get ignored-functions to work below
    # Disable deprecated checks
    - exhaustivestruct
    - varcheck
    - maligned
    - structcheck
    - ifshort
    - golint
    - deadcode
    - interfacer
    - scopelint
    - nosnakecase

issues:
  fix: true

Go environment

$ go version && go env
go version go1.20.3 darwin/arm64
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/david/Library/Caches/go-build"
GOENV="/Users/david/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/david/.gvm/pkgsets/go1.20.3/global/pkg/mod"
GONOPROXY="github.com/nytm/*,github.com/NYTimes/*,github.com/nytimes/*"
GONOSUMDB="github.com/nytm/*,github.com/NYTimes/*,github.com/nytimes/*"
GOOS="darwin"
GOPATH="/Users/david/.gvm/pkgsets/go1.20.3/global"
GOPRIVATE="github.com/nytm/*,github.com/NYTimes/*,github.com/nytimes/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/david/.gvm/gos/go1.20.3"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/david/.gvm/gos/go1.20.3/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/david/dev/go/goyacc-tutorial/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fl/mkyy75ys4mb372g__86mndsr0000gr/T/go-build375712479=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/david/dev/go/goyacc-tutorial /Users/david/dev/go /Users/david/dev /Users/david /Users /] 
INFO [config_reader] Used config file .golangci.yaml 
INFO [lintersdb] Active 91 linters: [asasalint asciicheck bidichk bodyclose containedctx contextcheck decorder depguard dogsled dupl dupword durationcheck errcheck errchkjson errname errorlint execinquery exhaustive exportloopref forbidigo forcetypeassert gci ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gocognit goconst gocritic gocyclo godot godox goerr113 gofmt gofumpt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple gosmopolitan govet grouper importas ineffassign interfacebloat ireturn lll loggercheck maintidx makezero mirror misspell musttag nakedret nestif nilerr nilnil nlreturn noctx nolintlint nonamedreturns nosprintfhostport paralleltest prealloc predeclared promlinter reassign revive rowserrcheck sqlclosecheck staticcheck stylecheck tagalign tagliatelle tenv testableexamples thelper tparallel typecheck unconvert unparam unused usestdlibvars wastedassign whitespace wrapcheck wsl zerologlint] 
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|files|name|exports_file|imports|types_sizes) took 124.363166ms 
INFO [runner/filename_unadjuster] Pre-built 2 adjustments in 679.75µs 
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key. 
INFO [linters_context/goanalysis] analyzers took 7.192892032s with top 10 stages: the_only_name: 746.243165ms, buildir: 726.599623ms, buildssa: 481.265414ms, musttag: 291.126125ms, bidichk: 172.961ms, exhaustive: 166.152752ms, gocritic: 139.751375ms, wastedassign: 122.412875ms, dupl: 117.625583ms, goimports: 105.126376ms 
WARN [runner] Can't run linter goanalysis_metalinter: whitespace: failed to get line /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar:329: failed to get file /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar lines cache: can't get file /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar bytes from cache: can't read file /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar: open /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar: no such file or directory 
INFO [runner] processing took 1.497µs with stages: max_same_issues: 375ns, skip_dirs: 250ns, identifier_marker: 166ns, cgo: 125ns, skip_files: 42ns, path_prettifier: 42ns, autogenerated_exclude: 42ns, filename_unadjuster: 42ns, max_from_linter: 42ns, sort_results: 42ns, path_prefixer: 42ns, exclude-rules: 41ns, uniq_by_line: 41ns, path_shortener: 41ns, severity-rules: 41ns, nolint: 41ns, max_per_file_from_linter: 41ns, diff: 41ns, source_code: 0s, fixer: 0s, exclude: 0s 
INFO [runner] linters took 1.126762458s with stages: goanalysis_metalinter: 1.126732375s 
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: whitespace: failed to get line /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar:329: failed to get file /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar lines cache: can't get file /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar bytes from cache: can't read file /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar: open /Users/david/dev/go/goyacc-tutorial/ast_calculator/yaccpar: no such file or directory
 
INFO Memory: 14 samples, avg is 167.2MB, max is 281.7MB 
INFO Execution took 1.265224291s                  

Code example or link to a public repository

git clone git@github.com:slrtbtfs/goyacc-tutorial.git
cd goyacc-tutorial
go mod init github.com/slrtbtfs/goyacc-tutorial
printf "linters:\n  enable-all: true\n" > .golangci.yaml
golangci-lint run -v ./calculator
perl -i -pe 's{^//line yacc.+}{}' calculator/y.go
golangci-lint run -v ./calculator

Validation

  • Yes, I've included all information above (version, config, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cgoRelated to CGO or line directivesbugSomething isn't workingdependenciesRelates to an upstream dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions