1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-05 17:15:09 +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

@@ -69,8 +69,9 @@ public:
int which = name.get_slice("/", 1).to_int() - 1;
ERR_FAIL_INDEX_V(which, params.size(), false);
params.write[which] = p_value;
} else
} else {
return false;
}
return true;
}
@@ -82,8 +83,9 @@ public:
int which = name.get_slice("/", 1).to_int() - 1;
ERR_FAIL_INDEX_V(which, params.size(), false);
r_ret = params[which];
} else
} else {
return false;
}
return true;
}
@@ -145,8 +147,9 @@ void ConnectDialog::_cancel_pressed() {
void ConnectDialog::_tree_node_selected() {
Node *current = tree->get_selected();
if (!current)
if (!current) {
return;
}
dst_path = source->get_path_to(current);
_update_ok_enabled();
@@ -156,8 +159,9 @@ void ConnectDialog::_tree_node_selected() {
* Adds a new parameter bind to connection.
*/
void ConnectDialog::_add_bind() {
if (cdbinds->params.size() >= VARIANT_ARG_MAX)
if (cdbinds->params.size() >= VARIANT_ARG_MAX) {
return;
}
Variant::Type vt = (Variant::Type)type_list->get_item_id(type_list->get_selected());
Variant value;
@@ -218,8 +222,9 @@ void ConnectDialog::_add_bind() {
*/
void ConnectDialog::_remove_bind() {
String st = bind_editor->get_selected_path();
if (st == "")
if (st == "") {
return;
}
int idx = st.get_slice("/", 1).to_int() - 1;
ERR_FAIL_INDEX(idx, cdbinds->params.size());
@@ -282,8 +287,9 @@ void ConnectDialog::set_dst_node(Node *p_node) {
StringName ConnectDialog::get_dst_method_name() const {
String txt = dst_method->get_text();
if (txt.find("(") != -1)
if (txt.find("(") != -1) {
txt = txt.left(txt.find("(")).strip_edges();
}
return txt;
}
@@ -347,8 +353,9 @@ void ConnectDialog::init(Connection c, bool bEdit) {
void ConnectDialog::popup_dialog(const String &p_for_signal) {
from_signal->set_text(p_for_signal);
error_label->add_color_override("font_color", get_color("error_color", "Editor"));
if (!advanced->is_pressed())
if (!advanced->is_pressed()) {
error_label->set_visible(!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root()));
}
popup_centered();
}
@@ -591,8 +598,9 @@ void ConnectionsDock::_connect(Connection cToMake) {
Node *source = static_cast<Node *>(cToMake.source);
Node *target = static_cast<Node *>(cToMake.target);
if (!source || !target)
if (!source || !target) {
return;
}
undo_redo->create_action(vformat(TTR("Connect '%s' to '%s'"), String(cToMake.signal), String(cToMake.method)));
@@ -632,8 +640,9 @@ void ConnectionsDock::_disconnect(TreeItem &item) {
void ConnectionsDock::_disconnect_all() {
TreeItem *item = tree->get_selected();
if (!_is_item_signal(*item))
if (!_is_item_signal(*item)) {
return;
}
TreeItem *child = item->get_children();
String signalName = item->get_metadata(0).operator Dictionary()["name"];
@@ -672,8 +681,9 @@ void ConnectionsDock::_tree_item_activated() { // "Activation" on double-click.
TreeItem *item = tree->get_selected();
if (!item)
if (!item) {
return;
}
if (_is_item_signal(*item)) {
_open_connection_dialog(*item);
@@ -745,19 +755,22 @@ void ConnectionsDock::_open_connection_dialog(Connection cToEdit) {
* Open slot method location in script editor.
*/
void ConnectionsDock::_go_to_script(TreeItem &item) {
if (_is_item_signal(item))
if (_is_item_signal(item)) {
return;
}
Connection c = item.get_metadata(0);
ERR_FAIL_COND(c.source != selectedNode); //shouldn't happen but...bugcheck
if (!c.target)
if (!c.target) {
return;
}
Ref<Script> script = c.target->get_script();
if (script.is_null())
if (script.is_null()) {
return;
}
if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, c.method)) {
editor->call("_editor_select", EditorNode::EDITOR_SCRIPT);
@@ -767,8 +780,9 @@ void ConnectionsDock::_go_to_script(TreeItem &item) {
void ConnectionsDock::_handle_signal_menu_option(int option) {
TreeItem *item = tree->get_selected();
if (!item)
if (!item) {
return;
}
switch (option) {
case CONNECT: {
@@ -785,8 +799,9 @@ void ConnectionsDock::_handle_signal_menu_option(int option) {
void ConnectionsDock::_handle_slot_menu_option(int option) {
TreeItem *item = tree->get_selected();
if (!item)
if (!item) {
return;
}
switch (option) {
case EDIT: {
@@ -806,8 +821,9 @@ void ConnectionsDock::_handle_slot_menu_option(int option) {
void ConnectionsDock::_rmb_pressed(Vector2 position) {
TreeItem *item = tree->get_selected();
if (!item)
if (!item) {
return;
}
Vector2 global_position = tree->get_global_position() + position;
@@ -867,8 +883,9 @@ void ConnectionsDock::set_node(Node *p_node) {
void ConnectionsDock::update_tree() {
tree->clear();
if (!selectedNode)
if (!selectedNode) {
return;
}
TreeItem *root = tree->create_item();
@@ -889,10 +906,11 @@ void ConnectionsDock::update_tree() {
Ref<Script> scr = selectedNode->get_script();
if (scr.is_valid()) {
scr->get_script_signal_list(&node_signals2);
if (scr->get_path().is_resource_file())
if (scr->get_path().is_resource_file()) {
name = scr->get_path().get_file();
else
} else {
name = scr->get_class();
}
if (has_icon(scr->get_class(), "EditorIcons")) {
icon = get_icon(scr->get_class(), "EditorIcons");
@@ -939,8 +957,9 @@ void ConnectionsDock::update_tree() {
for (int i = 0; i < mi.arguments.size(); i++) {
PropertyInfo &pi = mi.arguments[i];
if (i > 0)
if (i > 0) {
signaldesc += ", ";
}
String tname = "var";
if (pi.type == Variant::OBJECT && pi.class_name != StringName()) {
tname = pi.class_name.operator String();
@@ -1005,23 +1024,28 @@ void ConnectionsDock::update_tree() {
for (List<Object::Connection>::Element *F = connections.front(); F; F = F->next()) {
Object::Connection &c = F->get();
if (!(c.flags & CONNECT_PERSIST))
if (!(c.flags & CONNECT_PERSIST)) {
continue;
}
Node *target = Object::cast_to<Node>(c.target);
if (!target)
if (!target) {
continue;
}
String path = String(selectedNode->get_path_to(target)) + " :: " + c.method + "()";
if (c.flags & CONNECT_DEFERRED)
if (c.flags & CONNECT_DEFERRED) {
path += " (deferred)";
if (c.flags & CONNECT_ONESHOT)
}
if (c.flags & CONNECT_ONESHOT) {
path += " (oneshot)";
}
if (c.binds.size()) {
path += " binds(";
for (int i = 0; i < c.binds.size(); i++) {
if (i > 0)
if (i > 0) {
path += ", ";
}
path += c.binds[i].operator String();
}
path += ")";