Duplicated code notice, on first line of file

I have a strange issue where SC flags 26% of duplicated code density.
When I open the issue, it tells me on the first line of code (before even the opening <?php tag, even if in the file there is no line before that opening tag) that there are 2 Duplicated blocks of content that have to be removed).

There is literally no code on that line.

The following code (so from opening PHP tag onwards) are 2 blocks of comments.
One block is commenting the file purpose, then there is an empty line and then there is a comment explaining the class purpose that is registered in this file.

This is the practice I’ve learned and follow. Have a file comment (with @package and @since tags + a short explanation of what this file does/is) and a class or function comment, with a @since tag, and a comment of what the class or function does.

  1. Why is this flagged as duplicate code
  2. How can I find out what code is actually duplicated? SC does not tell me what precise code is duplicated, it just tells there is duplicate code on this line (even there is no code on that line)



That issue is raised at file level, which is why it’s showing up before the first line of code. If you scroll down in the file, you’ll see brown/grey marginal markers that indicate where the duplications are. Click on them to get more information.


1 Like

I’ve checked each and every “radioactive cog” marginal marker on that file and all I could find was Define a constant instead of duplicating this literal "my literal here" 8 times.

Could that be the “duplication” in question?


Here’s what you’re looking for:

Does that help?


Indeed, that same section says it is duplicated, by itself.
The section is a couple SQL Statements, which are not duplicates.
But I think that is related to the Define a constant instead of duplicating this literal "my literal here" 8 times. issue I have reported here: Define a constant instead of duplicating this literal "SQL STATEMENT" n times - #2 by Colin

So I will ignore it for now, since there is literally no duplication, it even states it is duplicated by line-to-line, which lines are the exact lines that make the statements, there is no duplication (of an entire block or single lines) just duplicated literals.

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