---
title: "empty-critical-section"
description: "Detect adjacent lock and unlock calls."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# empty-critical-section

**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

```go
mutex.Lock()
mutex.Unlock()
```

## Good

```go
mutex.Lock()
defer mutex.Unlock()
```

Source: https://strider.gempir.com/analyzers/empty-critical-section/index.mdx
