simonsmith

simonsmith

Is there any tooling to autofix certain compiler warnings?

Hi,

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?

Most Liked

al2o3cr

al2o3cr

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.

axelson

axelson

Scenic Core Team

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 https://github.com/elixir-lsp/elixir-ls/ :slight_smile:

millllllz

millllllz

After seeing this post I obviously started writing something to do this. After toiling for several undisclosed units of time I realized the next link in my search was fix_warnings – fix_warnings v0.1.3 where someone had already done it inarguable better than I had attempted. It handles variables and aliases, check it out!

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New

We're in Beta

About us Mission Statement