-
Notifications
You must be signed in to change notification settings - Fork 316
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
Conversation
lib/mix/tasks/ecto.load.ex
Outdated
@@ -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] |
There was a problem hiding this comment.
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
lib/ecto/migration.ex
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here.
lib/ecto/migration.ex
Outdated
@@ -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, "_", "")) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
We will gladly accept the map_join ones, but we should not change the boolean ones. :) Thank you! |
Alright I've got that updated. Let me know if you need anything else. Thanks! |
💚 💙 💜 💛 ❤️ |
Refactored from " != true"to use "not" for 2 boolean variables
Refactored Enum.map |> Enum.join to Enum.map_join