Skip to main content
ai-slop/cpp-null-literalmanual fix

NULL instead of nullptr.

The `NULL` macro in C++ code. It is an integer constant in disguise, so it can select the wrong overload where `nullptr` cannot.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

cpp-null-literal.cpp
✗ Flagged
Node* find(Node* head, int key) {
    for (Node* node = head; node != NULL; node = node->next) {
        if (node->key == key) return node;
    }
    return NULL;
}
Why this trips

Deterministic line match: flags the `NULL` token in C++ files, outside comments and strings.

cpp-null-literal.cpp
✓ Clean
Node* find(Node* head, int key) {
    for (Node* node = head; node != nullptr; node = node->next) {
        if (node->key == key) return node;
    }
    return nullptr;
}
What changed

Use `nullptr`.

C and pre-C++11 examples use `NULL` everywhere, and agents carry it into modern C++.

How this rule is justified.

Rule id

ai-slop/cpp-null-literal

Enforcing engine

ai-slop

Detector strategy

Deterministic line match: flags the `NULL` token in C++ files, outside comments and strings.

Legitimate code that is NOT flagged

`.c` and `.h` files, `nullptr`, and identifiers that merely contain NULL are not flagged.

Evidence

Part of aislop's C/C++ rule set. C/C++ support, including C/C++-specific AI-slop rules, arrived in aislop v0.14.1.