Single-Function Pipelines: A Song

Posted on: 2024-01-29

For a long time at work, our team included Credo.Check.Readability.SinglePipe in our Credo checks. It enforces this rule:

Use a function call when a pipeline is only one function long

I didn't like that; I'd rather use my own judgment there. I especially saw issues when allow_functions: true wasn't set to allow 0-arity functions, or when piping the result of an Ecto query to something like Repo.all.

Thankfully, this rule has been removed from the default Credo rules. Our team noticed and stopped using it.

But not before I made a song.

I don't like to brag, but this will probably be among the top 10 songs about Elixir code formatting you'll hear today.

The lyrics:

I'm just a boy who loves to pipeline even just one function long It hurts so bad to break the pipeline and that is why I made this song A function call may soon be many or maybe not, but who can say? Two different steps should be a pipeline For me it is the only way