diff --git a/man/checkers/variableScope.md b/man/checkers/variableScope.md index 6a89c5e8748..1a0d82f93c3 100644 --- a/man/checkers/variableScope.md +++ b/man/checkers/variableScope.md @@ -1,19 +1,23 @@ # variableScope **Message**: The scope of the variable 'x' can be reduced.
-**Category**: Code Quality
+**Category**: Readability
**Severity**: Style
**Language**: C/C++ ## Description -A variable is declared in an outer scope than where it's actually used - narrowing its declaration to -the innermost block that needs it makes the code easier to follow. +A variable is declared in an outer scope, it can be declared in an inner scope. ## Motivation -A variable declared too early forces a reader to track its lifetime across code that doesn't use it, -and makes it unclear at a glance which block actually depends on it. +It is common practice, especially in C++ code, to declare variables in inner scope when +possible. + +The motivation is to make the code more readable. + +Opinions about what is more readable can differ so make your own decisions - these warnings +can be easily suppressed. ## How to fix