nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.56k stars 29.05k forks source link

readability/pointer is inaccurate #53955

Open RedYetiDev opened 1 month ago

RedYetiDev commented 1 month ago

In the CPP linting configuration, the regular expression designed to identify pointers on the right side (which are considered invalid) is:

[^=|(,\s><);&?:}](?<!(sizeof|return))\s\*[a-zA-Z_][0-9a-zA-Z_]*

However, this case can occur:

#ifdef DEBUG
    bool consistency_check = false;
    isolate()->RequestInterrupt([](Isolate*, void* data) {
      *static_cast<bool*>(data) = true;
    }, &consistency_check);
#endif
#ifdef DEBUG
    bool consistency_check = false;
    isolate()->RequestInterrupt(
        [](Isolate*, void* data) { *static_cast<bool*>(data) = true; },
        &consistency_check);
#endif

Although both snippets are functionally equivalent, the only difference is the formatting. The regex doesn't match the first snippet, but matches the second.

https://regex101.com/r/nGXdSj/2

RedYetiDev commented 1 month ago

CC @nodejs/linting