The RAII idiom associates the lifetime of a resource with the lifetime of an object: The resource is acquired when the object is created, and
released when it is destroyed.
If the object that controls the resource lifetime is a temporary, chances are it will get destroyed while the resource should still be in use,
leading to resource corruption. This rule detects temporaries that look like RAII objects.
Noncompliant code example
void f() {
scoped_lock{myMutex}; // Noncompliant. The mutex will be locked then immediately unlocked
protectedCode(); // This code is not protected by the mutex
}
Compliant solution
void f() {
scoped_lock lock{myMutex}; // Compliant
protectedCode();
// The mutex is correctly released at this point
}