...
Failure to minimize scope could result in less reliable, readable, and reusable code.
Recommendation | Severity | Likelihood |
|---|
Detectable | Repairable | Priority | Level |
|---|---|---|---|
DCL19-C | Low | Unlikely | Yes |
Yes |
P3 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| local-object-scope global-object-scope | Partially checked | ||||||
| Axivion Bauhaus Suite |
| CertC-DCL19 | |||||||
| CodeSonar |
| LANG.STRUCT.SCOPE.FILE | Scope could be file static | ||||||
| CC2.DCL19 | Fully implemented | |||||||
| Helix QAC |
| C1504, C1505, C1531, C1532, C3210, C3218 | |||||||
| Klocwork |
| MISRA.VAR.MIN.VIS | |||||||
| LDRA tool suite |
| 25 D, 61 D, 40 S | Fully implemented | ||||||
| Parasoft C/C++test |
| CERT_C-DCL19-a | Declare variables as locally as possible | |||||||
| PC-lint Plus |
| 765, 9003 | Partially supported | ||||||
| Polyspace Bug Finder |
| Checks for:
Rec. partially covered. | |||||||
| PVS-Studio |
| V821 | |||||||
| RuleChecker |
| local-object-scope global-object-scope | Partially checked |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
| SEI CERT C++ Coding Standard | VOID DCL07-CPP. Minimize the scope of variables and methods |
| MISRA C:2012 | Rule 8.9 (advisory) |
...
...