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

linter should ignore C/C++ sources #433

Closed
vitalyisaev2 opened this issue Mar 13, 2019 · 1 comment
Closed

linter should ignore C/C++ sources #433

vitalyisaev2 opened this issue Mar 13, 2019 · 1 comment

Comments

@vitalyisaev2
Copy link
Contributor

It seems like linter tries to analyze *.cc files that may occur in cgo projects. Since it treats them just like common *.go files, it causes false arams.

main.go:

package main

import (
	"fmt"

	"gopkg.in/kothar/brotli-go.v0/enc"
)

func main() {
	params := enc.NewBrotliParams()
	fmt.Println(params)
}

This file can be compiled and run, but doesn't pass typecheck:

➜  linter-issue go run .
&{{0 11 22 0 true false false true}}
➜  linter-issue golangci-lint run .   
main.go:1: /home/isaev/go/src/gopkg.in/kothar/brotli-go.v0/enc/backward_references.cc:9:1: illegal character U+0023 '#' (typecheck)
package main
  1. Version of golangci-lint: golangci-lint --version (or git commit if you don't use binary distribution)
    7514bf823931b8c777a68ba7a7af8e5217fff191

  2. Config file: cat .golangci.yml
    No config file is used.

  3. Go environment: go version && go env

go version go1.12 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/isaev/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/isaev/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build596847704=/tmp/go-build -gno-record-gcc-switches"
  1. Verbose output of running: golangci-lint run -v
golangci-lint run -v .
INFO [config_reader] Config search paths: [./ /home/isaev/go/src/github.com/vitalyisaev2/linter-issue /home/isaev/go/src/github.com/vitalyisaev2 /home/isaev/go/src/github.com /home/isaev/go/src /home/isaev/go /home/isaev /home /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck 
INFO [loader] Go packages loading at mode load deps types and syntax took 742.125074ms 
INFO [loader] SSA repr building timing: packages building 4.937668ms, total 36.069116ms 
INFO [loader] Packages that do not compile: [github.com/vitalyisaev2/linter-issue] 
INFO [runner] worker.7 took 76.357µs with stages: errcheck: 52.698µs, varcheck: 2.864µs 
INFO [runner] worker.6 took 833ns                 
INFO [runner] worker.3 took 37.586µs with stages: deadcode: 21.01µs 
INFO [runner] worker.1 took 28.934µs              
INFO [runner] worker.5 took 141.67µs              
INFO [runner] worker.2 took 278.9µs with stages: typecheck: 120.243µs, structcheck: 20.106µs 
INFO [runner] worker.4 took 405.213µs with stages: ineffassign: 365.296µs, govet: 12.664µs 
main.go:1: /home/isaev/go/src/gopkg.in/kothar/brotli-go.v0/enc/backward_references.cc:9:1: illegal character U+0023 '#' (typecheck)
package main
INFO [runner] worker.8 took 236.518326ms with stages: megacheck: 236.509499ms 
INFO [runner] Workers idle times: #1: 236.318923ms, #2: 236.248691ms, #3: 236.323475ms, #4: 236.128353ms, #5: 236.281168ms, #6: 236.327591ms, #7: 236.354175ms 
INFO [runner] Issues before processing: 2, after processing: 1 
INFO [runner] processing took 374.161µs with stages: identifier_marker: 159.691µs, exclude: 116.6µs, source_code: 28.743µs, cgo: 16.878µs, path_prettifier: 14.418µs, skip_dirs: 13.585µs, nolint: 11.939µs, max_same_issues: 2.148µs, replacement_builder: 2.061µs, uniq_by_line: 1.965µs, path_shortener: 1.462µs, diff: 1.307µs, max_per_file_from_linter: 1.043µs, max_from_linter: 960ns, autogenerated_exclude: 802ns, skip_files: 374ns, exclude-rules: 185ns 
INFO Memory: 11 samples, avg is 130.4MB, max is 204.5MB 
INFO Execution took 1.05068674s
@jirfag
Copy link
Member

jirfag commented Mar 17, 2019

thank you!
closing it as #438 was merged

@jirfag jirfag closed this as completed Mar 17, 2019
bkrebsbach pushed a commit to asecurityteam/sdcli that referenced this issue May 3, 2019
…nings

The latest version of the sdcli container throws a warning due to compilation
errors when running the `sdcli go lint` command. Here's an example:

```bash
docker run -ti \
        --mount src="/Users/bkrebsbach/work/code/go/src/github.com/asecurityteam/nexpose-asset-attributor",target="/go/src/github.com/asecurityteam/nexpose-asset-attributor",type="bind" \
        -w "/go/src/github.com/asecurityteam/nexpose-asset-attributor" \
        asecurityteam/sdcli:v1 go lint
WARN [runner/megacheck] Can't run megacheck because of compilation errors in packages [github.com/asecurityteam/nexpose-asset-attributor/pkg/domain github.com/asecurityteam/nexpose-asset-attributor github.com/asecurityteam/nexpose-asset-attributor/pkg/assetattributor [github.com/asecurityteam/nexpose-asset-attributor/pkg/assetattributor.test] github.com/asecurityteam/nexpose-asset-attributor/pkg/handlers/v1 [github.com/asecurityteam/nexpose-asset-attributor/pkg/handlers/v1.test]]: pkg/domain/alias.go:1: /usr/local/go/src/internal/bytealg/compare_amd64.s:5:1: illegal character U+0023 '#' and 130 more errors: run `golangci-lint run --no-config --disable-all -E typecheck` to see all errors
```

This appears to be a result of golangci/golangci-lint#433, which was fixed in golangci-lint v1.16.0.
bkrebsbach pushed a commit to asecurityteam/sdcli that referenced this issue May 3, 2019
…nings

The latest version of the sdcli container throws a warning due to compilation
errors when running the `sdcli go lint` command. Here's an example:

```bash
docker run -ti \
        --mount src="/Users/bkrebsbach/work/code/go/src/github.com/asecurityteam/nexpose-asset-attributor",target="/go/src/github.com/asecurityteam/nexpose-asset-attributor",type="bind" \
        -w "/go/src/github.com/asecurityteam/nexpose-asset-attributor" \
        asecurityteam/sdcli:v1 go lint
WARN [runner/megacheck] Can't run megacheck because of compilation errors in packages [github.com/asecurityteam/nexpose-asset-attributor/pkg/domain github.com/asecurityteam/nexpose-asset-attributor github.com/asecurityteam/nexpose-asset-attributor/pkg/assetattributor [github.com/asecurityteam/nexpose-asset-attributor/pkg/assetattributor.test] github.com/asecurityteam/nexpose-asset-attributor/pkg/handlers/v1 [github.com/asecurityteam/nexpose-asset-attributor/pkg/handlers/v1.test]]: pkg/domain/alias.go:1: /usr/local/go/src/internal/bytealg/compare_amd64.s:5:1: illegal character U+0023 '#' and 130 more errors: run `golangci-lint run --no-config --disable-all -E typecheck` to see all errors
```

This appears to be a result of golangci/golangci-lint#433, which was fixed in golangci-lint v1.16.0.
bkrebsbach pushed a commit to asecurityteam/sdcli that referenced this issue May 6, 2019
* Update golanci-lint version in container to fix compilation error warnings

The latest version of the sdcli container throws a warning due to compilation
errors when running the `sdcli go lint` command. Here's an example:

```bash
docker run -ti \
        --mount src="/Users/bkrebsbach/work/code/go/src/github.com/asecurityteam/nexpose-asset-attributor",target="/go/src/github.com/asecurityteam/nexpose-asset-attributor",type="bind" \
        -w "/go/src/github.com/asecurityteam/nexpose-asset-attributor" \
        asecurityteam/sdcli:v1 go lint
WARN [runner/megacheck] Can't run megacheck because of compilation errors in packages [github.com/asecurityteam/nexpose-asset-attributor/pkg/domain github.com/asecurityteam/nexpose-asset-attributor github.com/asecurityteam/nexpose-asset-attributor/pkg/assetattributor [github.com/asecurityteam/nexpose-asset-attributor/pkg/assetattributor.test] github.com/asecurityteam/nexpose-asset-attributor/pkg/handlers/v1 [github.com/asecurityteam/nexpose-asset-attributor/pkg/handlers/v1.test]]: pkg/domain/alias.go:1: /usr/local/go/src/internal/bytealg/compare_amd64.s:5:1: illegal character U+0023 '#' and 130 more errors: run `golangci-lint run --no-config --disable-all -E typecheck` to see all errors
```

This appears to be a result of golangci/golangci-lint#433, which was fixed in golangci-lint v1.16.0.

* Add go1.12.x to Travis builds

* Replace system-provided pip package with download from pypa.io
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants