From 9c91c0bc4f6dba759691cdd31265c56b336aaa42 Mon Sep 17 00:00:00 2001 From: Ilya Klyuchnikov Date: Tue, 2 Jul 2024 08:05:57 -0700 Subject: [PATCH] fix specs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/wa_raft_log_ets.erl | 2 +- src/wa_raft_server.erl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wa_raft_log_ets.erl b/src/wa_raft_log_ets.erl index 571fd55..f87b35d 100644 --- a/src/wa_raft_log_ets.erl +++ b/src/wa_raft_log_ets.erl @@ -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) -> diff --git a/src/wa_raft_server.erl b/src/wa_raft_server.erl index efff897..32767e2 100644 --- a/src/wa_raft_server.erl +++ b/src/wa_raft_server.erl @@ -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]}),