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

linting is failing on a file that should be ignored #998

Closed
3 tasks done
sjansen opened this issue Mar 19, 2020 · 2 comments · Fixed by #1065
Closed
3 tasks done

linting is failing on a file that should be ignored #998

sjansen opened this issue Mar 19, 2020 · 2 comments · Fixed by #1065
Labels
bug Something isn't working

Comments

@sjansen
Copy link

sjansen commented Mar 19, 2020

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • 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.24.0 built from 6fd4383 on 2020-03-15T11:38:02Z
Config file
$ cat .golangci.yml
run:
    deadline: 3m
    issues-exit-code: 1
    tests: true
    build-tags:
    - integration

linters:
    enable:
    - deadcode
    - gocritic
    - gocyclo
    - gofmt
    - goimports
    - golint
    - gosimple
    - govet
    - ineffassign
    - lll
    - maligned
    - megacheck
    - misspell
    - structcheck
    - typecheck
    - varcheck
    disable:
    - errcheck  # configurable ignore
    fast: false

linters-settings:
    gocyclo:
        min-complexity: 15
    golint:
        min-confidence: 0
    lll:
        tab-width: 8
    maligned:
        suggest-new: true
Go environment
$ go version && go env
go version go1.14 linux/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/go/src/github.com/sjansen/lolcode-go/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-build526291357=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /go/src/github.com/sjansen/lolcode-go /go/src/github.com/sjansen /go/src/github.com /go/src /go /]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 17 linters: [deadcode gocritic gocyclo gofmt goimports golint gosimple govet ineffassign lll maligned misspell staticcheck structcheck typecheck unused varcheck]"
level=info msg="[lintersdb] Active 17 linters: [deadcode gocritic gocyclo gofmt goimports golint gosimple govet ineffassign lll maligned misspell staticcheck structcheck typecheck unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (imports|types_sizes|compiled_files|deps|exports_file|files|name) took 3.3095437s"
level=info msg="[runner/filename_unadjuster] Pre-built 1 adjustments in 106.1512ms"
level=info msg="[runner/unused/goanalysis] analyzers took 14.8542788s with top 10 stages: buildir: 14.6545166s, U1000: 199.7622ms"
level=info msg="[runner/goanalysis_metalinter/goanalysis] analyzers took 13.9142218s with top 10 stages: buildir: 9.4871235s, inspect: 563.8907ms, ctrlflow: 405.926ms, fact_purity: 290.5132ms, printf: 266.2469ms, SA4006: 255.7499ms, golint: 230.6868ms, misspell: 215.715ms, fact_deprecated: 211.0386ms, ineffassign: 206.1673ms"
level=warning msg="[runner] Can't run linter goanalysis_metalinter: gofmt: /go/src/github.com/sjansen/lolcode-go/internal/ast/ast_parser.rl:5:1: expected declaration, found '%' (and 29 more errors)"
level=info msg="[runner] Issues before processing: 3, after processing: 0"
level=info msg="[runner] Processors filtering stat (out/in): path_prettifier: 3/3, skip_dirs: 3/3, cgo: 3/3, filename_unadjuster: 3/3, skip_files: 3/3, autogenerated_exclude: 0/3"
level=info msg="[runner] processing took 9.808ms with stages: path_prettifier: 5.59ms, autogenerated_exclude: 2.3726ms, skip_dirs: 1.4726ms, max_per_file_from_linter: 42.1µs, nolint: 39.6µs, max_from_linter: 38.8µs, uniq_by_line: 34µs, max_same_issues: 31.3µs, filename_unadjuster: 29.8µs, identifier_marker: 20.9µs, path_shortener: 20.5µs, exclude-rules: 20.2µs, source_code: 20µs, skip_files: 19.5µs, exclude: 19.5µs, diff: 19.1µs, cgo: 17.5µs"
level=info msg="[runner] linters took 16.0783729s with stages: unused: 11.4166413s, goanalysis_metalinter: 4.6499064s"
level=error msg="Running error: gofmt: /go/src/github.com/sjansen/lolcode-go/internal/ast/ast_parser.rl:5:1: expected declaration, found '%' (and 29 more errors)"
level=info msg="Memory: 164 samples, avg is 556.3MB, max is 1282.1MB"
level=info msg="Execution took 19.5140635s"

Linting is failing on a file that should be ignored: ast_parser.rl

Running error: gofmt: /go/src/github.com/sjansen/lolcode-go/internal/ast/ast_parser.rl:5:1: expected declaration, found '%' (and 29 more errors)

@techjacker
Copy link

I'm getting the same issue with 1.24.0. Had to roll back to 1.23.8.

Seems to work on one run then error on the next. I tried cleaning the cache each time but still same behaviour.

@ernado ernado added the bug Something isn't working label Apr 21, 2020
@sjansen
Copy link
Author

sjansen commented Apr 29, 2020

This is still an issue with 1.25.1

golangci-lint has version 1.25.1 built from 07374ce on 2020-04-27T18:08:03Z

ksoichiro added a commit to ksoichiro/golangci-lint that referenced this issue May 3, 2020
If the target files contains `//line` directive and it indicates
a non-go file, the linter is going to handle it as a go file,
which results in failure.
The cause of this issue is that the linters (`Analyzer`s) are using
`pass.Fset.Position()`. This func returns the adjusted position using
`//line` directive.
The example project reported in golangci#998 has `//line` directive that
indicates other non-go file.
According to the description of "Compiler Directives”
(https://golang.org/cmd/compile/#hdr-Compiler_Directives),
line directives is mainly used for reporting original positions to
the generators or something.
On linters of golangci-lint, `pass.Fset.Position()` is used just to
aggregate file names; we don't have to adjust positions.
This changes `Analyzer`s that use `pass.Fset.Position()` to aggregate
file names to use `pass.Fset.PositionFor()` with `adjusted == false`.

Relates: golangci#998
jirfag pushed a commit that referenced this issue May 5, 2020
If the target files contains `//line` directive and it indicates
a non-go file, the linter is going to handle it as a go file,
which results in failure.
The cause of this issue is that the linters (`Analyzer`s) are using
`pass.Fset.Position()`. This func returns the adjusted position using
`//line` directive.
The example project reported in #998 has `//line` directive that
indicates other non-go file.
According to the description of "Compiler Directives”
(https://golang.org/cmd/compile/#hdr-Compiler_Directives),
line directives is mainly used for reporting original positions to
the generators or something.
On linters of golangci-lint, `pass.Fset.Position()` is used just to
aggregate file names; we don't have to adjust positions.
This changes `Analyzer`s that use `pass.Fset.Position()` to aggregate
file names to use `pass.Fset.PositionFor()` with `adjusted == false`.

Relates: #998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants