I have a ScopedLock class which can help to release lock automatically when running out of scope.
However, the problem is: Sometimes team members write invalid
In C++17, a type can be marked [[nodiscard]], in which case a warning is encouraged for an expression that discards a value of that type (including by the case described here that resembles a declaration of a variable). In C++20, it can be applied to individual constructors as well if only some of them cause this sort of problem.