1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-29 16:16:38 +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
2020-05-14 16:41:43 +02:00
parent 07bc4e2f96
commit 0ee0fa42e6
683 changed files with 22803 additions and 12225 deletions

View File

@@ -300,8 +300,9 @@ private:
if (lidx != -1) {
sp = sp.substr(lidx + 1, sp.length()).capitalize();
}
if (sp == "" && mode == MODE_IMPORT)
if (sp == "" && mode == MODE_IMPORT) {
sp = TTR("Imported Project");
}
project_name->set_text(sp);
_text_changed(sp);
@@ -404,13 +405,15 @@ private:
}
void _text_changed(const String &p_text) {
if (mode != MODE_NEW)
if (mode != MODE_NEW) {
return;
}
_test_path();
if (p_text == "")
if (p_text == "") {
set_message(TTR("It would be a good idea to name your project."), MESSAGE_WARNING);
}
}
void ok_pressed() {
@@ -578,8 +581,9 @@ private:
}
dir = dir.replace("\\", "/");
if (dir.ends_with("/"))
if (dir.ends_with("/")) {
dir = dir.substr(0, dir.length() - 1);
}
String proj = get_project_key_from_path(dir);
EditorSettings::get_singleton()->set("projects/" + proj, dir);
EditorSettings::get_singleton()->save();
@@ -608,16 +612,19 @@ private:
project_name->clear();
_text_changed("");
if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
if (status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) {
msg->show();
}
if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons"))
if (install_status_rect->get_texture() == msg->get_theme_icon("StatusError", "EditorIcons")) {
msg->show();
}
}
void _notification(int p_what) {
if (p_what == NOTIFICATION_WM_CLOSE_REQUEST)
if (p_what == NOTIFICATION_WM_CLOSE_REQUEST) {
_remove_created_folder();
}
}
protected:
@@ -1137,8 +1144,9 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String project_name = TTR("Unnamed Project");
if (cf_err == OK) {
String cf_project_name = static_cast<String>(cf->get_value("application", "config/name", ""));
if (cf_project_name != "")
if (cf_project_name != "") {
project_name = cf_project_name.xml_unescape();
}
config_version = (int)cf->get_value("", "config_version", 0);
}
@@ -1161,8 +1169,9 @@ void ProjectList::load_project_data(const String &p_property_key, Item &p_item,
String fscache = path.plus_file(".fscache");
if (FileAccess::exists(fscache)) {
uint64_t cache_modified = FileAccess::get_modified_time(fscache);
if (cache_modified > last_edited)
if (cache_modified > last_edited) {
last_edited = cache_modified;
}
}
} else {
grayed = true;
@@ -1208,8 +1217,9 @@ void ProjectList::load_projects() {
for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
// This is actually something like "projects/C:::Documents::Godot::Projects::MyGame"
String property_key = E->get().name;
if (!property_key.begins_with("projects/"))
if (!property_key.begins_with("projects/")) {
continue;
}
String project_key = property_key.get_slice("/", 1);
bool favorite = favorites.has("favorite_projects/" + project_key);
@@ -1327,8 +1337,9 @@ void ProjectList::create_project_item_control(int p_index) {
hb->icon = tf;
VBoxContainer *vb = memnew(VBoxContainer);
if (item.grayed)
if (item.grayed) {
vb->set_modulate(Color(1, 1, 1, 0.5));
}
vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
hb->add_child(vb);
Control *ec = memnew(Control);
@@ -1792,8 +1803,9 @@ void ProjectManager::_notification(int p_what) {
}
} break;
case NOTIFICATION_READY: {
if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available())
if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) {
open_templates->popup_centered();
}
if (_project_list->get_project_count() >= 1) {
// Focus on the search box immediately to allow the user
@@ -1859,8 +1871,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
}
#endif
if (tabs->get_current_tab() != 0)
if (tabs->get_current_tab() != 0) {
return;
}
bool keycode_handled = true;
@@ -1886,8 +1899,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_UP: {
if (k->get_shift())
if (k->get_shift()) {
break;
}
int index = _project_list->get_single_selected_index();
if (index > 0) {
@@ -1899,8 +1913,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
break;
}
case KEY_DOWN: {
if (k->get_shift())
if (k->get_shift()) {
break;
}
int index = _project_list->get_single_selected_index();
if (index + 1 < _project_list->get_project_count()) {
@@ -1911,10 +1926,11 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) {
} break;
case KEY_F: {
if (k->get_command())
if (k->get_command()) {
this->project_filter->search_box->grab_focus();
else
} else {
keycode_handled = false;
}
} break;
default: {
keycode_handled = false;
@@ -2176,8 +2192,9 @@ void ProjectManager::_erase_missing_projects_confirm() {
void ProjectManager::_erase_project() {
const Set<String> &selected_list = _project_list->get_selected_project_keys();
if (selected_list.size() == 0)
if (selected_list.size() == 0) {
return;
}
String confirm_message;
if (selected_list.size() >= 2) {
@@ -2305,8 +2322,9 @@ void ProjectManager::_open_asset_library() {
ProjectManager::ProjectManager() {
// load settings
if (!EditorSettings::get_singleton())
if (!EditorSettings::get_singleton()) {
EditorSettings::create();
}
EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came
@@ -2626,14 +2644,16 @@ ProjectManager::ProjectManager() {
}
ProjectManager::~ProjectManager() {
if (EditorSettings::get_singleton())
if (EditorSettings::get_singleton()) {
EditorSettings::destroy();
}
}
void ProjectListFilter::_setup_filters(Vector<String> options) {
filter_option->clear();
for (int i = 0; i < options.size(); i++)
for (int i = 0; i < options.size(); i++) {
filter_option->add_item(options[i]);
}
}
void ProjectListFilter::_search_text_changed(const String &p_newtext) {
@@ -2657,8 +2677,9 @@ void ProjectListFilter::_filter_option_selected(int p_idx) {
FilterOption selected = (FilterOption)(filter_option->get_selected());
if (_current_filter != selected) {
_current_filter = selected;
if (is_inside_tree())
if (is_inside_tree()) {
emit_signal("filter_changed");
}
}
}