llvm / llvm/llvm-project

[clang-tidy] Add check to flag use of early `return` or `continue` (readability-guard-clause)

Open
#168,599 6 comments 0 reactions 1 assignee Claimed by @vbvictor View on GitHub
check-request clang-tidy
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Code like this:
```cpp
void foo() {
// some processing

if (cond) {
// a lot of code
}
}
```
can be transformed to:
```cpp
void foo() {
// some processing

if (!cond)
return

// a lot of code
}
```

And code like this:
```cpp
while (...) {
if (cond) {
// a lot of code
}
}
```
can be transformed to:
```cpp
while (...) { // could be 'for' too
if (!cond)
continue
// a lot of code
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.