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

@@ -29,17 +29,23 @@ Compressor::Compressor(int pcmID) : m_module(pcmID) {
}
void Compressor::Start() {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
SetClosedLoopControl(true);
}
void Compressor::Stop() {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
SetClosedLoopControl(false);
}
bool Compressor::Enabled() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -53,7 +59,9 @@ bool Compressor::Enabled() const {
}
bool Compressor::GetPressureSwitchValue() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -67,7 +75,9 @@ bool Compressor::GetPressureSwitchValue() const {
}
double Compressor::GetCompressorCurrent() const {
if (StatusIsFatal()) return 0;
if (StatusIsFatal()) {
return 0;
}
int32_t status = 0;
double value;
@@ -81,7 +91,9 @@ double Compressor::GetCompressorCurrent() const {
}
void Compressor::SetClosedLoopControl(bool on) {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_SetCompressorClosedLoopControl(m_compressorHandle, on, &status);
@@ -92,7 +104,9 @@ void Compressor::SetClosedLoopControl(bool on) {
}
bool Compressor::GetClosedLoopControl() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -106,7 +120,9 @@ bool Compressor::GetClosedLoopControl() const {
}
bool Compressor::GetCompressorCurrentTooHighFault() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -120,7 +136,9 @@ bool Compressor::GetCompressorCurrentTooHighFault() const {
}
bool Compressor::GetCompressorCurrentTooHighStickyFault() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -135,7 +153,9 @@ bool Compressor::GetCompressorCurrentTooHighStickyFault() const {
}
bool Compressor::GetCompressorShortedStickyFault() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -149,7 +169,9 @@ bool Compressor::GetCompressorShortedStickyFault() const {
}
bool Compressor::GetCompressorShortedFault() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -163,7 +185,9 @@ bool Compressor::GetCompressorShortedFault() const {
}
bool Compressor::GetCompressorNotConnectedStickyFault() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -177,7 +201,9 @@ bool Compressor::GetCompressorNotConnectedStickyFault() const {
}
bool Compressor::GetCompressorNotConnectedFault() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value;
@@ -191,7 +217,9 @@ bool Compressor::GetCompressorNotConnectedFault() const {
}
void Compressor::ClearAllPCMStickyFaults() {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_ClearAllPCMStickyFaults(m_module, &status);
@@ -201,17 +229,20 @@ void Compressor::ClearAllPCMStickyFaults() {
}
}
int Compressor::GetModule() const { return m_module; }
int Compressor::GetModule() const {
return m_module;
}
void Compressor::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Compressor");
builder.AddBooleanProperty(
"Enabled", [=]() { return Enabled(); },
[=](bool value) {
if (value)
if (value) {
Start();
else
} else {
Stop();
}
});
builder.AddBooleanProperty(
"Pressure switch", [=]() { return GetPressureSwitchValue(); }, nullptr);