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

Proposal: Check for Ecto Usage In Views #19

Open veverkap opened 7 years ago

veverkap commented 7 years ago

I would be interested in helping out to implement an optional check in credo to see if any calls to the database happen in the view. But I'd need a little pointer to get started.

rrrene commented 6 years ago

This is a great idea!

Unfortunately, I am not sure how we would go about paring EEX templates into an AST.

On top of that - as my super late reply shows - I don't have the time, at the moment, to investigate this further.

OvermindDL1 commented 6 years ago

Unfortunately, I am not sure how we would go about paring EEX templates into an AST.

Well as far as phoenix is concerned they get compiled into render/* functions inside the appropriate *View modules (gigantic IOList creation), and everywhere in the View modules should not have calls to ecto.

rrrene commented 6 years ago

@OvermindDL1 sure

The question would be: how does one get the AST without compiling the templates? This might be crucial since Credo is a static analysis tool.