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

Flagging non-buggy and legal code #10

Open
bentcoder opened this issue Jan 28, 2023 · 3 comments
Open

Flagging non-buggy and legal code #10

bentcoder opened this issue Jan 28, 2023 · 3 comments

Comments

@bentcoder
Copy link

bentcoder commented Jan 28, 2023

Hi,

I don't understand why this code should be flagged. Any explanation or realistic reason would be appreciated for going deep to raise the flag.

Thanks

// github.com/go-chi/chi/v5
// parameter is set as normal using `"/{id}"`

func find(w http.ResponseWriter, r *http.Request) {
   id := chi.URLParam(r, "id")
}
Function `URLParam->URLParam` should pass the context parameter (contextcheck)
	id := chi.URLParam(r, "id")

Using:

  • golangci-lint has version 1.49.0
@kkHAIKE
Copy link
Owner

kkHAIKE commented Feb 4, 2023

I don't get similar output.

source:

package chitst

import (
  "net/http"
  "github.com/go-chi/chi/v5"
)

func find(w http.ResponseWriter, r *http.Request) {
   id := chi.URLParam(r, "id")
   _ = id
}

can you share the complete code?

@wawan93
Copy link

wawan93 commented Mar 6, 2024

I've got a similar issue: the linter tells me to pass context to the function without any parameters.

Function `Close[staff-transactions/internal/queries/pg.ReviseReportPaymentsRow]->Close->close[T]->close` should pass the context parameter (contextcheck) 
for rows.Next() {
	select {
	case <-ctx.Done():
		err = rows.Close() //nolint:contextcheck
		if err != nil {
			// ...
		}
		return
	default:
		// ...
	}
}

golangci-lint version v1.55.1

@kkHAIKE
Copy link
Owner

kkHAIKE commented Mar 10, 2024

I've got a similar issue: the linter tells me to pass context to the function without any parameters.

Function `Close[staff-transactions/internal/queries/pg.ReviseReportPaymentsRow]->Close->close[T]->close` should pass the context parameter (contextcheck) 
for rows.Next() {
	select {
	case <-ctx.Done():
		err = rows.Close() //nolint:contextcheck
		if err != nil {
			// ...
		}
		return
	default:
		// ...
	}
}

golangci-lint version v1.55.1

You can add //nolint:contextcheck in the comment of the Close method you specified for this case, please refer to README.md.

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

3 participants