Skip to content

goanalysis_metalinter seems not to be able to handle time zones #3375

@KevinJCross

Description

@KevinJCross

Welcome

  • 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.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

while linting our codebase on a PR:
cloudfoundry/app-autoscaler-release#1086
The error seems to be on an unrelated code bit that has not changed.
From the erorr it seems like the timezone is not accounted for but we have been successfully linting this for a while.

ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go.orig\t2022-11-24 15:16:15\n+++ /app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go\t2022-11-24 15:16:15\n@@ -2,9 +2,10 @@\n package fakes\n \n import (\n+\t\"sync\"\n+\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsforwarder/forwarder\"\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models\"\n-\t\"sync\"\n )\n \n type FakeMetricForwarder struct {\n": can't parse patch: parsing time "2022-11-24 15:16:15" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from 8926a95f on 2022-10-22T10:50:47Z

Configuration file

$ cat .golangci.yml
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
---
linters-settings:
  depguard:
    list-type: blacklist
    packages:
      - github.com/alecthomas/assert
      - github.com/magiconair/properties/assert
    packages-with-error-message:
      - github.com/alecthomas/assert: "use github.com/stretchr/testify/assert"
      - github.com/magiconair/properties/assert: "use github.com/stretchr/testify/assert"
  dupl:
    threshold: 100
  exhaustive:
    default-signifies-exhaustive: false
  funlen:
    lines: 250
    statements: 150
  goconst:
    min-len: 3
    min-occurrences: 3
  gocognit:
    min-complexity: 15
  gocritic:
    enabled-tags:
      - diagnostic
      - experimental
      - opinionated
      - performance
      - style
    disabled-checks:
      - dupImport # https://github.com/go-critic/go-critic/issues/845
      - ifElseChain
      - octalLiteral
      - whyNoLint
      - wrapperFunc
  gocyclo:
    min-complexity: 30
  gomnd:
    settings:
      mnd:
        # don't include the "operation" and "assign"
        checks:
          - argument
          - case
          - condition
          - return
  govet:
    check-shadowing: true
  lll:
    line-length: 140
  maligned:
    suggest-new: true
  nolintlint:
    allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
    allow-unused: false # report any unused nolint directives
    require-explanation: false # don't require an explanation for nolint directives
    require-specific: false # don't require nolint directives to be specific about which linter is being skipped
  staticcheck:
    checks: ["all"]
  stylecheck:
    go: "1.15"
    # https://staticcheck.io/docs/options#checks
    checks: ["all", "-ST1003", "-ST1005"]
    dot-import-whitelist:
      - github.com/onsi/ginkgo/v2
      - github.com/onsi/gomega
      - github.com/onsi/gomega/gexec
    # https://staticcheck.io/docs/options#initialisms
    #initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS"]
    # https://staticcheck.io/docs/options#http_status_code_whitelist
    #http-status-code-whitelist: ["200", "400", "404", "500"]
linters:
  # please, do not use `enable-all`: it's deprecated and will be removed soon.
  # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
  disable-all: true
  enable:
    - asciicheck
    - bodyclose
    - depguard
    - dogsled
      #- dupl
    - errcheck
    - funlen
      #    - gocognit
      #    - goconst
      #    - gocyclo
    - gofmt
    - goimports
    - goprintffuncname
    - gosec
    - gosimple
      # - gomoddirectives - commented out to allow replace directives
    - gomodguard
    - ineffassign
    - misspell
    - nakedret
    - nolintlint
    - rowserrcheck
    - staticcheck
    - stylecheck
    - testpackage
    - typecheck
      #    - unconvert
      #    - unparam
    - unused
    - whitespace
      #    - godox
      #    - staticcheck
      #    - prealloc
issues:
  # Excluding configuration per-path, per-linter, per-text and per-source
  exclude-rules:
    - path: _test\.go
      linters:
        - dupl
        - gomnd
        - typecheck
  max-same-issues: 0
run:
  go: '1.19'

Go environment

$ go version && go env
go version go1.19.3 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kevincross/Library/Caches/go-build"
GOENV="/Users/kevincross/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kevincross/SAPDevelop/go/pkg/mod"
GONOPROXY="github.tools.sap"
GONOSUMDB="github.tools.sap"
GOOS="darwin"
GOPATH="/Users/kevincross/SAPDevelop/go"
GOPRIVATE="github.tools.sap"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/kevincross/SAPDevelop/.asdf/installs/golang/1.19.3/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/kevincross/SAPDevelop/.asdf/installs/golang/1.19.3/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xk/fqv769xd4r1b2zhv07dttg_m0000gn/T/go-build2333628043=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v

INFO [config_reader] Used config file ../../.golangci.yaml 
INFO [lintersdb] Active 23 linters: [asciicheck bodyclose depguard dogsled errcheck funlen gofmt goimports gomodguard goprintffuncname gosec gosimple ineffassign misspell nakedret nolintlint rowserrcheck staticcheck stylecheck testpackage typecheck unused whitespace] 
INFO [loader] Go packages loading at mode 575 (name|types_sizes|deps|imports|files|compiled_files|exports_file) took 4.461632641s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 62.542452ms 
INFO [linters_context/goanalysis] analyzers took 2m24.278301791s with top 10 stages: buildir: 19.454396676s, goimports: 11.015089144s, buildssa: 10.755394003s, fact_deprecated: 3.883148827s, S1038: 3.859892261s, nilness: 3.800664085s, gosec: 3.502604981s, typedness: 3.470936742s, fact_purity: 3.436012862s, gofmt: 3.401190906s 
WARN [runner] Can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go.orig\t2022-11-24 15:50:09\n+++ /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go\t2022-11-24 15:50:09\n@@ -2,9 +2,10 @@\n package fakes\n \n import (\n+\t\"sync\"\n+\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsforwarder/forwarder\"\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models\"\n-\t\"sync\"\n )\n \n type FakeMetricForwarder struct {\n": can't parse patch: parsing time "2022-11-24 15:50:09" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700" 
WARN [linters_context] rowserrcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. 
INFO [runner] processing took 8.345µs with stages: max_same_issues: 2.344µs, nolint: 2.122µs, max_from_linter: 1.955µs, skip_dirs: 326ns, max_per_file_from_linter: 170ns, cgo: 134ns, uniq_by_line: 132ns, filename_unadjuster: 131ns, path_prettifier: 129ns, skip_files: 129ns, exclude: 128ns, autogenerated_exclude: 124ns, path_shortener: 85ns, source_code: 64ns, identifier_marker: 63ns, sort_results: 63ns, diff: 62ns, exclude-rules: 62ns, severity-rules: 62ns, path_prefixer: 60ns 
INFO [runner] linters took 10.155204878s with stages: goanalysis_metalinter: 10.154955143s, rowserrcheck: 9.583µs 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goimports: can't extract issues from gofmt diff output "--- /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go.orig\t2022-11-24 15:50:09\n+++ /Users/kevincross/SAPDevelop/cf/app-autoscaler-release/src/autoscaler/fakes/fake_metric_forwarder.go\t2022-11-24 15:50:09\n@@ -2,9 +2,10 @@\n package fakes\n \n import (\n+\t\"sync\"\n+\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/metricsforwarder/forwarder\"\n \t\"code.cloudfoundry.org/app-autoscaler/src/autoscaler/models\"\n-\t\"sync\"\n )\n \n type FakeMetricForwarder struct {\n": can't parse patch: parsing time "2022-11-24 15:50:09" as "2006-01-02 15:04:05 -0700": cannot parse "" as "-0700"
 
INFO Memory: 149 samples, avg is 409.9MB, max is 885.5MB 
INFO Execution took 14.706869763s                 
make: *** [Makefile:255: lint_autoscaler] Error 3

Code example or link to a public repository

PR https://github.com/cloudfoundry/app-autoscaler-release/pull/1086 ```go // add your code here ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions