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

@@ -62,10 +62,14 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, int center,
}
}
AnalogGyro::~AnalogGyro() { HAL_FreeAnalogGyro(m_gyroHandle); }
AnalogGyro::~AnalogGyro() {
HAL_FreeAnalogGyro(m_gyroHandle);
}
double AnalogGyro::GetAngle() const {
if (StatusIsFatal()) return 0.0;
if (StatusIsFatal()) {
return 0.0;
}
int32_t status = 0;
double value = HAL_GetAnalogGyroAngle(m_gyroHandle, &status);
wpi_setHALError(status);
@@ -73,7 +77,9 @@ double AnalogGyro::GetAngle() const {
}
double AnalogGyro::GetRate() const {
if (StatusIsFatal()) return 0.0;
if (StatusIsFatal()) {
return 0.0;
}
int32_t status = 0;
double value = HAL_GetAnalogGyroRate(m_gyroHandle, &status);
wpi_setHALError(status);
@@ -81,7 +87,9 @@ double AnalogGyro::GetRate() const {
}
int AnalogGyro::GetCenter() const {
if (StatusIsFatal()) return 0;
if (StatusIsFatal()) {
return 0;
}
int32_t status = 0;
int value = HAL_GetAnalogGyroCenter(m_gyroHandle, &status);
wpi_setHALError(status);
@@ -89,7 +97,9 @@ int AnalogGyro::GetCenter() const {
}
double AnalogGyro::GetOffset() const {
if (StatusIsFatal()) return 0.0;
if (StatusIsFatal()) {
return 0.0;
}
int32_t status = 0;
double value = HAL_GetAnalogGyroOffset(m_gyroHandle, &status);
wpi_setHALError(status);
@@ -104,21 +114,27 @@ void AnalogGyro::SetSensitivity(double voltsPerDegreePerSecond) {
}
void AnalogGyro::SetDeadband(double volts) {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_SetAnalogGyroDeadband(m_gyroHandle, volts, &status);
wpi_setHALError(status);
}
void AnalogGyro::Reset() {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_ResetAnalogGyro(m_gyroHandle, &status);
wpi_setHALError(status);
}
void AnalogGyro::InitGyro() {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
if (m_gyroHandle == HAL_kInvalidHandle) {
int32_t status = 0;
m_gyroHandle = HAL_InitializeAnalogGyro(m_analog->m_port, &status);
@@ -153,7 +169,9 @@ void AnalogGyro::InitGyro() {
}
void AnalogGyro::Calibrate() {
if (StatusIsFatal()) return;
if (StatusIsFatal()) {
return;
}
int32_t status = 0;
HAL_CalibrateAnalogGyro(m_gyroHandle, &status);
wpi_setHALError(status);