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

with -> case -> if #100

Closed
novaugust opened this issue Dec 8, 2023 · 0 comments
Closed

with -> case -> if #100

novaugust opened this issue Dec 8, 2023 · 0 comments

Comments

@novaugust
Copy link
Contributor

novaugust commented Dec 8, 2023

found this rewrite while testing main against a production codebase

-    with account <- Map.put(foo, :bar, true),
-         true <- bop? do
-      {:ok, []}
-    else
+    account = Map.put(foo, :bar, true)
+
+    case bop? do
+      true -> {:ok, []}
       _ -> {:error, :forbidden}
     end

a second rewrite would change that case to an if, so that needs to happen automatically

assert_style """
with foo <- bar,
  true <- bop do
  :ok
else
  _ -> :error
end
""",
"""
foo = bar

if bop do
  :ok
else
  :error
end
"""
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

No branches or pull requests

1 participant