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

@@ -173,10 +173,11 @@ bool EditorExportPreset::has_export_file(const String &p_path) {
}
void EditorExportPreset::add_patch(const String &p_path, int p_at_pos) {
if (p_at_pos < 0)
if (p_at_pos < 0) {
patches.push_back(p_path);
else
} else {
patches.insert(p_at_pos, p_path);
}
EditorExport::singleton->save_presets();
}
@@ -233,8 +234,9 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) {
host = "localhost";
}
if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
@@ -260,8 +262,9 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
String bpoints;
for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
bpoints += E->get().replace(" ", "%20");
if (E->next())
if (E->next()) {
bpoints += ",";
}
}
r_flags.push_back(bpoints);
@@ -389,16 +392,18 @@ void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_d
}
void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<String> &p_paths) {
if (p_paths.has(p_path))
if (p_paths.has(p_path)) {
return;
}
p_paths.insert(p_path);
EditorFileSystemDirectory *dir;
int file_idx;
dir = EditorFileSystem::get_singleton()->find_file(p_path, &file_idx);
if (!dir)
if (!dir) {
return;
}
Vector<String> deps = dir->get_file_deps(file_idx);
@@ -410,16 +415,17 @@ void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set<S
void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude) {
da->list_dir_begin();
String cur_dir = da->get_current_dir().replace("\\", "/");
if (!cur_dir.ends_with("/"))
if (!cur_dir.ends_with("/")) {
cur_dir += "/";
}
String cur_dir_no_prefix = cur_dir.replace("res://", "");
Vector<String> dirs;
String f;
while ((f = da->get_next()) != "") {
if (da->current_is_dir())
if (da->current_is_dir()) {
dirs.push_back(f);
else {
} else {
String fullpath = cur_dir + f;
// Test also against path without res:// so that filters like `file.txt` can work.
String fullpath_no_prefix = cur_dir_no_prefix + f;
@@ -439,8 +445,9 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S
for (int i = 0; i < dirs.size(); ++i) {
String dir = dirs[i];
if (dir.begins_with("."))
if (dir.begins_with(".")) {
continue;
}
da->change_dir(dir);
_edit_files_with_filter(da, p_filters, r_list, exclude);
da->change_dir("..");
@@ -448,14 +455,16 @@ void EditorExportPlatform::_edit_files_with_filter(DirAccess *da, const Vector<S
}
void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude) {
if (p_filter == "")
if (p_filter == "") {
return;
}
Vector<String> split = p_filter.split(",");
Vector<String> filters;
for (int i = 0; i < split.size(); i++) {
String f = split[i].strip_edges();
if (f.empty())
if (f.empty()) {
continue;
}
filters.push_back(f);
}
@@ -649,8 +658,9 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
Vector<String> files = p_preset->get_files_to_export();
for (int i = 0; i < files.size(); i++) {
if (scenes_only && ResourceLoader::get_resource_type(files[i]) != "PackedScene")
if (scenes_only && ResourceLoader::get_resource_type(files[i]) != "PackedScene") {
continue;
}
_export_find_dependencies(files[i], paths);
}
@@ -777,8 +787,9 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
export_plugins.write[i]->_clear();
if (!do_export)
if (!do_export) {
break; //apologies, not exporting
}
}
//just store it as it comes
if (do_export) {
@@ -976,8 +987,9 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c
while (true) {
int got = ftmp->get_buffer(buf, bufsize);
if (got <= 0)
if (got <= 0) {
break;
}
f->store_buffer(buf, got);
}
@@ -1018,8 +1030,9 @@ Error EditorExportPlatform::save_zip(const Ref<EditorExportPreset> &p_preset, co
zd.zip = zip;
Error err = export_project_files(p_preset, _save_zip_file, &zd);
if (err != OK && err != ERR_SKIP)
if (err != OK && err != ERR_SKIP) {
ERR_PRINT("Failed to export project files");
}
zipClose(zip, nullptr);
@@ -1040,8 +1053,9 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
String host = EditorSettings::get_singleton()->get("network/debug/remote_host");
int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST)
if (p_flags & DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST) {
host = "localhost";
}
if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
int port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
@@ -1067,8 +1081,9 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
String bpoints;
for (const List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
bpoints += E->get().replace(" ", "%20");
if (E->next())
if (E->next()) {
bpoints += ",";
}
}
r_flags.push_back(bpoints);
@@ -1140,8 +1155,9 @@ void EditorExport::_save() {
}
void EditorExport::save_presets() {
if (block_save)
if (block_save) {
return;
}
save_timer->start();
}
@@ -1163,10 +1179,11 @@ Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) {
}
void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) {
if (p_at_pos < 0)
if (p_at_pos < 0) {
export_presets.push_back(p_preset);
else
} else {
export_presets.insert(p_at_pos, p_preset);
}
}
String EditorExportPlatform::test_etc2() const {
@@ -1221,16 +1238,18 @@ void EditorExport::load_config() {
Ref<ConfigFile> config;
config.instance();
Error err = config->load("res://export_presets.cfg");
if (err != OK)
if (err != OK) {
return;
}
block_save = true;
int index = 0;
while (true) {
String section = "preset." + itos(index);
if (!config->has_section(section))
if (!config->has_section(section)) {
break;
}
String platform = config->get_value(section, "platform");
@@ -1408,8 +1427,9 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset,
valid = dvalid || rvalid;
r_missing_templates = !valid;
if (!err.empty())
if (!err.empty()) {
r_error = err;
}
return valid;
}
@@ -1597,8 +1617,9 @@ void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, con
}
bool convert = GLOBAL_GET("editor/convert_text_resources_to_binary_on_export");
if (!convert)
if (!convert) {
return;
}
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpfile.res");
Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path);
if (err != OK) {