Sonarcloud scanner breaks with an error on Javascript (regex)

  • ALM used (Azure DevOps)
  • CI system used (Azure DevOps)
  • Languages of the repository Javascript, C# .NET

[Include Custom.JS into Sonarcloud analysis]
We use a regex in our JavaScript code:


// First check for the pattern
if (!/^\d{1,2}[-./]\d{1,2}[-./]\d{4}$/.test(dateString)) {
return false;
}
// Parse the date parts to integers
var parts = dateString.split(/[-./]+/);
var day = parseInt(parts[0], 10);
var month = parseInt(parts[1], 10);
var year = parseInt(parts[2], 10);

Sonar Cloud scanner breaks with an error

##[error]ERROR: Failure during analysis
java.lang.IllegalArgumentException: 10 is not a valid line offset for pointer. File Src/custom.js

This is not the only regex in the JavaScript we use, but only this cause a failure in a scanner.

Once scanner fails, Azure pipelines will fail and forbid the release process.

Hey there!

Can you provide a complete self-contained file where you can reproduce the issue? Parsing errors are harder to reproduce with snippets of code.