alcjzk / Webserv

0 stars 0 forks source link

Update clang-format spec #46

Closed alcjzk closed 7 months ago

alcjzk commented 7 months ago

This PR updates a few formatting settings that were causing fairly hard to read portions in an upcoming PR. The settings have been modified as follows:


AlignAfterOpenBracket from Align to BlockIndent

This allows splitting parentheses & brackets with many values into multiple lines without extremely large indentations. This also makes it slightly easier to see which parentheses the split content belongs to, as the opening and closing brackets will always occupy their own line when split.

// Before
ReadState read_state{ReadTask(std::move(file), size, server.config()),
                              std::move(client), server, connection};
// After
ReadState read_state{
    ReadTask(std::move(file), size, server.config()),
    std::move(client),
    server,
    connection,
};

AlignConsecutiveDeclarations disabled AcrossEmptyLines and AcrossComments

In some cases like here, extreme indentations could occur inside function bodies. This change allows breaking the forced indent level with an empty line / comment.


AlwaysBreakTemplateDeclarations set to MultiLine

The previous setting forced template type declarations on the same line as the function signature, making for extremely long lines and unnecessary awkward breaks.

// Before
template <typename... States> template <typename T> void CompositeTask<States...>::state(
    T&& state
    )
{
    _state.template emplace<T>(std::forward<T>(state));
}
// After
template <typename... States>
template <typename T>
void CompositeTask<States...>::state(T&& state)
{
    _state.template emplace<T>(std::forward<T>(state));
}