Add braces to C++ single-line loops and conditionals (NFC) (#2973)

This makes code easier to read and more consistent between C++ and Java.
Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
Peter Johnson
2020-12-28 12:58:06 -08:00
committed by GitHub
parent 0291a3ff56
commit 2aed432b4b
634 changed files with 10716 additions and 3938 deletions

View File

@@ -57,7 +57,9 @@ void NetworkTablesProvider::DisplayMenu() {
}
}
for (; depth > 0; --depth) ImGui::EndMenu();
for (; depth > 0; --depth) {
ImGui::EndMenu();
}
}
}
@@ -69,13 +71,16 @@ void NetworkTablesProvider::Update() {
// look for .type fields
wpi::StringRef eventName{event.name};
if (!eventName.endswith("/.type") || !event.value ||
!event.value->IsString())
!event.value->IsString()) {
continue;
}
auto tableName = eventName.drop_back(6);
// only handle ones where we have a builder
auto builderIt = m_typeMap.find(event.value->GetString());
if (builderIt == m_typeMap.end()) continue;
if (builderIt == m_typeMap.end()) {
continue;
}
if (event.flags & NT_NOTIFY_DELETE) {
auto it = std::find_if(
@@ -96,18 +101,26 @@ void NetworkTablesProvider::Update() {
// check for visible windows that need displays (typically this is due to
// file loading)
for (auto&& window : m_windows) {
if (!window->IsVisible() || window->HasView()) continue;
if (!window->IsVisible() || window->HasView()) {
continue;
}
auto id = window->GetId();
auto typeIt = m_typeCache.find(id);
if (typeIt == m_typeCache.end()) continue;
if (typeIt == m_typeCache.end()) {
continue;
}
// only handle ones where we have a builder
auto builderIt = m_typeMap.find(typeIt->second.GetName());
if (builderIt == m_typeMap.end()) continue;
if (builderIt == m_typeMap.end()) {
continue;
}
auto entry = GetOrCreateView(
builderIt->second, nt::GetEntry(m_nt.GetInstance(), id + "/.type"), id);
if (entry) Show(entry, window.get());
if (entry) {
Show(entry, window.get());
}
}
}
@@ -125,20 +138,29 @@ void NetworkTablesProvider::Show(ViewEntry* entry, Window* window) {
}
// get or create model
if (!entry->modelEntry->model)
if (!entry->modelEntry->model) {
entry->modelEntry->model =
entry->modelEntry->createModel(m_nt.GetInstance(), entry->name.c_str());
if (!entry->modelEntry->model) return;
}
if (!entry->modelEntry->model) {
return;
}
// the window might exist and we're just not associated to it yet
if (!window) window = GetOrAddWindow(entry->name, true);
if (!window) return;
if (!window) {
window = GetOrAddWindow(entry->name, true);
}
if (!window) {
return;
}
entry->window = window;
// create view
auto view = entry->createView(window, entry->modelEntry->model.get(),
entry->name.c_str());
if (!view) return;
if (!view) {
return;
}
window->SetView(std::move(view));
entry->window->SetVisible(true);