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 @@ DigitalOutput::DigitalOutput(int channel) {
}
DigitalOutput::~DigitalOutput() {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
// Disable the PWM in case it was running.
DisablePWM();
@@ -50,7 +52,9 @@ DigitalOutput::~DigitalOutput() {
}
void DigitalOutput::Set(bool value) {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_SetDIO(m_handle, value, &status);
@@ -58,7 +62,9 @@ void DigitalOutput::Set(bool value) {
}
bool DigitalOutput::Get() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool val = HAL_GetDIO(m_handle, &status);
@@ -66,18 +72,26 @@ bool DigitalOutput::Get() const {
return val;
}
HAL_Handle DigitalOutput::GetPortHandleForRouting() const { return m_handle; }
HAL_Handle DigitalOutput::GetPortHandleForRouting() const {
return m_handle;
}
AnalogTriggerType DigitalOutput::GetAnalogTriggerTypeForRouting() const {
return (AnalogTriggerType)0;
}
bool DigitalOutput::IsAnalogTrigger() const { return false; }
bool DigitalOutput::IsAnalogTrigger() const {
return false;
}
int DigitalOutput::GetChannel() const { return m_channel; }
int DigitalOutput::GetChannel() const {
return m_channel;
}
void DigitalOutput::Pulse(double length) {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_Pulse(m_handle, length, &status);
@@ -85,7 +99,9 @@ void DigitalOutput::Pulse(double length) {
}
bool DigitalOutput::IsPulsing() const {
if (StatusIsFatal()) return false;
if (StatusIsFatal()) {
return false;
}
int32_t status = 0;
bool value = HAL_IsPulsing(m_handle, &status);
@@ -94,7 +110,9 @@ bool DigitalOutput::IsPulsing() const {
}
void DigitalOutput::SetPWMRate(double rate) {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_SetDigitalPWMRate(rate, &status);
@@ -102,26 +120,38 @@ void DigitalOutput::SetPWMRate(double rate) {
}
void DigitalOutput::EnablePWM(double initialDutyCycle) {
if (m_pwmGenerator != HAL_kInvalidHandle) return;
if (m_pwmGenerator != HAL_kInvalidHandle) {
return;
}
int32_t status = 0;
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
m_pwmGenerator = HAL_AllocateDigitalPWM(&status);
wpi_setHALError(status);
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
HAL_SetDigitalPWMDutyCycle(m_pwmGenerator, initialDutyCycle, &status);
wpi_setHALError(status);
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, m_channel, &status);
wpi_setHALError(status);
}
void DigitalOutput::DisablePWM() {
if (StatusIsFatal()) return;
if (m_pwmGenerator == HAL_kInvalidHandle) return;
if (StatusIsFatal()) {
return;
}
if (m_pwmGenerator == HAL_kInvalidHandle) {
return;
}
int32_t status = 0;
@@ -137,7 +167,9 @@ void DigitalOutput::DisablePWM() {
}
void DigitalOutput::UpdateDutyCycle(double dutyCycle) {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_SetDigitalPWMDutyCycle(m_pwmGenerator, dutyCycle, &status);