Our website uses cookies to enhance your browsing experience.
Accept
to the top

Webinar: Let's make a programming language. Lexer - 29.04

>
>
>
V7016. Suspicious access to a...
menu mobile close menu
Additional information
toggle menu Contents

V7016. Suspicious access to a collection element by a constant index inside a loop.

Apr 03 2026

The analyzer has detected that the code accesses the same collection element on every iteration of a for loop using a constant index.

The example:

let sum = 0;
for (let i = 0; i < arr.length; i++) {
  sum += arr[0];          // <=
}

In this case, it is intended to sum all elements of the array, but the index contains a typo. As a result, only the first array element is used, and the values of the other elements are ignored.

The fixed code:

let sum = 0;
for (let i = 0; i < arr.length; i++) {
  sum += arr[i];  
}