golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.65k stars 1.39k forks source link

ERRO Running error: context loading failed: no go files to analyze #4168

Closed aine-etke closed 1 year ago

aine-etke commented 1 year ago

Welcome

Description of the problem

Running golangci-lint run ./... inside the root of the https://gitlab.com/etke.cc/mrs/api project fails with the error:

ERRO Running error: context loading failed: no go files to analyze

Version of golangci-lint

```console $ golangci-lint --version golangci-lint has version 1.55.1 built with go1.21.3 from 9b20d49d on 2023-10-25T10:03:43Z ```

Configuration

```console run: concurrency: 4 timeout: 5m issues-exit-code: 1 tests: true build-tags: [] skip-dirs: [] skip-dirs-use-default: true skip-files: [] modules-download-mode: readonly allow-parallel-runners: false output: format: colored-line-number print-issued-lines: true print-linter-name: true uniq-by-line: true path-prefix: "" sort-results: true linters-settings: errcheck: check-blank: true gocognit: min-complexity: 15 nestif: min-complexity: 4 gocritic: enabled-tags: - performance gofumpt: lang-version: "1.18" gosimple: go: "1.18" checks: [ "all" ] govet: check-shadowing: true enable: - atomicalign - shadow misspell: locale: US staticcheck: go: "1.18" checks: [ "all" ] stylecheck: go: "1.18" unparam: check-exported: true unused: go: "1.18" gci: sections: - standard - default - prefix(gitlab.com/etke.cc/mrs/api) section-separators: - newLine linters: disable-all: false enable: - megacheck - govet - errcheck - gci - gocognit - nestif - gocritic - gofumpt - goimports - gosimple - govet - misspell - staticcheck - stylecheck - unparam - unused fast: false issues: exclude-rules: - path: _test\.go linters: - gocyclo - errcheck - dupl - gosec - linters: - staticcheck text: "SA9003:" - linters: - lll source: "^//go:generate " max-issues-per-linter: 0 max-same-issues: 0 new: false ```

Go environment

```console $ go version && go env go version go1.21.3 linux/amd64 GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/user/.cache/go-build' GOENV='/home/user/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/user/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/user/go' GOPRIVATE='' GOPROXY='direct' GOROOT='/usr/lib/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.21.3' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='gcc' CXX='g++' CGO_ENABLED='1' GOMOD='/home/user/projects/etke.cc/mrs/api/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3766158995=/tmp/go-build -gno-record-gcc-switches' ```

Verbose output of running

```console $ golangci-lint cache clean $ golangci-lint run -v INFO [config_reader] Config search paths: [./ /home/user/projects/etke.cc/mrs/api /home/user/projects/etke.cc/mrs /home/user/projects/etke.cc /home/user/projects /home/user /home /] INFO [config_reader] Used config file .golangci.yml INFO [lintersdb] Active 15 linters: [errcheck gci gocognit gocritic gofumpt goimports gosimple govet ineffassign misspell nestif staticcheck stylecheck unparam unused] INFO [loader] Go packages loading at mode 575 (types_sizes|deps|files|name|compiled_files|exports_file|imports) took 73.050549ms ERRO Running error: context loading failed: no go files to analyze INFO Memory: 2 samples, avg is 25.3MB, max is 27.3MB INFO Execution took 76.012364ms ```

A minimal reproducible example or link to a public repository

https://gitlab.com/etke.cc/mrs/api

Validation

aine-etke commented 1 year ago

distributive: Arch Linux golangci-lint was downloaded from binary releases

ldez commented 1 year ago

Hello,

you have to do a go mod tidy.

$ git clone git@gitlab.com:etke.cc/mrs/api.git
Cloning into 'api'...
remote: Enumerating objects: 4850, done.
remote: Counting objects: 100% (732/732), done.
remote: Compressing objects: 100% (634/634), done.
remote: Total 4850 (delta 123), reused 370 (delta 53), pack-reused 4118
Receiving objects: 100% (4850/4850), 128.67 MiB | 18.27 MiB/s, done.
Resolving deltas: 100% (1585/1585), done.
$ golangci-lint run ./...                                
ERRO Running error: context loading failed: no go files to analyze 
$ go mod tidy  
go: downloading github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16
$ golangci-lint run ./...
services/blocklist.go:7: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(gitlab.com/etke.cc/mrs/api) (gci)
        "gitlab.com/etke.cc/mrs/api/utils"
services/blocklist.go:8: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(gitlab.com/etke.cc/mrs/api) (gci)
        "golang.org/x/exp/slices"
services/cache.go:32:6: type `cacheBunny` is unused (unused)
type cacheBunny struct {
     ^
services/cache.go:105: File is not `gofumpt`-ed (gofumpt)

services/moderation.go:39:116: NewModeration - result 1 (error) is always nil (unparam)
func NewModeration(cfg ConfigService, data DataRepository, index IndexRepository, mail EmailService) (*Moderation, error) {
                                                                                                                   ^
services/moderation.go:87:10: Error return value of `url.Parse` is not checked (errcheck)
        apiURL, _ := url.Parse(m.cfg.Get().Public.API)
                ^
services/stats.go:226:6: func `getSymbol` is unused (unused)
func getSymbol[T Number](diff T) string {
     ^
services/stats.go:237:6: func `abs` is unused (unused)
func abs[T Number](number T) T {
     ^