1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-24 15:26:15 +00:00

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
This commit is contained in:
Rémi Verschelde
2021-05-05 12:44:11 +02:00
parent b8d198eeed
commit 140350d767
694 changed files with 23283 additions and 12499 deletions

View File

@@ -58,11 +58,13 @@ void AnimationTrackEditBool::draw_key(int p_index, float p_pixels_sec, int p_x,
Vector2 ofs(p_x - icon->get_width() / 2, int(get_size().height - icon->get_height()) / 2);
if (ofs.x + icon->get_width() / 2 < p_clip_left)
if (ofs.x + icon->get_width() / 2 < p_clip_left) {
return;
}
if (ofs.x + icon->get_width() / 2 > p_clip_right)
if (ofs.x + icon->get_width() / 2 > p_clip_right) {
return;
}
draw_texture(icon, ofs);
@@ -96,8 +98,9 @@ void AnimationTrackEditColor::draw_key_link(int p_index, float p_pixels_sec, int
int x_to = p_next_x - fh / 2 + 1;
fh /= 3;
if (x_from > p_clip_right || x_to < p_clip_left)
if (x_from > p_clip_right || x_to < p_clip_left) {
return;
}
Color color = get_animation()->track_get_key_value(get_track(), p_index);
Color color_next = get_animation()->track_get_key_value(get_track(), p_index + 1);
@@ -159,8 +162,9 @@ void AnimationTrackEditColor::draw_key(int p_index, float p_pixels_sec, int p_x,
void AnimationTrackEditAudio::_preview_changed(ObjectID p_which) {
Object *object = ObjectDB::get_instance(id);
if (!object)
if (!object) {
return;
}
Ref<AudioStream> stream = object->call("get_stream");
@@ -246,11 +250,13 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
if (pixel_end < p_clip_left)
if (pixel_end < p_clip_left) {
return;
}
if (pixel_begin > p_clip_right)
if (pixel_begin > p_clip_right) {
return;
}
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
@@ -261,8 +267,9 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
to_x = MIN(limit_x, to_x);
}
if (to_x <= from_x)
if (to_x <= from_x) {
return;
}
Ref<Font> font = get_font("font", "Label");
float fh = int(font->get_height() * 1.5);
@@ -489,11 +496,13 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
Rect2 rect(p_x, int(get_size().height - height) / 2, width, height);
if (rect.position.x + rect.size.x < p_clip_left)
if (rect.position.x + rect.size.x < p_clip_left) {
return;
}
if (rect.position.x > p_clip_right)
if (rect.position.x > p_clip_right) {
return;
}
Color accent = get_color("accent_color", "Editor");
Color bg = accent;
@@ -588,17 +597,20 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
if (pixel_end < p_clip_left)
if (pixel_end < p_clip_left) {
return;
}
if (pixel_begin > p_clip_right)
if (pixel_begin > p_clip_right) {
return;
}
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
if (to_x <= from_x)
if (to_x <= from_x) {
return;
}
Ref<Font> font = get_font("font", "Label");
int fh = font->get_height() * 1.5;
@@ -626,8 +638,9 @@ void AnimationTrackEditSubAnim::draw_key(int p_index, float p_pixels_sec, int p_
float ofs = animation->track_get_key_time(i, j);
int x = p_x + ofs * p_pixels_sec + 2;
if (x < from_x || x >= (to_x - 4))
if (x < from_x || x >= (to_x - 4)) {
continue;
}
lines.push_back(Point2(x, y));
lines.push_back(Point2(x + 1, y));
@@ -697,8 +710,9 @@ void AnimationTrackEditVolumeDB::draw_fg(int p_clip_left, int p_clip_right) {
}
void AnimationTrackEditVolumeDB::draw_key_link(int p_index, float p_pixels_sec, int p_x, int p_next_x, int p_clip_left, int p_clip_right) {
if (p_x > p_clip_right || p_next_x < p_clip_left)
if (p_x > p_clip_right || p_next_x < p_clip_left) {
return;
}
float db = get_animation()->track_get_key_value(get_track(), p_index);
float db_n = get_animation()->track_get_key_value(get_track(), p_index + 1);
@@ -799,12 +813,14 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
float ofs_local = -len_resizing_rel / get_timeline()->get_zoom_scale();
if (len_resizing_start) {
start_ofs += ofs_local;
if (start_ofs < 0)
if (start_ofs < 0) {
start_ofs = 0;
}
} else {
end_ofs += ofs_local;
if (end_ofs < 0)
if (end_ofs < 0) {
end_ofs = 0;
}
}
}
@@ -835,11 +851,13 @@ void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
if (pixel_end < p_clip_left)
if (pixel_end < p_clip_left) {
return;
}
if (pixel_begin > p_clip_right)
if (pixel_begin > p_clip_right) {
return;
}
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
@@ -1140,17 +1158,20 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
int pixel_begin = p_x;
int pixel_end = p_x + pixel_len;
if (pixel_end < p_clip_left)
if (pixel_end < p_clip_left) {
return;
}
if (pixel_begin > p_clip_right)
if (pixel_begin > p_clip_right) {
return;
}
int from_x = MAX(pixel_begin, p_clip_left);
int to_x = MIN(pixel_end, p_clip_right);
if (to_x <= from_x)
if (to_x <= from_x) {
return;
}
Ref<Font> font = get_font("font", "Label");
int fh = font->get_height() * 1.5;
@@ -1178,8 +1199,9 @@ void AnimationTrackEditTypeAnimation::draw_key(int p_index, float p_pixels_sec,
float ofs = animation->track_get_key_time(i, j);
int x = p_x + ofs * p_pixels_sec + 2;
if (x < from_x || x >= (to_x - 4))
if (x < from_x || x >= (to_x - 4)) {
continue;
}
lines.push_back(Point2(x, y));
lines.push_back(Point2(x + 1, y));