mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
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:
@@ -14,7 +14,9 @@ using namespace frc;
|
||||
|
||||
unsigned notifierCounter;
|
||||
|
||||
void notifierHandler(void*) { notifierCounter++; }
|
||||
void notifierHandler(void*) {
|
||||
notifierCounter++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the Wait function works
|
||||
|
||||
@@ -23,7 +23,9 @@ class TestEnvironment : public testing::Environment {
|
||||
void SetUp() override {
|
||||
/* Only set up once. This allows gtest_repeat to be used to
|
||||
automatically repeat tests. */
|
||||
if (m_alreadySetUp) return;
|
||||
if (m_alreadySetUp) {
|
||||
return;
|
||||
}
|
||||
m_alreadySetUp = true;
|
||||
|
||||
if (!HAL_Initialize(500, 0)) {
|
||||
|
||||
@@ -19,24 +19,38 @@ MockCommand::MockCommand() {
|
||||
m_interruptedCount = 0;
|
||||
}
|
||||
|
||||
bool MockCommand::HasInitialized() { return GetInitializeCount() > 0; }
|
||||
bool MockCommand::HasInitialized() {
|
||||
return GetInitializeCount() > 0;
|
||||
}
|
||||
|
||||
bool MockCommand::HasEnd() { return GetEndCount() > 0; }
|
||||
bool MockCommand::HasEnd() {
|
||||
return GetEndCount() > 0;
|
||||
}
|
||||
|
||||
bool MockCommand::HasInterrupted() { return GetInterruptedCount() > 0; }
|
||||
bool MockCommand::HasInterrupted() {
|
||||
return GetInterruptedCount() > 0;
|
||||
}
|
||||
|
||||
void MockCommand::Initialize() { ++m_initializeCount; }
|
||||
void MockCommand::Initialize() {
|
||||
++m_initializeCount;
|
||||
}
|
||||
|
||||
void MockCommand::Execute() { ++m_executeCount; }
|
||||
void MockCommand::Execute() {
|
||||
++m_executeCount;
|
||||
}
|
||||
|
||||
bool MockCommand::IsFinished() {
|
||||
++m_isFinishedCount;
|
||||
return IsHasFinished();
|
||||
}
|
||||
|
||||
void MockCommand::End() { ++m_endCount; }
|
||||
void MockCommand::End() {
|
||||
++m_endCount;
|
||||
}
|
||||
|
||||
void MockCommand::Interrupted() { ++m_interruptedCount; }
|
||||
void MockCommand::Interrupted() {
|
||||
++m_interruptedCount;
|
||||
}
|
||||
|
||||
void MockCommand::ResetCounters() {
|
||||
m_initializeCount = 0;
|
||||
|
||||
@@ -20,30 +20,42 @@ void MockConditionalCommand::SetCondition(bool condition) {
|
||||
m_condition = condition;
|
||||
}
|
||||
|
||||
bool MockConditionalCommand::Condition() { return m_condition; }
|
||||
bool MockConditionalCommand::Condition() {
|
||||
return m_condition;
|
||||
}
|
||||
|
||||
bool MockConditionalCommand::HasInitialized() {
|
||||
return GetInitializeCount() > 0;
|
||||
}
|
||||
|
||||
bool MockConditionalCommand::HasEnd() { return GetEndCount() > 0; }
|
||||
bool MockConditionalCommand::HasEnd() {
|
||||
return GetEndCount() > 0;
|
||||
}
|
||||
|
||||
bool MockConditionalCommand::HasInterrupted() {
|
||||
return GetInterruptedCount() > 0;
|
||||
}
|
||||
|
||||
void MockConditionalCommand::Initialize() { ++m_initializeCount; }
|
||||
void MockConditionalCommand::Initialize() {
|
||||
++m_initializeCount;
|
||||
}
|
||||
|
||||
void MockConditionalCommand::Execute() { ++m_executeCount; }
|
||||
void MockConditionalCommand::Execute() {
|
||||
++m_executeCount;
|
||||
}
|
||||
|
||||
bool MockConditionalCommand::IsFinished() {
|
||||
++m_isFinishedCount;
|
||||
return ConditionalCommand::IsFinished();
|
||||
}
|
||||
|
||||
void MockConditionalCommand::End() { ++m_endCount; }
|
||||
void MockConditionalCommand::End() {
|
||||
++m_endCount;
|
||||
}
|
||||
|
||||
void MockConditionalCommand::Interrupted() { ++m_interruptedCount; }
|
||||
void MockConditionalCommand::Interrupted() {
|
||||
++m_interruptedCount;
|
||||
}
|
||||
|
||||
void MockConditionalCommand::ResetCounters() {
|
||||
m_initializeCount = 0;
|
||||
|
||||
@@ -24,14 +24,15 @@ static void LoggerFunc(unsigned int level, const char* file, unsigned int line,
|
||||
}
|
||||
|
||||
wpi::StringRef levelmsg;
|
||||
if (level >= 50)
|
||||
if (level >= 50) {
|
||||
levelmsg = "CRITICAL: ";
|
||||
else if (level >= 40)
|
||||
} else if (level >= 40) {
|
||||
levelmsg = "ERROR: ";
|
||||
else if (level >= 30)
|
||||
} else if (level >= 30) {
|
||||
levelmsg = "WARNING: ";
|
||||
else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
oss << "DS: " << levelmsg << msg << " (" << file << ':' << line << ")\n";
|
||||
wpi::errs() << oss.str();
|
||||
}
|
||||
@@ -50,7 +51,9 @@ static void generateEnabledDsPacket(wpi::SmallVectorImpl<uint8_t>& data,
|
||||
using namespace frc;
|
||||
|
||||
void MockDS::start() {
|
||||
if (m_active) return;
|
||||
if (m_active) {
|
||||
return;
|
||||
}
|
||||
m_active = true;
|
||||
m_thread = std::thread([&]() {
|
||||
wpi::Logger logger(LoggerFunc);
|
||||
@@ -82,5 +85,7 @@ void MockDS::start() {
|
||||
|
||||
void MockDS::stop() {
|
||||
m_active = false;
|
||||
if (m_thread.joinable()) m_thread.join();
|
||||
if (m_thread.joinable()) {
|
||||
m_thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user