ruff icon indicating copy to clipboard operation
ruff copied to clipboard

CLI: Show `--fix`ed and fixable issues too?

Open akx opened this issue 2 years ago • 5 comments

I think it would be useful if the CLI listed the things it --fixes, or can fix; right now you get something like

Found 8 error(s).
1 potentially fixable with the --fix option.

and if you run --fix, you'll get one error less and need look at the changes that have been applied and then figure out why. Instead, I think it'd be nicer if the flow was

$ ruff .
file.py:2:9: NOM001 Ran out of pancakes in `__init__` (fixable)
Found 1 error(s).
1 potentially fixable with the --fix option.
$ ruff --fix .
file.py:2:9: NOM001 Ran out of pancakes in `__init__` (fixed)
Found 1 error(s).
1 fixed with the --fix option.
$

akx avatar Jan 25 '23 07:01 akx

I disagree ... I think it's better to follow the "rule of silence" from the Unix philosophy (1,2):

When a program has nothing surprising to say, it should say nothing.

(Besides any self-respecting programmer uses version control and will be able to see the fixes in detail by doing e.g. a git diff.)

So I'd rather keep the current default behavior. However I'd be alright with showing this output when a --verbose flag is supplied ... however in order to do that we'd probably have to firstly rename our current --verbose flag to debug ... which would be more fitting anyway since it currently literally prints [DEBUG] messages that are completely uninteresting for regular users.

not-my-profile avatar Jan 25 '23 09:01 not-my-profile

I actually made a change in #1701, a while ago, to include the list of fixes in a slightly different format (just telling you how many violations were fixed in each file, closer to Black's output, where it tells you which files are reformatted). But I was worried it was too verbose and wanted to get more feedback before sending it out (so it was reverted in #1711).

charliermarsh avatar Jan 25 '23 12:01 charliermarsh

How about --show-fixes instead of --verbose?

akx avatar Jan 25 '23 12:01 akx

I don't think this is important enough to warrant a dedicated command-line flag ... every flag we add complicates the UI a bit and makes it harder to for the user to find the flags they're actually looking for.

not-my-profile avatar Jan 25 '23 13:01 not-my-profile

I just opened #2188 for the larger issue of -v being user-unfriendly.

not-my-profile avatar Jan 26 '23 06:01 not-my-profile

My 2cent: We call ruff --fix from pre-commit - I'd love to see a hint of what was changed to have a closer look. It is not always obvious when just a single line has new changes.

aberres avatar Feb 24 '23 19:02 aberres

The --show-fixes flag exists which helps with this a bit.

charliermarsh avatar Feb 24 '23 20:02 charliermarsh

Ah, great, thank you. This is close enough.

aberres avatar Feb 24 '23 20:02 aberres

Actually gonna close this because I think --show-fixes helped enough.

charliermarsh avatar Feb 24 '23 20:02 charliermarsh