Skip to content

Commit

Permalink
Merge pull request #1232 from UniStuttgart-VISUS/clang-format
Browse files Browse the repository at this point in the history
Update clang-format
  • Loading branch information
moritz-h authored Oct 13, 2023
2 parents 84746b1 + f2128fc commit f0a06c6
Show file tree
Hide file tree
Showing 162 changed files with 1,711 additions and 1,697 deletions.
6 changes: 3 additions & 3 deletions .ci/check_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ while read -r file; do
if [[ "$is_cpp" == true ]]; then
# ClangFormat
if [[ "$_fix" == true ]]; then
clang-format-14 -i "$file"
clang-format-16 -i "$file"
else
# Workaround "set -e" and store exit code
format_exit_code=0
output="$(clang-format-14 --dry-run --Werror "$file" 2>&1)" || format_exit_code=$?
output="$(clang-format-16 --dry-run --Werror "$file" 2>&1)" || format_exit_code=$?
if [[ $format_exit_code -ne 0 ]]; then
EXIT_CODE=1
echo "::error::ClangFormat found issues in: $file"
#echo "$output"
# Show detailed diff. Requires ClangFormat to run again, but should mostly affect only a few files.
clang-format-14 "$file" | diff --color=always -u "$file" - || true
clang-format-16 "$file" | diff --color=always -u "$file" - || true
fi
fi

Expand Down
5 changes: 2 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: Left
AllowAllArgumentsOnNextLine: true # 'false' has different behavior between clang-format 11 and 12, therefore use 'true'.
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
Expand All @@ -22,13 +21,13 @@ AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Attach
BreakConstructorInitializers: BeforeComma
CommentPragmas: '^.*'
ConstructorInitializerAllOnOneLineOrOnePerLine: true # Replace with "PackConstructorInitializers: Never", when switching to clang-format 14.
ConstructorInitializerIndentWidth: 8
DerivePointerAlignment: false
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PackConstructorInitializers: CurrentLine
PointerAlignment: Left
SpaceAfterCStyleCast: false # want true, but has issues with clang-format-12
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
Standard: c++17
# TODO Does not work reliable, yet. Do not use in automatic CI pipeline!
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/style_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
name: Style-Check
runs-on: ubuntu-22.04
steps:
- name: Install clang-format
run: |
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
sudo add-apt-repository --yes "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
sudo apt-get install -y clang-format-16
- uses: actions/checkout@v3
- name: Run format check
run: .ci/check_format.sh
Expand Down
6 changes: 3 additions & 3 deletions core/include/mmcore/utility/log/Log.inl
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ void Log::writeMessage(log_level level, std::string const& msg, Args&&... args)
switch (level) {
case log_level::error: {
logger->error(fmsg);
(echo_logger ? echo_logger->error(fmsg) : (void)(0));
(echo_logger ? echo_logger->error(fmsg) : (void) (0));
} break;
case log_level::warn: {
logger->warn(fmsg);
(echo_logger ? echo_logger->warn(fmsg) : (void)(0));
(echo_logger ? echo_logger->warn(fmsg) : (void) (0));
} break;
case log_level::info:
default: {
logger->info(fmsg);
(echo_logger ? echo_logger->info(fmsg) : (void)(0));
(echo_logger ? echo_logger->info(fmsg) : (void) (0));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/include/mmcore/view/CameraControllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ class Camera3DController {
* This event handler can be reimplemented to receive mouse move events.
*/
virtual void OnMouseMove(double x, double y, int wndWidth, int wndHeight) {
this->_mouseX = (float)static_cast<int>(x);
this->_mouseY = (float)static_cast<int>(y);
this->_mouseX = (float) static_cast<int>(x);
this->_mouseY = (float) static_cast<int>(y);

glm::vec3 newPos;

Expand Down
4 changes: 2 additions & 2 deletions core/src/param/TransferFunctionParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ bool TransferFunctionParam::CheckTransferFunctionString(const std::string& tfs)

// Check transfer function node data
if (json.at("Nodes").is_array()) {
unsigned int tmp_size = (unsigned int)json.at("Nodes").size();
unsigned int tmp_size = (unsigned int) json.at("Nodes").size();
for (unsigned int i = 0; i < tmp_size; ++i) {
if (!json.at("Nodes")[i].is_array()) {
megamol::core::utility::log::Log::DefaultLog.WriteError(
Expand Down Expand Up @@ -298,7 +298,7 @@ bool TransferFunctionParam::CheckTransferFunctionString(const std::string& tfs)

// Check value range
if (json.at("ValueRange").is_array()) {
unsigned int tmp_size = (unsigned int)json.at("ValueRange").size();
unsigned int tmp_size = (unsigned int) json.at("ValueRange").size();
if (tmp_size != 2) {
megamol::core::utility::log::Log::DefaultLog.WriteError(
"There should be at two entries in 'ValueRange' array. [%s, %s, line %d]\n", __FILE__,
Expand Down
Loading

0 comments on commit f0a06c6

Please sign in to comment.