From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: 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 #33027. --- scene/resources/gradient.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'scene/resources/gradient.h') diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h index 573749ea7e..fa654cf31d 100644 --- a/scene/resources/gradient.h +++ b/scene/resources/gradient.h @@ -39,7 +39,6 @@ class Gradient : public Resource { public: struct Point { - float offset; Color color; bool operator<(const Point &p_ponit) const { @@ -77,7 +76,6 @@ public: Vector get_colors() const; _FORCE_INLINE_ Color get_color_at_offset(float p_offset) { - if (points.empty()) return Color(0, 0, 0, 1); -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: Style: Enforce braces around if blocks and loops Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html --- scene/resources/gradient.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'scene/resources/gradient.h') diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h index fa654cf31d..d40dcc8d44 100644 --- a/scene/resources/gradient.h +++ b/scene/resources/gradient.h @@ -76,8 +76,9 @@ public: Vector get_colors() const; _FORCE_INLINE_ Color get_color_at_offset(float p_offset) { - if (points.empty()) + if (points.empty()) { return Color(0, 0, 0, 1); + } if (!is_sorted) { points.sort(); @@ -90,8 +91,9 @@ public: int middle = 0; #ifdef DEBUG_ENABLED - if (low > high) + if (low > high) { ERR_PRINT("low > high, this may be a bug"); + } #endif while (low <= high) { @@ -112,10 +114,12 @@ public: } int first = middle; int second = middle + 1; - if (second >= points.size()) + if (second >= points.size()) { return points[points.size() - 1].color; - if (first < 0) + } + if (first < 0) { return points[0].color; + } const Point &pointFirst = points[first]; const Point &pointSecond = points[second]; return pointFirst.color.lerp(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset)); -- cgit v1.2.3