Skip to content

Suggested Edits from Linters do not get printed #2134

Closed
@ifaisalalam

Description

@ifaisalalam

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. (https://golangci-lint.run/usage/linters/)

Description of the problem

I have enabled the fieldalignment analyzer in govet linter.

It only prints the message on running golangci-lint run and does not print the suggested edit.

Actual output:

$ golangci-lint run
query/query.go:23:12: fieldalignment: struct with 80 pointer bytes could be 64 (govet)
type query struct {

Expected output:

$ golangci-lint run
query/query.go:23:12: fieldalignment: struct with 80 pointer bytes could be 64

    ```
struct {
        validator Validator
        filter    map[string]interface{}
        context   map[string]interface{}
        relations map[string]Query
        Name      string
        fields    []string
}
``` (govet)
type query struct {

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.41.1 built from a207480 on 2021-06-19T21:15:29Z

Configuration file

$ cat .golangci.yaml
# Refer to golangci-lint's example config file for more options and information:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml

run:
  timeout: 5m
  modules-download-mode: readonly

linters:
  disable-all: true
  enable:
    - deadcode
    - errcheck
    - goimports
    - revive
    - govet
    - gosimple
    - ineffassign
    - structcheck
    - staticcheck

linters-settings:
  revive:
    ignore-generated-header: true
    severity: warning
    rules:
      - name: atomic
      - name: line-length-limit
        severity: error
        arguments: [ 120 ]
      - name: indent-error-flow
      - name: exported
        disabled: true

  govet:
    check-shadowing: true
    enable-all: true

  goimports:
    # put imports beginning with prefix after 3rd-party packages;
    # it's a comma-separated list of prefixes
    local-prefixes: github.com/Unacademy/golang-core

issues:
  exclude-use-default: false
  max-issues-per-linter: 0
  max-same-issues: 0
  new: false
  fix: true

# output configuration options
output:
  # colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
  # default is "colored-line-number"
  format: colored-line-number

  # print lines of code with issue, default is true
  print-issued-lines: true

  # print linter name in the end of issue text, default is true
  print-linter-name: true

  # make issues output unique by line, default is true
  uniq-by-line: true

  # add a prefix to the output file references; default is no prefix
  path-prefix: ""

  # sorts results by: filepath, line and column
  sort-results: true

Go environment

$ go version && go env
go version go1.16.6 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/faisalalam/Library/Caches/go-build"
GOENV="/Users/faisalalam/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/faisalalam/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/faisalalam/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.6/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.6/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/faisalalam/Projects/awesomeProject/awesome-golang-project/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rq/zxvgzfz571jbggj49937clw80000gq/T/go-build1842288699=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/faisalalam/Projects/awesomeProject/awesome-golang-project /Users/faisalalam/Projects/awesomeProject /Users/faisalalam/Projects /Users/faisalalam /Users /] 
INFO [config_reader] Used config file .golangci.yaml 
INFO [lintersdb] Active 9 linters: [deadcode errcheck goimports gosimple govet ineffassign revive staticcheck structcheck] 
INFO [loader] Go packages loading at mode 575 (files|compiled_files|exports_file|imports|name|types_sizes|deps) took 484.567578ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.674233ms 
INFO [linters context/goanalysis] analyzers took 982.743746ms with top 10 stages: buildir: 165.056101ms, buildssa: 148.963479ms, goimports: 35.261444ms, the_only_name: 29.883768ms, cgocall: 18.661757ms, fact_deprecated: 18.037046ms, unusedresult: 16.696724ms, findcall: 16.383728ms, printf: 15.776863ms, structcheck: 13.43742ms 
INFO [runner] Issues before processing: 2, after processing: 1 
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 2/2, path_shortener: 1/1, cgo: 2/2, uniq_by_line: 1/1, diff: 1/1, max_per_file_from_linter: 1/1, path_prettifier: 2/2, skip_dirs: 2/2, autogenerated_exclude: 2/2, exclude: 2/2, exclude-rules: 2/2, nolint: 1/2, max_same_issues: 1/1, max_from_linter: 1/1, severity-rules: 1/1, skip_files: 2/2, identifier_marker: 2/2, source_code: 1/1, path_prefixer: 1/1, sort_results: 1/1 
INFO [runner] processing took 644.793µs with stages: nolint: 370.323µs, path_prettifier: 92.178µs, autogenerated_exclude: 63.985µs, identifier_marker: 50.85µs, source_code: 40.997µs, skip_dirs: 17.253µs, cgo: 2.525µs, uniq_by_line: 2.099µs, path_shortener: 804ns, filename_unadjuster: 665ns, sort_results: 526ns, max_per_file_from_linter: 474ns, max_same_issues: 338ns, max_from_linter: 326ns, diff: 295ns, exclude-rules: 284ns, skip_files: 271ns, exclude: 257ns, severity-rules: 216ns, path_prefixer: 127ns 
INFO [runner] linters took 450.5344ms with stages: goanalysis_metalinter: 449.742351ms 
INFO fixer took 0s with no stages                 
query/query.go:23:12: fieldalignment: struct with 80 pointer bytes could be 64 (govet)
type query struct {
           ^
INFO File cache stats: 1 entries of total size 4.7KiB 
INFO Memory: 11 samples, avg is 127.0MB, max is 272.3MB 
INFO Execution took 952.550114ms  

Code example or link to a public repository

type query struct {
	filter    map[string]interface{}
	Name      string
	context   map[string]interface{}
	relations map[string]Query
	fields    []string
	validator Validator
}

type Query interface {
	AddFilter(map[string]interface{}) Query
	WithContext(map[string]interface{}) Query
	AddFields(...string) Query
	IncludeRelations(...Query) Query
	Build() (interface{}, error)
}

type Validator interface {
	ValidateFilter(map[string]interface{}) error
	ValidateFields(...string) error
	ValidateRelations(...string) error
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions