Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks #38738

Merged

Commits on May 14, 2020

  1. Configuration menu
    Copy the full SHA
    710b34b View commit details
    Browse the repository at this point in the history
  2. Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks

    Which means that reduz' beloved style which we all became used to
    will now be changed automatically to remove the first empty line.
    
    This makes us lean closer to 1TBS (the one true brace style) instead
    of hybridating it with some Allman-inspired spacing.
    
    There's still the case of braces around single-statement blocks that
    needs to be addressed (but clang-format can't help with that, but
    clang-tidy may if we agree about it).
    
    Part of godotengine#33027.
    akien-mga committed May 14, 2020
    Configuration menu
    Copy the full SHA
    0be6d92 View commit details
    Browse the repository at this point in the history
  3. Style: Enforce separation line between function definitions

    I couldn't find a tool that enforces it, so I went the manual route:
    ```
    find -name "thirdparty" -prune \
      -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
      -o -name "*.glsl" > files
    perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
    misc/scripts/fix_style.sh -c
    ```
    
    This adds a newline after all `}` on the first column, unless they
    are followed by `#` (typically `#endif`). This leads to having lots
    of places with two lines between function/class definitions, but
    clang-format then fixes it as we enforce max one line of separation.
    
    This doesn't fix potential occurrences of function definitions which
    are indented (e.g. for a helper class defined in a .cpp), but it's
    better than nothing. Also can't be made to run easily on CI/hooks so
    we'll have to be careful with new code.
    
    Part of godotengine#33027.
    akien-mga committed May 14, 2020
    Configuration menu
    Copy the full SHA
    07bc4e2 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0ee0fa4 View commit details
    Browse the repository at this point in the history