You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rule should not suggest using Regex.exec if the returned value of String.match is eventually used to get the number of matches. It only involves getting the .length of the value, while a loop is needed in the case of Regex.exec.
constregex=newRegExp(pattern);constmatches='foo'.match(regex);// Currently false positive, should be compliant/* ... */matches.length;/* or */matches?.length;
The text was updated successfully, but these errors were encountered:
yassin-kammoun-sonarsource
changed the title
Fix FP S6594 (sonar-prefer-regexp-exec): Ignore match count use case and global RegExp instances
Fix FP S6594 (sonar-prefer-regexp-exec): Ignore match count use case
Jan 31, 2024
The rule should not suggest using
Regex.exec
if the returned value ofString.match
is eventually used to get the number of matches. It only involves getting the.length
of the value, while a loop is needed in the case ofRegex.exec
.The text was updated successfully, but these errors were encountered: