Credo: map_join, one filter, and no redundant with clause

6107e04 · Gabe Morell · 2026-11-04 20:38

16 files +13 -14

Files changed

modified lib/git_gud/federation/http_signatures.ex
+1 −2
@@ -83,11 +83,10 @@ defmodule GitGud.Federation.HttpSignatures do
83 83 def signing_string(headers_param, header_lookup, request_target) do
84 84 headers_param
85 85 |> String.split(" ", trim: true)
86 − |> Enum.map(fn
86 + |> Enum.map_join("\n", fn
87 87 "(request-target)" -> "(request-target): " <> request_target
88 88 name -> "#{String.downcase(name)}: #{header_lookup.(name) || ""}"
89 89 end)
90 − |> Enum.join("\n")
91 90 end
92 91
93 92 # ── verification ─────────────────────────────────────────────────────
modified lib/git_gud/pull_requests.ex
+2 −4
@@ -1002,10 +1002,8 @@ defmodule GitGud.PullRequests do
1002 1002 :ok <- authorize_write(actor, source_repo),
1003 1003 :ok <- ensure_fresh(pr, comment, source_repo),
1004 1004 {:ok, content, mode} <- read_file(source_repo, pr.head_sha, comment.file_path),
1005 − {:ok, updated} <- Suggestion.apply_to(content, comment.line, replacement),
1006 − {:ok, new_sha} <-
1007 − commit_replacement(source_repo, pr, comment, actor, updated, mode) do
1008 − {:ok, new_sha}
1005 + {:ok, updated} <- Suggestion.apply_to(content, comment.line, replacement) do
1006 + commit_replacement(source_repo, pr, comment, actor, updated, mode)
1009 1007 end
1010 1008 end
1011 1009
modified lib/git_gud/workflows/schedules.ex
+1 −2
@@ -157,8 +157,7 @@ defmodule GitGud.Workflows.Schedules do
157 157 select: s
158 158 )
159 159 |> Repo.all()
160 − |> Enum.filter(&due?(&1, minute))
161 − |> Enum.filter(&claim(&1, minute))
160 + |> Enum.filter(&(due?(&1, minute) and claim(&1, minute)))
162 161 |> Enum.flat_map(&fire/1)
163 162 end
164 163
modified lib/git_gud_web/live/repo_live/index.ex
+4 −2
@@ -122,8 +122,10 @@ defmodule GitGudWeb.RepoLive.Index do
122 122 # add round-trips.
123 123 defp visible(assigns) do
124 124 assigns.repos
125 − |> Enum.filter(&matches?(&1, assigns.query, assigns.tags))
126 − |> Enum.filter(&in_scope?(&1, assigns.scope_filter, assigns.current_scope))
125 + |> Enum.filter(
126 + &(matches?(&1, assigns.query, assigns.tags) and
127 + in_scope?(&1, assigns.scope_filter, assigns.current_scope))
128 + )
127 129 |> sort_by(assigns.sort)
128 130 end
129 131
modified lib/git_gud_web/live/repo_live/show.ex
+1 −2
@@ -525,8 +525,7 @@ defmodule GitGudWeb.RepoLive.Show do
525 525 defp language_summary(%{languages: languages, total_bytes: total}) when total > 0 do
526 526 languages
527 527 |> Enum.take(@top_n)
528 − |> Enum.map(fn s -> "#{s.language} #{pct(s.bytes, total)}%" end)
529 − |> Enum.join(" · ")
528 + |> Enum.map_join(" · ", fn s -> "#{s.language} #{pct(s.bytes, total)}%" end)
530 529 end
531 530
532 531 defp language_summary(_), do: ""
modified test/git_gud/federation/publishing_test.exs
+4 −2
@@ -118,8 +118,10 @@ defmodule GitGud.Federation.PublishingTest do
118 118
119 119 assert [%Activity{type: "Create"}] =
120 120 GitGud.Repo.all(Activity)
121 − |> Enum.filter(&(&1.is_local and &1.type == "Create"))
122 − |> Enum.filter(fn a -> a.raw["object"]["name"] =~ "##{issue.number}" end)
121 + |> Enum.filter(
122 + &(&1.is_local and &1.type == "Create" and
123 + &1.raw["object"]["name"] =~ "##{issue.number}")
124 + )
123 125
124 126 _ = repo_actor
125 127 end

Parents: e737fcd