Sonar Code Smell for unused code after merge

Must-share information (formatted with Markdown):
SonarQube 9.9 LTS Developer Edition
deployed via Docker
wish to have understanding of a code smell not showing up in branch but showing up once merged.
Scenario is as follows:
Repository is setup as follows:
Development branch is “main” branch and treats “new” code as since prior version.
Branches are compared against development branch to detect new code.

Event:
Branch was created, went through refactoring (deleting code, moving to new file,…), Cleaned of any smells
Branch was merged
Main Branch (Development) now has an unused constant as a code smell.

I want to know why it wasn’t detected in the branch prior to merge that the variable was dead/no longer in use.

Sometimes, if an issue doesn’t involve a changed line of code it can only be raised after the merge. So if you used a function somewhere… and stopped using it (but still had the function which hadn’t changed somewhere in your code)… the issue will only be raised on an analysis of the main branch. You can vote for this roadmap item here.

So because the refactoring was a large delete it didn’t get picked up as related to “new code” block and as a result passed over until an analysis of the main branch would execute?

The question ultimately lies in – is the line that the issue is now raised in the main branch a line that was changed (added/moved) in the PR?

The line was not changed (missed by the engineer as being an unused variable). So the code that referenced the unused variable was refactored to a new class.