From a2f211d19f4cdb741c6821f07674850454d4324c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 20 Sep 2026 16:51:52 +0200 Subject: [PATCH] man/checkers/variableScope.md: rewrite description and motivation --- man/checkers/variableScope.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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