Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider Java v3.0 (sch jp)

Scope minimization helps to capture common programming errors, improves code readability by tying together the declaration and actual use and eases maintainability since unused variables are easily caught and removed.

...

Noncompliant Code Example

This non-compliant noncompliant example shows a variable that is declared outside the for loop. This can harm reusability since the loop index i will change after the for statement. Consider for instance, if this code snippet is copy pasted with the intent of using a different index j but the statement mistakenly still iterates over index i. Since i is still in scope, this will lead to a rather obtuse outcome.

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

SCP00-J

low

unlikely

medium

P??

P2

L3 L??

Automated Detection

TODO

Related Vulnerabilities

...