jscpd icon indicating copy to clipboard operation
jscpd copied to clipboard

Sort output with respect to number of duplicate lines detected

Open JosephTLyons opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

Sorting the output with the items with the most amount of duplicate first would allow users to see where the biggest refactoring wins are at.

Describe the solution you'd like

Have a flag that enables sorting by number of duplicate lines detected, for each item found

JosephTLyons avatar Jan 29 '24 21:01 JosephTLyons

As I understand you are going to sort summary results with a list of languages.

kucherenko avatar Jan 30 '24 09:01 kucherenko

If you are using the HTML reporter you can order them with this bit of JavaScript, I know its not the ideal solution but it works well.

let elements = document.querySelectorAll('#txt-clones .py-4');
elements = Array.from(elements);
elements.sort((a, b) => b.textContent.length - a.textContent.length);
let parent = elements[0].parentNode;
elements.forEach(el => el.parentNode.removeChild(el));
elements.forEach(el => parent.appendChild(el));

Ivanca avatar Feb 02 '24 04:02 Ivanca

If you are using the HTML reporter you can order them with this bit of JavaScript, I know its not the ideal solution but it works well.

let elements = document.querySelectorAll('#txt-clones .py-4');
elements = Array.from(elements);
elements.sort((a, b) => b.textContent.length - a.textContent.length);
let parent = elements[0].parentNode;
elements.forEach(el => el.parentNode.removeChild(el));
elements.forEach(el => parent.appendChild(el));

it works, but is it porssible to add this as a feature ?

KingAmo avatar Feb 21 '24 05:02 KingAmo