Skip to content

Can't cope with line directives in goyacc generated files: "yaccpar: no such file or directory"  #1559

Open
@jaqx0r

Description

@jaqx0r

github.com/google/mtail creates part of the parser with goyacc, and that code generator inserts line directives for things that don't really exist because they're internal string constants inside goyacc before the code is generated.

I don't understand why golangci-lint fails here, but I remember gometalinter used to fail in a similar way.


  • [ x] Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • [ x] Yes, I've searched similar issues on GitHub and didn't find any.
  • [ x] Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.33.0 built from b90551c on 2020-11-23T05:15:36Z
Config file
$ cat .golangci.yml
service:
  prepare:
    - make install_deps

run:
  tests: true
  build-tags:
    - integration
  skip-files:
    - yaccpar

linters-settings:
  govet:
    check-shadowing: true

linters:
  enable-all: true
  disable:
    - maligned
    - megacheck
    - lll
    - gocyclo
    - unparam
    # Not sure what this is telling me yet.
    - scopelint
    # How dare you tell me not to use inits.
    - gochecknoinits
    # Flags are fine, as are test tables.
    - gochecknoglobals
    # wsl doesn't explain any of its recommendations
    - wsl
    # magic numbers in test tables are fine actually
    - gomnd
    # My tests will be as long as they need to be thanks
    - funlen

issues:
  max-per-linter: 0
  max-same: 0
  exclude-use-default: true
  exclude:
  #   # Captured by errcheck.
  #   - '^(G104|G204):'
  #   # Very commonly not checked.
  #   - 'Error return value of .(.*\.Help|.*\.MarkFlagRequired|(os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked'
  #   #- 'exported method (.*\.MarshalJSON|.*\.UnmarshalJSON|.*\.EntityURN|.*\.GoString|.*\.Pos) should have comment or be unexported'
     # If you liked it you shoulda put a gofix on it.
     - 'composite literal uses unkeyed fields'
     # I like shadowing err
     - 'declaration of "err" shadows declaration'
  #   #- 'bad syntax for struct tag key'
  #   #- 'bad syntax for struct tag pair'
     # goyacc generated error in three locations
     - 'this value of `mtailDollar.* is never used'
     # Incorrectly reports undeclared in same package
     - "undeclared name:"

Go environment
$ go version && go env
go version go1.14.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jaq/.cache/go-build"
GOENV="/home/jaq/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jaq/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jaq/src/golang/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jaq/src/golang/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jaq/go/src/github.com/google/mtail/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-build831103737=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
/mtail /home/jaq/go/src/github.com/google /home/jaq/go/src/github.com /home/jaq/go/src /home/jaq/go /home/jaq /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 48 linters: [asciicheck bodyclose deadcode depguard dogsled dupl errcheck errorlint exhaustive exhaustivestruct exportloopref gci gocognit goconst gocritic godot godox goerr113 gofmt gofumpt goheader goimports golint gomodguard goprintffuncname gosec govet ineffassign interfacer misspell nakedret nestif nlreturn noctx nolintlint paralleltest prealloc rowserrcheck sqlclosecheck structcheck stylecheck testpackage tparallel typecheck unconvert varcheck whitespace wrapcheck] 
INFO [loader] Using build tags: [integration]     
INFO [loader] Go packages loading at mode 575 (files|imports|compiled_files|deps|exports_file|name|types_sizes) took 577.022607ms 
INFO [runner/filename_unadjuster] Pre-built 1 adjustments in 23.652692ms 
INFO [linters context/goanalysis] analyzers took 1m10.042020326s with top 10 stages: buildir: 16.693125195s, dupl: 8.177282718s, the_only_name: 6.548406147s, buildssa: 3.83183074s, goimports: 2.679286711s, gofumpt: 2.509275176s, godot: 2.373875231s, unconvert: 2.172736071s, gocritic: 1.903569508s, gosec: 1.781943863s 
WARN [runner] Can't run linter goanalysis_metalinter: whitespace: failed to get line /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar:329: failed to get file /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar lines cache: can't get file /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar bytes from cache: can't read file /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar: open /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar: no such file or directory 
INFO [runner] processing took 6.101µs with stages: autogenerated_exclude: 1.547µs, max_same_issues: 1.03µs, cgo: 540ns, nolint: 458ns, skip_dirs: 331ns, max_from_linter: 322ns, uniq_by_line: 224ns, filename_unadjuster: 210ns, diff: 195ns, identifier_marker: 179ns, path_shortener: 163ns, skip_files: 161ns, source_code: 156ns, path_prettifier: 152ns, sort_results: 79ns, exclude: 77ns, max_per_file_from_linter: 77ns, exclude-rules: 74ns, path_prefixer: 65ns, severity-rules: 61ns 
INFO [runner] linters took 13.369428673s with stages: goanalysis_metalinter: 13.369344421s 
ERRO Running error: whitespace: failed to get line /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar:329: failed to get file /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar lines cache: can't get file /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar bytes from cache: can't read file /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar: open /home/jaq/go/src/github.com/google/mtail/internal/vm/parser/yaccpar: no such file or directory 
INFO Memory: 137 samples, avg is 349.6MB, max is 741.2MB 
INFO Execution took 13.976735477s       

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cgoRelated to CGO or line directivesbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions