Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid piping into anonymous functions #2117

Merged
merged 2 commits into from
Jun 28, 2024
Merged

Conversation

anthonyshull
Copy link
Contributor

@anthonyshull anthonyshull requested a review from a team as a code owner June 26, 2024 18:27
@anthonyshull anthonyshull requested a review from kotva006 June 26, 2024 18:27
@anthonyshull anthonyshull force-pushed the ags/credo-pipe-anonymous branch from 1c0d981 to db44278 Compare June 26, 2024 18:29
@@ -24,7 +24,7 @@ defmodule Dotcom.Cache.KeyGenerator do
mod
|> Kernel.to_string()
|> String.split(".")
|> (fn [_ | tail] -> tail end).()
|> Kernel.then(fn [_ | tail] -> tail end)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like using then doesn't actually help what this credo check is for. The goal of the check is to improve readability and this doesn't make it better, just changes it. I think moving these to named functions would improve readability. This example replacing it with Kernel.tl would solve this problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, I was looking for a function named tail and couldn't find one.

Copy link
Contributor

@kotva006 kotva006 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use function names instead of Kernel.then

@anthonyshull
Copy link
Contributor Author

Use function names instead of Kernel.then

Anonymous functions make sense when they are doing something very basic that isn't particularly reusable.

@anthonyshull anthonyshull requested a review from kotva006 June 28, 2024 13:39
@anthonyshull anthonyshull merged commit 81ee54b into main Jun 28, 2024
23 checks passed
@anthonyshull anthonyshull deleted the ags/credo-pipe-anonymous branch June 28, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants