Skip to content

empty-critical-section

Detect adjacent lock and unlock calls.

Updated View as Markdown

Default severity: warning

A lock immediately followed by its matching unlock protects no work and is commonly a missing defer. Intentional empty critical sections used for synchronization should be documented and suppressed explicitly.

Bad

mutex.Lock()
mutex.Unlock()

Good

mutex.Lock()
defer mutex.Unlock()
Navigation

Type to search…

↑↓ navigate↵ selectEsc close