Our great sponsors
-
credo
A static code analysis tool for the Elixir language with a focus on code consistency and teaching.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
I've been doing elixir professionally for 6 years. I realize I'm in the minority, but as someone who _reads_ a lot of code, I feel that the strong emphasis (and in some cases, requirement) to extract functions seriously hurts readability.
Quickly glancing through this, I see the Complex Branching case as an example (https://github.com/lucasvegi/Elixir-Code-Smells#complex-bran...). It makes my brain need to act like the runtime, storing the stack of the current function in my head, jumping to the function call, then returning back to the original function and restoring the stack (to be clear, I'm not talking about the actual execution, I'm talking about what my brain goes through reading this).
In a complex codebase, the jumping can be far (physically and figuratively), especially since there's a strong preference for pattern matching in function parameters (so in the given example, there might be 4 `success_api_response/2`.
Inline code is _often_ easier to read and reason about, even when you aren't concerned about a function mutating a parameter (as in the case with elixir).
[Credo](https://hex.pm/packages/credo) comes with a nice set of default checks and it is straightforward to add your own.