Many duplicate blocks reported for requires in JavaScript files

Developer Edition Version 9.2.4

SonarQube is reporting lots of duplicate blocks for ‘require’ statements in .js files.
Is there a way to tell SQ to ignore requires statements when reporting duplicate blocks?

I searched through a bunch of Q&A both here and in StackOverflow and I read through the doc on “narrowing the focus” but I can’t find a way to apply the rule to the remainder of the files apart from the require statements.

I see that Import considered as duplicated lines in SonarQube reported a similar issue for import statements in typescript files and that a ticket was opened for that. Should a similar enhancement request be opened for this?
I would hope that a generic solution would be implemented. I am surprised that this is still a problem given the number of people who have hit the issue over the past number of years.

Adding a rider about how to ignore duplicate comments.
Each module begins with a common copyright header, followed by the require statements.
The copyright date must be updated when a module is edited and the copyright comment block is often part of a duplicate block, so the PR gets a high duplication score. This prevents the code duplication metric being used as a Quality Gates.

thanks, /Dave.

Hello David,

Thank you for your feedback. Indeed, as we did for import statements, it also makes sense to ignore JavaScript requires from duplication computation.

In that regard, I created the following ticket to address that as soon as possible.

Best regards,

Thank you.

FYI, I experimented with Ignore Issues in Blocks, adding a marker before/after the require block to tell SonarQube not to report any issues on those lines.
This works as far as stopping a code smell being reported on my PR, but SonarScanner results for the SQ scan (in my github PR) still includes the lines in its % Duplication summary, so I still cannot include the Duplicated Lines (%) in my Quality Gate.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.