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

Feature: Add option to sort suggestions by file and line #104

Open
eksperimental opened this issue Nov 24, 2024 · 5 comments
Open

Feature: Add option to sort suggestions by file and line #104

eksperimental opened this issue Nov 24, 2024 · 5 comments

Comments

@eksperimental
Copy link

What do you want Credo to do?

I would like to have an option via command line and config file to return a the list of suggestions within each group sorted by file paths and line number, alternatively the line number could be descending.

My use case is that when I introduce Credo to an Existing project, a really long list is generated. My way of fixing it is start working from the last one in the file, this ways changes at the bottom of the file does not affect the line numbers above and I can still reference to them without having to run mix credo again. That's why it would be useful to be able to sort line numbers descending.

Having files sorted by path also help me start and finish one file, as of now, they are scattered around, I guess sorted by priority.

@rrrene
Copy link
Owner

rrrene commented Nov 26, 2024

I like this.

An early idea would be to have a config switch like this:

      sort_by: [
        {:filename, :asc},
        {:line, :desc},
        {:priority, :desc}
      ],

and a command-line switch

$ mix credo --sort-by filename:asc,line:desc,priority:desc

WDYT?

@eksperimental
Copy link
Author

Looks awesome. So we could pass the three of them, and in any order.

So if i wanted to order by priority and then by file name and line it would be like this?

mix credo --sort-by priority:desc,filename:asc,line:desc

@rrrene
Copy link
Owner

rrrene commented Nov 28, 2024

I could imagine a list like this:

filename
line
column
priority
severity
category
check
check_id

I have a rough draft and should be able to push a branch for further discussion soon.

@eksperimental
Copy link
Author

That's OK with me. filename should be renamed as filepath or path IMO.

What would be the difference between check and check_id?+

@rrrene
Copy link
Owner

rrrene commented Nov 29, 2024

We can for sure also think about aliasing things like line and line_no 👍

check would be the Check Module and check_id the check's ID (a feature that was introduced in Credo 1.7).

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

2 participants