christopheradams / elixir_style_guide

A community driven style guide for Elixir
4.36k stars 300 forks source link

Placement of defguard? #191

Closed fireproofsocks closed 4 years ago

fireproofsocks commented 4 years ago

Thanks for the thorough guide!

Is there a comment somewhere that would advise where to put defguard?

christopheradams commented 4 years ago

I would recommend putting any defguard right above the regular def functions, but after all of the module attributes, import directives, types, defstruct, etc.

Here's an example from the Integer module.

Also, because "Guards" are listed before "Functions" in the documentation, this feels like a natural placement order.

Should we add this to our Modules section?