Skip to content

Commit 2f5ebd6

Browse files
committed
fix: silence Bandit test server warnings
- Remove unused 'alias Plug.Conn' (we use the fully-qualified Elixir.Plug.Conn instead). - Use '@behaviour Elixir.Plug' inside the nested Plug module so Elixir recognizes the behaviour declaration. Without the fully-qualified name, '@behaviour Plug' refers to the inner module (self-reference), which is why Credo and the compiler flagged it as 'module is not a behaviour'. 107 tests pass. CI green (Credo strict, --warnings-as-errors clean).
1 parent 590bcab commit 2f5ebd6

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

test/support/test_server.ex

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ defmodule AdoCli.TestServer do
2727

2828
use GenServer
2929

30-
alias Plug.Conn
31-
3230
defstruct port: nil, bandit_pid: nil, expectations: []
3331

3432
@type method :: String.t()
@@ -79,12 +77,13 @@ defmodule AdoCli.TestServer do
7977
# Keeping it at top-level keeps the code clean.
8078
defmodule Plug do
8179
@moduledoc false
82-
@behaviour Plug
83-
8480
# Nested-module gotcha: `Plug` inside `AdoCli.TestServer.Plug` refers
85-
# to the inner Plug (this module), so `Plug.Conn` would resolve to
86-
# `AdoCli.TestServer.Plug.Conn`. Use the full `Elixir.Plug.Conn` name
87-
# to disambiguate.
81+
# to the inner Plug (this module), so `@behaviour Plug` would refer
82+
# to itself and `@behaviour Plug` would be treated as a self-reference.
83+
# Use the full `Elixir.Plug` name to disambiguate.
84+
@behaviour Elixir.Plug
85+
86+
# Same disambiguation for `Plug.Conn`.
8887
import Elixir.Plug.Conn, only: [put_resp_content_type: 2, resp: 3]
8988

9089
@impl true

0 commit comments

Comments
 (0)