bitwalker / bitwalker/artificery

Failure in dialyzer check of value returned by the pre_dispatch/3 callback

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elixir
Stars
132
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Dialyzer is returning the following error when checking `lib/entry.ex`:
```
lib/entry.ex:291:pattern_match_cov
The pattern
variable_

can never match, because previous clauses completely cover the type
{:ok, _}.
```

This is happening because the [pre_dispatch/3](https://github.com/bitwalker/artificery/blob/master/lib/artificery.ex#L29) callback is defined like this:
```elixir
@callback pre_dispatch(Command.t, argv, options) :: {:ok, options} | no_return
```
But within the `Artificery.Entry` module the [function is called](https://github.com/bitwalker/artificery/blob/master/lib/entry.ex#L287-L297) assuming that some value other than `{:ok, options}` can be returned by it:
```elixir
case __MODULE__.pre_dispatch(command, argv, flags) do
{:ok, new_flags} ->
new_flags

other ->
Console.error(
"Expected {:ok, options} returned from #{__MODULE__}.pre_dispatch/3, got: #{
inspect(other)
}"
)
end
```

I'm not sure what the fix should be other than trying to find a way to disable the warning in dialyzer or crashing instead of calling `Console.error/1`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the pre_dispatch/3 callback declaration in lib/artificery.ex around line 29 with its call in lib/entry.ex around lines 287-297. Run the Dialyzer check and inspect the reported pattern_match_cov warning. Done means the callback contract and caller agree and the warning is resolved without losing the intended error handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.