Skip to content

Instantly share code, notes, and snippets.

@tsloughter
Created January 15, 2017 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsloughter/07d4086afa89c80f5292bf2a423e33c2 to your computer and use it in GitHub Desktop.
Save tsloughter/07d4086afa89c80f5292bf2a423e33c2 to your computer and use it in GitHub Desktop.

Exports given by prettypr:

-export([block_fragment/1, format/1, new/2,
     promised_stream_id/1, read_binary/2, to_binary/1,
     to_frame/4]).

becomes

-export([block_fragment/1,
         format/1,
         new/2,
         promised_stream_id/1,
         read_binary/2,
         to_binary/1,
         to_frame/4]).

or at the very least:

-export([block_fragment/1, format/1, new/2,
         promised_stream_id/1, read_binary/2,
         to_binary/1, to_frame/4]).

This one I'm not sure why it is a new line, keeping it one line is only 63 chars:

promised_stream_id(#push_promise{promised_stream_id =
                     PSID}) ->
    PSID.

Should be.

promised_stream_id(#push_promise{promised_stream_id = PSID}) ->
    PSID.

And if it were over 80 then the variable PSID should at least line up like:

promised_stream_id(#push_promise{promised_stream_id = 
                                    PSID}) ->
    PSID.

This indentation of a record:

new(StreamId, Bin) ->
    #push_promise{promised_stream_id = StreamId,
          block_fragment = Bin}.

becomes:

new(StreamId, Bin) ->
    #push_promise{promised_stream_id = StreamId,
                  block_fragment = Bin}.

Indentation of the right hand side of a bind with a newline because of length:

to_frame(StreamId, PStreamId, Headers, EncodeContext) ->
    {ok, {HeadersToSend, NewContext}} =
    hpack:encode(Headers, EncodeContext),

becomes:

to_frame(StreamId, PStreamId, Headers, EncodeContext) ->
    {ok, {HeadersToSend, NewContext}} =
        hpack:encode(Headers, EncodeContext),

Case statements should indent the body:

case ExitStrategy of
    max_frame_size ->
	  s_send_what_we_can(SWS - SentBytes, MFS, NewS);
    stream -> {SWS - SentBytes, NewS};
    connection -> {0, NewS}
end;

becomes:

case ExitStrategy of
    max_frame_size ->
	      s_send_what_we_can(SWS - SentBytes, MFS, NewS);
    stream -> {SWS - SentBytes, NewS};
    connection -> {0, NewS}
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment