Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort output with respect to number of duplicate lines detected #622

Open
JosephTLyons opened this issue Jan 29, 2024 · 3 comments
Open

Sort output with respect to number of duplicate lines detected #622

JosephTLyons opened this issue Jan 29, 2024 · 3 comments

Comments

@JosephTLyons
Copy link

JosephTLyons commented Jan 29, 2024

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

@kucherenko
Copy link
Owner

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

@Ivanca
Copy link

Ivanca commented Feb 2, 2024

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));

@KingAmo
Copy link

KingAmo commented Feb 21, 2024

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants