Open spaceone opened 1 year ago
You're likely to end up with duplicates like that if there are multiple violations in a file. So you'd want another flag to avoid duplicate rows, or have ruff
deduplicate automatically, or use ruff --select E --error-format '{path}' | sort --unique
.
Also note that tabpagemax
is set to 10
by default, so you may want to up that when using -p
...
I kind of intentionally didn't do this because it felt like it'd add a good deal of complexity, and that in most cases these problems would be solvable by chaining different tools. E.g., in this case, couldn't you pipe the output, split at :
, and take everything before it to see the list of paths?
This would also be nice for formatting the output when using --statistics
.
...and that in most cases these problems would be solvable by chaining different tools.
True, this is possible, and you don't even need to fiddle splitting text strings:
ruff check --format=json . | jq --raw-output .[].filename | sort --unique
You're likely to end up with duplicates like that if there are multiple violations in a file. So you'd want another flag to avoid duplicate rows, or have
ruff
deduplicate automatically, or useruff --select E --error-format '{path}' | sort --unique
.
jeah, that's not something I expect ruff
to do.
Also note that
tabpagemax
is set to10
by default, so you may want to up that when using-p
...
yes, I have set tabpagemax=30 in vimrc.
Currently I am using vim -p $(ruff --select SIM115 --fix $files | sed -rne 's/:.*//gp')
.
So this feature would just allow me to not always write that much/complex.
FWIW, this will make Ruff even easier to drop in with VSCode's built-in flake8 integration, which fails bc VSCode sends --format "%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s"
to Ruff. Alternatively, one could just use the Ruff VSCode extension.
pylint format works with vim's quickfix (better than just opening file as this will also use location and error message)
nvim -q <(ruff check --output-format=pylint)
flake8 supports specifying the output format via an command line argument:
flake8 --format '%(path)s'
allowed specifiers are:
ruff could support
--error-format '{path}:{row}:{col} {code}: {text}
when--format=text
.This would allow me to easily open all files with specific violations in my editor (
vim -p $(ruff --select E --error-format '{path}')
)