"Source files should not have any duplicated blocks" for copyright comments


We are running SonarQube Developer Edition Version 7.7 (build 23042).
We are using the same copyright block at the beginning of each Java file:

 * Copyright 2019 by Example <info@example.com>
 * This software contains free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License ("License") as
 * published by the Free Software Foundation  (version 3 of the License).
 * This software is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * License you received along with this software for more details.


package com.example;

SonarQube detects a code duplication for each file:

Source files should not have any duplicated blocks

This seems to be a false-positive. I could deactivate the rule however I still want SonarQube to find “real” code duplications. How can I handle this issue?


I’m pretty sure headers and comments in general are excluded from CPD. Are you sure the duplicated blocks are referring to the header?

1 Like

Here is an example screenshot:

Is this consideres a bug or desired behavior?
Should my post be moved to another category such as “Report a bug”?


The issue is being reported on the file-level, not on the code at the top of the file. If you scroll down in that file, I bet you’ll find the duplicated mode (marked by a yellow background) that is triggering this issue.

Best regards,


1 Like

Hi Colin.

You are right. There is actually code in this file marked with the vertical bar (in gray, “Duplicated block”). Supprising to me is that the duplication points to a file in another project.
Is there a way to configure the analysis to a project scope?

Thanks! Tobias

You probably have “cross project duplication analysis” enabled either at the instance or project level. This can be switched off (and is also deprecated). Take a look in the General section of your project administration.

Thank you for the clarification. Indeed, “cross project duplication detection” is enabled.
I consider my issue as resolved now. Thanks to Julian and Colin for your support.