uber-go / nilaway

Static analysis tool to detect potential nil panics in Go code
Apache License 2.0
3.2k stars 66 forks source link

false positive cases #262

Closed madneal closed 4 months ago

madneal commented 5 months ago
func CreateTicketFromAlert(ticketItem *ticket.Ticket, alertItem *alert.Alert, currentUser string) {
    if alertItem == nil || ticketItem == nil {
        return
    }
    ticketItem.Entity = alertItem.Entity
    ticketItem.Severity = alertItem.Severity
    ticketItem.AlertID = alertItem.ID
    ticketItem.Detail = alertItem.Detail
    ticketItem.RiskType = alertItem.RiskType
    ticketItem.Source = "alert"

    if alertItem != nil {
biz/handler/api/ticket/ticket.go:202:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
        if alertItem != nil {
           ^
biz/handler/api/ticket/ticket.go:196:34: SA5011: possible nil pointer dereference (staticcheck)
        ticketItem.Severity = alertItem.Severity
                                        ^
biz/handler/api/ticket/ticket.go:197:33: SA5011: possible nil pointer dereference (staticcheck)
        ticketItem.AlertID = alertItem.ID

All these lints are false positive

yuxincs commented 4 months ago

Hmmm, are these lints generated by NilAway? It seems to be coming from staticcheck 🤔