autofix compiler warnings


Most of my compile warnings are things like unused variables which just need _ prepending to or unused functions, is there any tooling out there which will auto fix these on compile?

1 Like

I don’t think there’s a consistent “auto fix” for these; a lot of the time I find I get unused variable errors when I make a copy-paste error:

foo = some_operation()
bar = some_other_operation(foo)

{some_complicated_function_call(foo, ...), some_complicated_function_call(foo, ...)}

That last foo is supposed to be bar, but the expression was copied over and the change didn’t happen.

Changing bar to _bar will silence the warning, but that’s like taking the batteries out of the fire alarm because it keeps going off.

This is a surprisingly common class of error - the PVS-Studio team has some great write-ups and results from scanning big open-source codebases.


Not currently, but I do think that a quickfix for prepending _ would be helpful (especially for function arguments). Of course as @al2o3cr you wouldn’t always want to use the quickfix, but it is nice to have it if it was there. If you want to tackle it, it would make a great contribution to :slight_smile: