I get "javascript:S2189 'item' is not modified in this loop" even though I am modifying it

Please provide

  • Operating system: Ubuntu 22.04.1 LTS
  • SonarLint plugin version: v3.14.0
  • Programming language you’re coding in: JavaScript
  • Is connected mode used: no

And a thorough description of the problem / question:

item.promise = new Promise(async (resolve) => {
  while ('bar' in item) {
    const bar = item.bar
    delete item.bar
    await doBar(bar)
  delete item.promise

This code yields 'item' is not modified in this loop. sonarlint(javascript:S2189) even though item clearly is modified in the loop and bar is deleted from item. Is this a false positive? Am I missing something? How can I remove this warning?

Hi @vincesp Welcome, and thank you for your feedback.

You are right. This issue is a False-Positive because the rule ignores the delete operator. I created a ticket to fix this False-Positive.