If an else has a brace on one side, it should have it on both according to Google style guidelines "readability/braces"

This commit is contained in:
Micke Prag 2012-06-15 16:20:31 +02:00
parent 31ee1880ad
commit 2fc9d470dd
6 changed files with 31 additions and 61 deletions

View file

@ -55,8 +55,7 @@ void ClientCommunicationHandler::run() {
if(strReturn == L"") {
msg.addArgument(intReturn);
}
else {
} else {
msg.addArgument(strReturn);
}
msg.append(L"\n");

View file

@ -93,15 +93,14 @@ int DeviceManager::getDeviceLastSentCommand(int deviceId, int methodsSupported)
int DeviceManager::setDeviceLastSentCommand(int deviceId, int command, const std::wstring &value) {
TelldusCore::MutexLocker deviceListLocker(&d->lock);
if (!d->devices.size()) {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
DeviceMap::iterator it = d->devices.find(deviceId);
if (it != d->devices.end()) {
TelldusCore::MutexLocker deviceLocker(it->second);
d->set.setDeviceState(deviceId, command, value);
it->second->setLastSentCommand(command, value);
}
else {
} else {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
return TELLSTICK_SUCCESS;
@ -208,8 +207,7 @@ int DeviceManager::setDeviceModel(int deviceId, const std::wstring &model) {
return ret;
}
it->second->setModel(model);
}
else {
} else {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
@ -242,8 +240,7 @@ int DeviceManager::setDeviceName(int deviceId, const std::wstring &name) {
return ret;
}
it->second->setName(name);
}
else {
} else {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
@ -279,8 +276,7 @@ int DeviceManager::setDeviceParameter(int deviceId, const std::wstring &name, co
return ret;
}
it->second->setParameter(name, value);
}
else {
} else {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
@ -313,8 +309,7 @@ int DeviceManager::setDeviceProtocol(int deviceId, const std::wstring &protocol)
return ret;
}
it->second->setProtocolName(protocol);
}
else {
} else {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
@ -424,8 +419,7 @@ int DeviceManager::doAction(int deviceId, int action, unsigned char data) {
deviceLocker = std::auto_ptr<TelldusCore::MutexLocker>(new TelldusCore::MutexLocker(it->second));
device = it->second;
} // devicelist unlocked
}
else {
} else {
Controller *controller = d->controllerManager->getBestControllerById(device->getPreferredControllerId());
if(!controller) {
Log::warning("Trying to execute action, but no controller found. Rescanning USB ports");
@ -487,17 +481,14 @@ int DeviceManager::doGroupAction(const std::wstring devices, const int action, c
if(type == TELLSTICK_TYPE_SCENE && (action == TELLSTICK_TURNON || action == TELLSTICK_EXECUTE)) {
deviceReturnValue = executeScene(singledevice, groupDeviceId);
}
else if(type == TELLSTICK_TYPE_GROUP) {
} else if(type == TELLSTICK_TYPE_GROUP) {
if(deviceId != 0) {
int childType = DeviceManager::getDeviceType(deviceId);
if(childType == TELLSTICK_TYPE_DEVICE) {
deviceReturnValue = doAction(deviceId, action, data);
}
else if(childType == TELLSTICK_TYPE_SCENE) {
} else if(childType == TELLSTICK_TYPE_SCENE) {
deviceReturnValue = doGroupAction(DeviceManager::getDeviceParameter(deviceId, L"devices", L""), action, data, childType, deviceId, duplicateDeviceIds); // TODO make scenes infinite loops-safe
}
else {
} else {
// group (in group)
deviceReturnValue = doGroupAction(DeviceManager::getDeviceParameter(deviceId, L"devices", L""), action, data, childType, deviceId, duplicateDeviceIds);
@ -509,8 +500,7 @@ int DeviceManager::doGroupAction(const std::wstring devices, const int action, c
}
}
}
}
else {
} else {
deviceReturnValue = TELLSTICK_ERROR_DEVICE_NOT_FOUND; // Probably incorrectly formatted parameter
}
}
@ -577,8 +567,7 @@ int DeviceManager::removeDevice(int deviceId) {
if (it != d->devices.end()) {
device = it->second;
d->devices.erase(it); // remove from list, keep reference
}
else {
} else {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
}

View file

@ -85,19 +85,16 @@ void EventUpdateManager::sendMessageToClients(EventUpdateData *data) {
msg.addArgument(data->deviceId);
msg.addArgument(data->eventState);
msg.addArgument(data->eventValue); // string
}
else if(data->messageType == L"TDDeviceChangeEvent") {
} else if(data->messageType == L"TDDeviceChangeEvent") {
msg.addArgument("TDDeviceChangeEvent");
msg.addArgument(data->deviceId);
msg.addArgument(data->eventDeviceChanges);
msg.addArgument(data->eventChangeType);
}
else if(data->messageType == L"TDRawDeviceEvent") {
} else if(data->messageType == L"TDRawDeviceEvent") {
msg.addArgument("TDRawDeviceEvent");
msg.addArgument(data->eventValue); // string
msg.addArgument(data->controllerId);
}
else if(data->messageType == L"TDSensorEvent") {
} else if(data->messageType == L"TDSensorEvent") {
msg.addArgument("TDSensorEvent");
msg.addArgument(data->protocol);
msg.addArgument(data->model);
@ -105,8 +102,7 @@ void EventUpdateManager::sendMessageToClients(EventUpdateData *data) {
msg.addArgument(data->dataType);
msg.addArgument(data->value);
msg.addArgument(data->timestamp);
}
else if(data->messageType == L"TDControllerEvent") {
} else if(data->messageType == L"TDControllerEvent") {
msg.addArgument("TDControllerEvent");
msg.addArgument(data->controllerId);
msg.addArgument(data->eventState);
@ -117,8 +113,7 @@ void EventUpdateManager::sendMessageToClients(EventUpdateData *data) {
(*it)->write(msg);
it++;
}
else {
} else {
// connection is dead, remove it
delete *it;
it = d->clients.erase(it);

View file

@ -121,14 +121,11 @@ std::string ProtocolEverflourish::decodeData(const ControllerMessage &dataMsg) {
retString << "class:command;protocol:everflourish;model:selflearning;house:" << house << ";unit:" << unit << ";method:";
if(method == 0) {
retString << "turnoff;";
}
else if(method == 15) {
} else if(method == 15) {
retString << "turnon;";
}
else if(method == 10) {
} else if(method == 10) {
retString << "learn;";
}
else {
} else {
// not everflourish
return "";
}

View file

@ -172,8 +172,7 @@ std::string ProtocolNexa::decodeData(const ControllerMessage& dataMsg) {
if(TelldusCore::comparei(dataMsg.model(), L"selflearning")) {
// selflearning
return decodeDataSelfLearning(allData);
}
else {
} else {
// codeswitch
return decodeDataCodeSwitch(allData);
}
@ -206,11 +205,9 @@ std::string ProtocolNexa::decodeDataSelfLearning(uint32_t allData) {
retString << "class:command;protocol:arctech;model:selflearning;house:" << house << ";unit:" << unit << ";group:" << group << ";method:";
if(method == 1) {
retString << "turnon;";
}
else if(method == 0) {
} else if(method == 0) {
retString << "turnoff;";
}
else {
} else {
// not arctech selflearning
return "";
}
@ -254,14 +251,11 @@ std::string ProtocolNexa::decodeDataCodeSwitch(uint32_t allData) {
if(method == 6) {
retString << ";unit:" << unit << ";method:turnoff;";
}
else if(method == 14) {
} else if(method == 14) {
retString << ";unit:" << unit << ";method:turnon;";
}
else if(method == 15) {
} else if(method == 15) {
retString << ";method:bell;";
}
else {
} else {
// not arctech codeswitch
return "";
}

View file

@ -71,11 +71,9 @@ std::string ProtocolSartano::decodeData(const ControllerMessage &dataMsg) {
if(method1 == 0 && method2 == 1) {
method = 0; // off
}
else if(method1 == 1 && method2 == 0) {
} else if(method1 == 1 && method2 == 0) {
method = 1; // on
}
else {
} else {
return "";
}
@ -90,8 +88,7 @@ std::string ProtocolSartano::decodeData(const ControllerMessage &dataMsg) {
for(int i = 0; i < 10; i++) {
if((code & mask) != 0) {
retString << 1;
}
else {
} else {
retString << 0;
}
mask >>= 1;
@ -100,8 +97,7 @@ std::string ProtocolSartano::decodeData(const ControllerMessage &dataMsg) {
if(method == 0) {
retString << "turnoff;";
}
else {
} else {
retString << "turnon;";
}