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

@@ -42,7 +42,9 @@ void glass::DisplayLEDDisplay(LEDDisplayModel* model, int index) {
ImGui::Combo("Start", start, options, 4);
}
ImGui::Checkbox("Serpentine", serpentine);
if (*numColumns < 1) *numColumns = 1;
if (*numColumns < 1) {
*numColumns = 1;
}
ImGui::PopItemWidth();
// show as LED indicators
@@ -51,13 +53,17 @@ void glass::DisplayLEDDisplay(LEDDisplayModel* model, int index) {
storage.SetData(std::make_shared<IndicatorData>());
iData = storage.GetData<IndicatorData>();
}
if (length > static_cast<int>(iData->values.size()))
if (length > static_cast<int>(iData->values.size())) {
iData->values.resize(length);
if (length > static_cast<int>(iData->colors.size()))
}
if (length > static_cast<int>(iData->colors.size())) {
iData->colors.resize(length);
}
if (!running) {
iData->colors[0] = IM_COL32(128, 128, 128, 255);
for (int j = 0; j < length; ++j) iData->values[j] = -1;
for (int j = 0; j < length; ++j) {
iData->values[j] = -1;
}
} else {
for (int j = 0; j < length; ++j) {
iData->values[j] = j + 1;
@@ -79,10 +85,14 @@ void glass::DisplayLEDDisplays(LEDDisplaysModel* model) {
model->ForEachLEDDisplay([&](LEDDisplayModel& display, int i) {
hasAny = true;
if (model->GetNumLEDDisplays() > 1) ImGui::Text("LEDs[%d]", i);
if (model->GetNumLEDDisplays() > 1) {
ImGui::Text("LEDs[%d]", i);
}
PushID(i);
DisplayLEDDisplay(&display, i);
PopID();
});
if (!hasAny) ImGui::Text("No addressable LEDs");
if (!hasAny) {
ImGui::Text("No addressable LEDs");
}
}