You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DESCRIPTION
Poorly formed nilness guards can be fatal as they might lead to unwanted panic because of nil pointer dereferences. Depending on the binary expression, the logic might not work as expected because of the poorly formed guards. In a binary expression, it is crucial to creating good nilness guards so that executing the other operand in the expression is safe.
BAD PRACTICE:
if cmd == nil && cmd.Execute() == 0 {
// do something
}
if cmd != nil || cmd.Execute() == 0 {
// do something
}
RECOMMENDED:
if cmd != nil && cmd.Execute() == 0 {
// do something
}
if cmd == nil || cmd.Execute() == 0 {
// do something
}
Problematic code to fix: /shentu/blob/master/app/export.go#L75-L75
The text was updated successfully, but these errors were encountered:
DESCRIPTION
Poorly formed nilness guards can be fatal as they might lead to unwanted panic because of nil pointer dereferences. Depending on the binary expression, the logic might not work as expected because of the poorly formed guards. In a binary expression, it is crucial to creating good nilness guards so that executing the other operand in the expression is safe.
BAD PRACTICE:
if cmd == nil && cmd.Execute() == 0 {
// do something
}
if cmd != nil || cmd.Execute() == 0 {
// do something
}
RECOMMENDED:
if cmd != nil && cmd.Execute() == 0 {
// do something
}
if cmd == nil || cmd.Execute() == 0 {
// do something
}
Problematic code to fix: /shentu/blob/master/app/export.go#L75-L75
The text was updated successfully, but these errors were encountered: