SonarCloud flags properties of objects in an array as duplicate code on initialization

  • ALM used - GitHub
  • CI system used - Circle CI
  • Scanner command used when applicable (private details masked)
  • Languages of the repository - Typescript
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting) :
    SonarCloud marks the bit of code below as containing duplications:
  content: [
    {
      label: "Alleged Abuse",
      isActive: true,
      icon: "stop-violence.png",
    },
    {
      label: "Behaviour Issue",
      isActive: false,
      icon: "dermatology.png",
    },
    {
      label: "Choking",
      isActive: false,
      icon: "choking.png",
    },
    {
      label: "Equipment",
      isActive: false,
      icon: "medical-equipment.png",
    },
    {
      label: "Fall",
      isActive: false,
      icon: "falling-warning.png",
    },
    {
      label: "Medication Incident",
      isActive: false,
      icon: "medicine.png",
    },
    {
      label: "Skin Issue",
      isActive: false,
      icon: "dermatology.png",
    },
    {
      label: "Death",
      isActive: false,
      icon: "cardiogram.png",
    },
    {
      label: "Property management",
      isActive: false,
      icon: "property.png",
    },
    {
      label: "Elopement",
      isActive: false,
      icon: "",
    },
  ],
};

I have no workarounds for creating an array of objects and would like to resolve it without having to create exclusions, as suggested by the only other reference to this problem I’ve found online so far, linked here: Duplicate scanner falsely marks object array entries as dupes

  • Steps to reproduce
  • Potential workaround

Hey there.

Given how SonarCloud calculates duplication today… unfortunately, an exclusion is your only option. Can you tell us why you don’t want to create an exclusion?

Right now, duplication detection is a topic of internal discussion, but not much more to share at this time.

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