fix: update drifted source citations to match current upstream
Verified all 17 file:line citations against elixir-lang/elixir HEAD. Fixed 10 citations where line numbers had shifted due to upstream changes: - patterns/genserver.md: agent.ex:246 → 279 (start_link spec) - patterns/process-design.md: task.ex:282 → 327 (child_spec) - smells/anti-patterns.md: registry_test.exs:28 → 29, gen_server_test.exs:166 → 164, test_helper.exs:98 → 99 - smells/common-mistakes.md: registry_test.exs:28 → 29, callbacks.ex:423 → 433, task_test.exs:297,305,315,330 → 300,308,316,327, supervisor_test.exs:278 → 289, callbacks.ex:277 → 520
This commit is contained in:
@@ -289,7 +289,7 @@ def start_link(default) when is_binary(default) do
|
||||
GenServer.start_link(__MODULE__, default)
|
||||
end
|
||||
|
||||
# From agent.ex:246
|
||||
# From agent.ex:279
|
||||
@spec start_link((-> term), GenServer.options()) :: on_start
|
||||
def start_link(fun, options \\ []) when is_function(fun, 0) do
|
||||
GenServer.start_link(Agent.Server, fun, options)
|
||||
|
||||
@@ -457,7 +457,7 @@ Supervisor.init(children,
|
||||
**Code example from source:**
|
||||
```elixir
|
||||
# Task defaults to :temporary — intentional one-shot work
|
||||
# (from task.ex:282)
|
||||
# (from task.ex:327)
|
||||
def child_spec(arg) do
|
||||
%{
|
||||
id: Task,
|
||||
|
||||
@@ -84,7 +84,7 @@ end)
|
||||
|
||||
**What they avoid:** Tests that depend on or modify global state without cleanup.
|
||||
|
||||
**Source evidence:** `lib/mix/test/test_helper.exs:98-113` — MixTest.Case restores ALL global state in `on_exit`:
|
||||
**Source evidence:** `lib/mix/test/test_helper.exs:99-115` — MixTest.Case restores ALL global state in `on_exit`:
|
||||
- `Mix.env(:dev)`, `Mix.target(:host)`, `Mix.Task.clear()`, `Mix.Shell.Process.flush()`
|
||||
- Unloads all applications that were loaded during the test
|
||||
|
||||
@@ -587,12 +587,12 @@ end
|
||||
|
||||
**What they avoid:** ETS tables, registered names, or application env used across tests without isolation.
|
||||
|
||||
**Source evidence:** `lib/elixir/test/elixir/registry_test.exs:28-31` — Each test gets a uniquely-named Registry:
|
||||
**Source evidence:** `lib/elixir/test/elixir/registry_test.exs:29-32` — Each test gets a uniquely-named Registry:
|
||||
```elixir
|
||||
name = :"#{config.test}_#{partitions}_#{inspect(keys)}"
|
||||
```
|
||||
|
||||
`lib/elixir/test/elixir/gen_server_test.exs:166` — Uses `%{test: name}` for unique process registration.
|
||||
`lib/elixir/test/elixir/gen_server_test.exs:164` — Uses `%{test: name}` for unique process registration.
|
||||
|
||||
**Why it's bad:** Tests that share state can't run concurrently. They're order-dependent and fragile.
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ setup do
|
||||
end
|
||||
```
|
||||
|
||||
**Source:** `lib/ex_unit/lib/ex_unit/callbacks.ex:277-340` — `start_supervised` is designed specifically for this: guaranteed shutdown in reverse order, no leaked processes, no race conditions.
|
||||
**Source:** `lib/ex_unit/lib/ex_unit/callbacks.ex:520-568` — `start_supervised` is designed specifically for this: guaranteed shutdown in reverse order, no leaked processes, no race conditions.
|
||||
|
||||
### When to Apply This Rule
|
||||
|
||||
@@ -236,7 +236,7 @@ test "starts a server", %{test: test_name} do
|
||||
end
|
||||
```
|
||||
|
||||
**Source:** `lib/elixir/test/elixir/registry_test.exs:28` — `name = :"#{config.test}_#{partitions}_#{inspect(keys)}"` — always derives unique names from test context.
|
||||
**Source:** `lib/elixir/test/elixir/registry_test.exs:29` — `name = :"#{config.test}_#{partitions}_#{inspect(keys)}"` — always derives unique names from test context.
|
||||
|
||||
### When to Apply This Rule
|
||||
|
||||
@@ -474,7 +474,7 @@ describe "admin users - deletion" do
|
||||
end
|
||||
```
|
||||
|
||||
**Source:** `lib/ex_unit/lib/ex_unit/callbacks.ex:423-425` — `no_describe!` check prevents nesting.
|
||||
**Source:** `lib/ex_unit/lib/ex_unit/callbacks.ex:433-437` — `no_describe!` check prevents nesting.
|
||||
|
||||
### When to Apply This Rule
|
||||
|
||||
@@ -628,7 +628,7 @@ test "handles process crash" do
|
||||
end
|
||||
```
|
||||
|
||||
**Source:** `lib/elixir/test/elixir/task_test.exs:297,305,315,330` — Every test that expects a linked process to crash sets `:trap_exit` first.
|
||||
**Source:** `lib/elixir/test/elixir/task_test.exs:300,308,316,327` — Every test that expects a linked process to crash sets `:trap_exit` first.
|
||||
|
||||
### When to Apply This Rule
|
||||
|
||||
@@ -866,7 +866,7 @@ test "process stops" do
|
||||
end
|
||||
```
|
||||
|
||||
**Source:** `lib/elixir/test/elixir/supervisor_test.exs:278-285` — `assert_kill` helper always uses monitor + assert_receive, never `Process.alive?` polling.
|
||||
**Source:** `lib/elixir/test/elixir/supervisor_test.exs:289-293` — `assert_kill` helper always uses monitor + assert_receive, never `Process.alive?` polling.
|
||||
|
||||
### When to Apply This Rule
|
||||
|
||||
|
||||
Reference in New Issue
Block a user