Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
Examples of errors detected by the...

Examples of errors detected by the V7016 diagnostic

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


Visual Studio Code

V7016 Suspicious access to an element of the 'diffs' object by a constant index inside a loop. notebookViewModelImpl.ts 252


....
const diffs = changes.map(splice => {
    return [splice[0], splice[1], splice[2].map(....)]
             as [number, number, CellViewModel[]];
});
....
for (let i = 0; i < diffs.length; i++) {
  const diff = diffs[0];                                   // <=
  if (diff[0] + diff[1] <= primarySelectionIndex) {
    delta += diff[2].length - diff[1];
    continue;
  }
  if (diff[0] > primarySelectionIndex) {
    endSelectionHandles = [primaryHandle];
    break;
  }
  if (diff[0] + diff[1] > primarySelectionIndex) {
    endSelectionHandles = [this._viewCells[diff[0] + delta].handle];
    break;
  }
}
....