Back to all reviewers

Standardize null pointer checks

nodejs/node
Based on 5 comments
Other

Always use standard null-checking patterns like CHECK_NOT_NULL for pointer validation instead of manual null checks. This ensures consistent error handling and improves code readability. For functions that may return null objects, consider using wrapper types like MaybeLocal to properly propagate null states.

Null Handling Other

Reviewer Prompt

Always use standard null-checking patterns like CHECK_NOT_NULL for pointer validation instead of manual null checks. This ensures consistent error handling and improves code readability. For functions that may return null objects, consider using wrapper types like MaybeLocal to properly propagate null states.

Example:

// Incorrect - manual null check
if (network_resource_manager_ == nullptr) {
  return protocol::DispatchResponse::ServerError("...");
}

// Correct - using standard macro
CHECK_NOT_NULL(network_resource_manager_);

// Correct - using MaybeLocal for nullable returns
MaybeLocal<Object> CreateObject(Isolate* isolate) {
  if (some_condition) return MaybeLocal<Object>();  // Return empty handle
  return Object::New(isolate);
}
5
Comments Analyzed
Other
Primary Language
Null Handling
Category

Source Discussions