Code duplication on different contexts is considered as duplication

  • 6.7.2 (build 37468)
  • Duplicated Lines on New Code (%)

Example code:

    public class User
    {
        public string Firstname;
        public string Surname;

        public string getFullname()
        {
           return computeFullName;
        }
    
        private string computeFullName()
        {
            return $"{Firstname} {Surname}";
        }
    }
    
    public class Car
    {
        public string Make { get; set; }
        public string Model { get; set; }

        public string getFullname()
        {
            return computeFullName;
        }
    
        private string computeFullName()
        {
            return $"{Make}/{Model}";
        }
    }

public string getFullname() is consiereded as duplicate, while making those two totally not related classes using common base class would be a mistake

Hello @Jakub_Pawlinski

Unfortunately currently there is no way to dismiss some particular duplication detected by SonarQube if you think it’s not relevant to you.
Still you can exclude some files from duplication consideration. To do so, go to Administration > General Settings > Analysis Scope > Duplications and set the Duplication Exclusions property.