Hi,
We came across an issue when duplicated code has not been detected by SonarCloud as we would initially expect. For example, we have two files to this email that have most of the code the same with the difference in function names only:
File 1 - contents1.ts:
export const PiNearbyTitleContainer = styled.View display: flex; flex-direction: row; align-items: center; justify-content: space-between;
;
export const PiNearbySortOptionContainer2 = styled.View background-color: ${colors.WHITE}; padding: 16px;
;
File 2 - contents2.ts:
export const PiNearbyTitleContainer = styled.View display: flex; flex-direction: row; align-items: center; justify-content: space-between;
;
export const PiNearbySortOptionContainer = styled.View background-color: ${colors.WHITE}; padding: 16px;
;
The SonarCloud report shows 0.0% of duplicated code in this case, although the files contain several identical functions. As soon as I make the function names identical, SonarCloud detects duplicated code.
Currently we don’t really have any specific configuration for code duplication in SonarCloud. Is there a specific way to configure SonarCloud for a project to detect duplicated code more precisely and avoid cases when a method name change in a sourcecode file significantly impacts the discovered duplicated code percentage?