contextcheck
contextcheck copied to clipboard
Flagging non-buggy and legal code
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
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?
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
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.