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

@@ -98,7 +98,9 @@ void WriteIni(ImGuiTextBuffer* out) {
static void* Mechanism2DReadOpen(ImGuiContext* ctx,
ImGuiSettingsHandler* handler,
const char* name) {
if (name == wpi::StringRef{"Mechanism2D"}) return &mechanism2DInfo;
if (name == wpi::StringRef{"Mechanism2D"}) {
return &mechanism2DInfo;
}
return nullptr;
}
@@ -109,7 +111,9 @@ static void Mechanism2DReadLine(ImGuiContext* ctx,
auto [name, value] = line.split('=');
name = name.trim();
value = value.trim();
if (entry == &mechanism2DInfo) ReadIni(name, value);
if (entry == &mechanism2DInfo) {
ReadIni(name, value);
}
}
static void Mechanism2DWriteAll(ImGuiContext* ctx,
@@ -166,20 +170,28 @@ static void buildDrawList(float startXLocation, float startYLocation,
minSize = ImGui::GetWindowHeight() > ImGui::GetWindowWidth()
? ImGui::GetWindowWidth()
: ImGui::GetWindowHeight();
if (devHandle == 0) devHandle = HALSIM_GetSimDeviceHandle("Mechanism2D");
if (devHandle == 0) {
devHandle = HALSIM_GetSimDeviceHandle("Mechanism2D");
}
// Get the length
if (!lengthHandle)
if (!lengthHandle) {
lengthHandle = HALSIM_GetSimValueHandle(
devHandle, (bodyConfig.name + "/length").c_str());
if (lengthHandle) length = lengthHandle.Get();
}
if (lengthHandle) {
length = lengthHandle.Get();
}
if (length <= 0) {
length = bodyConfig.length;
}
// Get the angle
if (!angleHandle)
if (!angleHandle) {
angleHandle = HALSIM_GetSimValueHandle(
devHandle, (bodyConfig.name + "/angle").c_str());
if (angleHandle) angle = angleHandle.Get();
}
if (angleHandle) {
angle = angleHandle.Get();
}
// Calculate the next angle to go to
float angleToGoTo = angle + bodyConfig.angle + previousAngle;
// Draw the first line and get the ending coordinates