golangci / golangci-lint

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

Branch analysis not working when default severity is mentioned #4835

Closed Vishal1297 closed 3 months ago

Vishal1297 commented 3 months ago

Welcome

Description of the problem

Hi,

I am trying golangici-lint after a long time on a sample code in pushed to a branch. After adding the code, I tried running the golangci-lint but it fails to report issues when I mention default severity.

Version of golangci-lint

```console $ golangci-lint --version # golangci-lint has version 1.59.1 built with go1.22.3 from 1a55854a on 2024-06-09T18:08:33Z ```

Configuration

```console run: timeout: 5m issues-exit-code: 0 modules-download-mode: readonly tests: false linters: disable-all: true enable: - errcheck - gosimple - govet - ineffassign - staticcheck - unused issues: exclude-use-default: true exclude-dirs-use-default: true new: true severity: default-severity: "error" output: formats: - format: colored-line-number path: stderr - format: checkstyle path: report.xml ```

Go environment

```console $ go version && go env go version go1.21.1 linux/amd64 ```

Verbose output of running

```console $ golangci-lint cache clean $ golangci-lint run -v INFO golangci-lint has version 1.59.1 built with go1.22.3 from 1a55854a on 2024-06-09T18:08:33Z INFO [config_reader] Config search paths: [./ /home/vishal/DEV/OpenSource/graphql-go /home/vishal/DEV/OpenSource /home/vishal/DEV /home/vishal /home /] INFO [config_reader] Used config file .golangci.yml INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] INFO [loader] Go packages loading at mode 575 (exports_file|types_sizes|compiled_files|deps|files|imports|name) took 258.700206ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 8.573195ms INFO [linters_context/goanalysis] analyzers took 0s with no stages INFO [runner] Issues before processing: 18, after processing: 0 INFO [runner] Processors filtering stat (out/in): nolint: 13/18, skip_dirs: 18/18, skip_files: 18/18, identifier_marker: 18/18, exclude-rules: 18/18, uniq_by_line: 12/13, filename_unadjuster: 18/18, invalid_issue: 18/18, path_prettifier: 18/18, exclude: 18/18, cgo: 18/18, diff: 0/12, autogenerated_exclude: 18/18 INFO [runner] processing took 10.550511ms with stages: diff: 7.569925ms, nolint: 1.829367ms, exclude-rules: 458.25µs, identifier_marker: 253.113µs, path_prettifier: 171.827µs, autogenerated_exclude: 156.878µs, skip_dirs: 96.037µs, uniq_by_line: 3.614µs, cgo: 3.272µs, invalid_issue: 2.56µs, max_same_issues: 1.446µs, filename_unadjuster: 912ns, max_per_file_from_linter: 538ns, fixer: 421ns, max_from_linter: 421ns, skip_files: 356ns, sort_results: 350ns, path_shortener: 309ns, severity-rules: 258ns, source_code: 258ns, exclude: 237ns, path_prefixer: 162ns INFO [runner] linters took 108.358104ms with stages: goanalysis_metalinter: 97.665948ms INFO File cache stats: 0 entries of total size 0B INFO Memory: 5 samples, avg is 35.2MB, max is 50.6MB INFO Execution took 380.1793ms ```

A minimal reproducible example or link to a public repository

https://github.com/Vishal1297/graphql-go/tree/vishal/try-golangci-lint

Validation

Supporter

boring-cyborg[bot] commented 3 months ago

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

ldez commented 3 months ago

Hello,

It's not related to the severity but to the option issues.new.

issues:
  new: true

This option hides the reports that are already known. This is the expected behavior.

$ docker run --rm -it golang:1.21-alpine sh
/go # apk add -q git curl
/go # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
golangci/golangci-lint info checking GitHub for tag 'v1.59.1'
golangci/golangci-lint info found version: 1.59.1 for v1.59.1/linux/amd64
golangci/golangci-lint info installed /go/bin/golangci-lint
/go # git clone --quiet https://github.com/Vishal1297/graphql-go.git
/go # cd graphql-go
/go/graphql-go # git switch vishal/try-golangci-lint
branch 'vishal/try-golangci-lint' set up to track 'origin/vishal/try-golangci-lint'.
Switched to a new branch 'vishal/try-golangci-lint'
/go/graphql-go # golangci-lint run
main.go:6:8: Error return value is not checked (errcheck)
        myFunc()
              ^
main.go:5:6: func `main` is unused (unused)
func main() {
     ^
main.go:9:6: func `myFunc` is unused (unused)
func myFunc() error {
     ^
main.go:13:6: func `call` is unused (unused)
func call() error {
     ^
/go/graphql-go # golangci-lint run
/go/graphql-go # golangci-lint run
/go/graphql-go # golangci-lint run --new=false
main.go:6:8: Error return value is not checked (errcheck)
        myFunc()
              ^
main.go:5:6: func `main` is unused (unused)
func main() {
     ^
main.go:9:6: func `myFunc` is unused (unused)
func myFunc() error {
     ^
main.go:13:6: func `call` is unused (unused)
func call() error {
     ^
example/enum/main.go:53:77: Error return value of `w.Write` is not checked (errcheck)
        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write(page) })
                                                                                   ^
example/caching/server/server.go:22:10: Error return value of `w.Write` is not checked (errcheck)
                w.Write(page)
                       ^
example/caching/server/server.go:60:9: Error return value of `w.Write` is not checked (errcheck)
        w.Write(responseJSON)
               ^
/go/graphql-go #