Skip to content

Commit

Permalink
fix specs
Browse files Browse the repository at this point in the history
Summary:
Fixing types for function arguments:

Before:

```
> eqwalize-app wa_raft --clause-coverage
  Parsing modules           ████████████████████ 25/25
  EqWAlizing                ████████████████████ 25/25                                                                                                                                                                                                            error: clause_not_covered
    ┌─ erl/wa_raft/src/wa_raft_log_ets.erl:214:1
    │
214 │ ╭ trim_impl(_Log, '$end_of_table') ->
215 │ │     ok;
    │ ╰──────^ Clause is not covered by spec

See https://fb.me/eqwalizer_errors#clause_not_covered

error: clause_not_covered
     ┌─ erl/wa_raft/src/wa_raft_server.erl:1995:1
     │
1995 │ ╭ apply_op(LogIndex, undefined, _EffectiveTerm, #raft_state{name = Name, log_view = View, current_term = CurrentTerm}) ->
1996 │ │     ?RAFT_COUNT('raft.server.missing.log.entry'),
1997 │ │     ?LOG_ERROR("Server[~0p, term ~0p] failed to apply ~0p because log entry is missing from log covering ~0p to ~0p.",
1998 │ │         [Name, CurrentTerm, LogIndex, wa_raft_log:first_index(View), wa_raft_log:last_index(View)], #{domain => [whatsapp, wa_raft]}),
1999 │ │     exit({invalid_op, LogIndex});
     │ ╰────────────────────────────────^ Clause is not covered by spec

See https://fb.me/eqwalizer_errors#clause_not_covered

eqWAlized 9 module(s) (16 cached) in 0s
2 ERRORS
```

After - all covered

Differential Revision: D59275906

fbshipit-source-id: a09913130f842adfa3497a0d4b10c3e59efae2fc
  • Loading branch information
ilya-klyuchnikov authored and facebook-github-bot committed Jul 2, 2024
1 parent 703dcd0 commit 9c91c0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wa_raft_log_ets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ trim(Log, Index, State) ->
trim_impl(Log, Index - 1),
{ok, State}.

-spec trim_impl(Log :: wa_raft_log:log(), Index :: wa_raft_log:log_index()) -> ok.
-spec trim_impl(Log :: wa_raft_log:log(), Index :: wa_raft_log:log_index() | '$end_of_table') -> ok.
trim_impl(_Log, '$end_of_table') ->
ok;
trim_impl(#raft_log{name = Name} = Log, Index) ->
Expand Down
2 changes: 1 addition & 1 deletion src/wa_raft_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,7 @@ apply_log(#raft_state{application = App, name = Name, table = Table, partition =
apply_log(State, _CommitIndex, _TrimIndex, _EffectiveTerm) ->
State.

-spec apply_op(wa_raft_log:log_index(), wa_raft_log:log_entry(), wa_raft_log:log_term() | undefined, #raft_state{}) -> #raft_state{}.
-spec apply_op(wa_raft_log:log_index(), wa_raft_log:log_entry() | undefined, wa_raft_log:log_term() | undefined, #raft_state{}) -> #raft_state{}.
apply_op(LogIndex, _Entry, _EffectiveTerm, #raft_state{name = Name, last_applied = LastAppliedIndex, current_term = CurrentTerm} = State) when LogIndex =< LastAppliedIndex ->
?LOG_WARNING("Server[~0p, term ~0p] is skipping applying log entry ~0p because log entries up to ~0p are already applied.",
[Name, CurrentTerm, LogIndex, LastAppliedIndex], #{domain => [whatsapp, wa_raft]}),
Expand Down

0 comments on commit 9c91c0b

Please sign in to comment.