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

Convert Enum.map/2+Enum.join/2 to Enum.map_join/3 #585

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

bradhanks
Copy link
Contributor

@bradhanks bradhanks commented Jan 8, 2024

Refactored from " != true"to use "not" for 2 boolean variables
Refactored Enum.map |> Enum.join to Enum.map_join

@bradhanks bradhanks closed this Jan 8, 2024
@bradhanks bradhanks reopened this Jan 8, 2024
@@ -101,7 +101,7 @@ defmodule Mix.Tasks.Ecto.Load do
end

defp skip_safety_warnings? do
Mix.Project.config()[:start_permanent] != true
not Mix.Project.config()[:start_permanent]
Copy link
Member

@greg-rychlewski greg-rychlewski Jan 8, 2024

Choose a reason for hiding this comment

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

this will raise instead of returning true if start_permanent is not a boolean. i don't believe there is a reason to change this behaviour

@@ -1540,7 +1539,7 @@ defmodule Ecto.Migration do
end

defp validate_index_opts!(opts) when is_list(opts) do
if opts[:nulls_distinct] != nil and opts[:unique] != true do
if opts[:nulls_distinct] != nil and not opts[:unique] do
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here.

@@ -944,8 +944,7 @@ defmodule Ecto.Migration do
|> List.flatten()
|> Enum.map(&to_string(&1))
|> Enum.map(&String.replace(&1, ~r"[^\w_]", "_"))
|> Enum.map(&String.replace_trailing(&1, "_", ""))
|> Enum.join("_")
|> Enum.map_join("_", &String.replace_trailing(&1, "_", ""))
Copy link
Member

Choose a reason for hiding this comment

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

You should lift this change to a separate PR and if you are going for efficiency, you might as well combine the previous map functions into one anonymous function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! That's a big improvement over what I did initially.

@josevalim
Copy link
Member

We will gladly accept the map_join ones, but we should not change the boolean ones. :) Thank you!

@bradhanks
Copy link
Contributor Author

Alright I've got that updated. Let me know if you need anything else. Thanks!

@josevalim josevalim changed the title Refactored from " != trueto use "not" for boolean Convert Enum.map/2+Enum.join/2 to Enum.map_join/3 Jan 8, 2024
@josevalim josevalim merged commit ec8ea63 into elixir-ecto:master Jan 8, 2024
10 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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.

4 participants