0

A large portion of our code is based on a template, because of this sonar scanner falsely reports that code as having too many duplications.

I know it's only a warning, but it fills our Jenkins pipeline logs with warnings, we'll never fix, to the extent that real issues get overlooked.

Following https://stackoverflow.com/a/52869313/1817610 I added sonar.cpd.exclusions=**/*.w to our scanner properties, but that does not eliminate the warnings.

The fragment of the log below shows 25 lines in the log for a single source, we have more than a thousand sources like that.

00:21:14  INFO: 3970/4255 - current file: X:/cce/build/develop/git/smartlisa/appl/src/erprap/fwkal-u.w
00:21:14  WARN: Too many duplication references on file src/erprap/fwkal-u.w for block at line 523. Keep only the first 100 references.
00:21:14  WARN: Too many duplication references on file src/erprap/fwkal-u.w for block at line 525. Keep only the first 100 references.
00:21:14  WARN: Too many duplication references on file src/erprap/fwkal-u.w for block at line 523. Keep only the first 100 references.
00:21:14  WARN: Too many duplication references on file src/erprap/fwkal-u.w for block at line 527. Keep only the first 100 references.
/// trimmed 20 similar lines
...
00:21:14  WARN: Too many duplication references on file src/erprap/fwkal-u.w for block at line 523. Keep only the first 100 references.

using SonarScanner 4.7.0.2747

carl verbiest
  • 1,113
  • 1
  • 15
  • 30

2 Answers2

0

I found a solution using the https://plugins.jenkins.io/log-file-filter/ plugin.

I added a filter to replace

.* WARN: Too many duplication references on file .*\n

with an empty string.

enter image description here

carl verbiest
  • 1,113
  • 1
  • 15
  • 30
-1

You had only to google for "WARN: Too many duplication references" to find: https://community.sonarsource.com/t/supress-ignore-warning-warn-too-many-duplication-references-on-file/27946 .

This tells you that you can't control that.

And to be frank, it isn't a "false" report. I understand where you're coming from, as I used to work on a project where we generated a lot of our application code. It's really not a good strategy. You'd be better off with an architecture where common code is inherited or composed, not duplicated.

David M. Karr
  • 14,317
  • 20
  • 94
  • 199