rrrene / credo-proposals

Proposals for Credo, the Elixir code analysis tool with a focus on code consistency and teaching
MIT License
9 stars 0 forks source link

Credo does not detect IO.inspect calls in EEx templates #64

Open dabaer opened 3 years ago

dabaer commented 3 years ago

Environment

What were you trying to do?

Track down a confusing output in the terminal whilst testing. It turned out to be an errant IO.inspect call in one of my templates.

Expected outcome

For Credo to detect the IO.inspect call.

Actual outcome

Credo did not detect the IO.inspect call.

I am able to reproduce this with a stock phx.new project, by adding a call to IO.inspect in the page index template (or any template).

Is this supposed to be by design?

rrrene commented 3 years ago

The reason is simply that I have no idea how to parse .eex and .leex templates 😉

dabaer commented 3 years ago

Unfortunately that makes two of us 😅

I'll try and take a cursory peek into doing that, but likely it will happen after a major release at work here shortly.

rrrene commented 3 years ago

:+1:

My research got as far as EEx.SmartEngine , but I seem to recall that that would not give us an AST to work with.

kaikuchn commented 1 year ago

With Elixir 1.14.x there's now the EEx.tokenize/2 function.

I've used this to write a crude custom check that also handles elixir expressions in LiveView's sigil_H blocks.