Fixed most issues from codacy (#3050)

This commit is contained in:
ctrlaltca 2018-01-27 19:31:44 +01:00 committed by Zach H
parent 3c3e6ae68a
commit e127cb74b6
16 changed files with 26 additions and 33 deletions

View file

@ -37,7 +37,7 @@ private:
int flags; int flags;
public: public:
compareFunctor(int _flags) : flags(_flags) explicit compareFunctor(int _flags) : flags(_flags)
{ {
} }
inline bool operator()(CardItem *a, CardItem *b) const inline bool operator()(CardItem *a, CardItem *b) const

View file

@ -35,7 +35,7 @@ const FilterItemList *LogicMap::findTypeList(CardFilter::Type type) const
{ {
QList<FilterItemList *>::const_iterator i; QList<FilterItemList *>::const_iterator i;
for (i = childNodes.constBegin(); i != childNodes.constEnd(); i++) { for (i = childNodes.constBegin(); i != childNodes.constEnd(); ++i) {
if ((*i)->type == type) { if ((*i)->type == type) {
return *i; return *i;
} }
@ -49,7 +49,7 @@ FilterItemList *LogicMap::typeList(CardFilter::Type type)
QList<FilterItemList *>::iterator i; QList<FilterItemList *>::iterator i;
int count = 0; int count = 0;
for (i = childNodes.begin(); i != childNodes.end(); i++) { for (i = childNodes.begin(); i != childNodes.end(); ++i) {
if ((*i)->type == type) { if ((*i)->type == type) {
break; break;
} }

View file

@ -220,7 +220,6 @@ QModelIndex FilterTreeModel::parent(const QModelIndex &ind) const
{ {
const FilterTreeNode *node; const FilterTreeNode *node;
FilterTreeNode *parent; FilterTreeNode *parent;
int row;
QModelIndex idx; QModelIndex idx;
if (!ind.isValid()) if (!ind.isValid())
@ -232,7 +231,7 @@ QModelIndex FilterTreeModel::parent(const QModelIndex &ind) const
parent = node->parent(); parent = node->parent();
if (parent) { if (parent) {
row = parent->index(); int row = parent->index();
if (row < 0) if (row < 0)
return QModelIndex(); return QModelIndex();
idx = createIndex(row, 0, parent); idx = createIndex(row, 0, parent);

View file

@ -9,7 +9,7 @@
#include <QTextCursor> #include <QTextCursor>
#include <QWidget> #include <QWidget>
LineEditCompleter::LineEditCompleter(QWidget *parent) : QLineEdit(parent) LineEditCompleter::LineEditCompleter(QWidget *parent) : QLineEdit(parent), c(nullptr)
{ {
} }

View file

@ -796,6 +796,7 @@ MessageLogWidget::MessageLogWidget(const TabSupervisor *_tabSupervisor,
const UserlistProxy *_userlistProxy, const UserlistProxy *_userlistProxy,
TabGame *_game, TabGame *_game,
QWidget *parent) QWidget *parent)
: ChatView(_tabSupervisor, _userlistProxy, _game, true, parent), currentContext(MessageContext_None) : ChatView(_tabSupervisor, _userlistProxy, _game, true, parent), mulliganNumber(0),
currentContext(MessageContext_None)
{ {
} }

View file

@ -20,7 +20,6 @@ private:
CardInfo *card; CardInfo *card;
QList<CardSet *> sortedSets; QList<CardSet *> sortedSets;
int setIndex; int setIndex;
bool hq;
public: public:
PictureToLoad(CardInfo *_card = 0); PictureToLoad(CardInfo *_card = 0);

View file

@ -3,7 +3,7 @@
#include "update_downloader.h" #include "update_downloader.h"
UpdateDownloader::UpdateDownloader(QObject *parent) : QObject(parent) UpdateDownloader::UpdateDownloader(QObject *parent) : QObject(parent), response(nullptr)
{ {
netMan = new QNetworkAccessManager(this); netMan = new QNetworkAccessManager(this);
} }

View file

@ -426,7 +426,7 @@ void Server::externalJoinGameCommandReceived(const Command_JoinGame &cmd,
ResponseContainer responseContainer(cmdId); ResponseContainer responseContainer(cmdId);
Response::ResponseCode responseCode = room->processJoinGameCommand(cmd, responseContainer, userInterface); Response::ResponseCode responseCode = room->processJoinGameCommand(cmd, responseContainer, userInterface);
userInterface->sendResponseContainer(responseContainer, responseCode); userInterface->sendResponseContainer(responseContainer, responseCode);
} catch (Response::ResponseCode code) { } catch (Response::ResponseCode &code) {
Response response; Response response;
response.set_cmd_id(cmdId); response.set_cmd_id(cmdId);
response.set_response_code(code); response.set_response_code(code);

View file

@ -89,7 +89,7 @@ Server_Player::Server_Player(Server_Game *_game,
bool _spectator, bool _spectator,
Server_AbstractUserInterface *_userInterface) Server_AbstractUserInterface *_userInterface)
: ServerInfo_User_Container(_userInfo), game(_game), userInterface(_userInterface), deck(0), pingTime(0), : ServerInfo_User_Container(_userInfo), game(_game), userInterface(_userInterface), deck(0), pingTime(0),
playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false), playerId(_playerId), spectator(_spectator), initialCards(0), nextCardId(0), readyStart(false), conceded(false),
sideboardLocked(true) sideboardLocked(true)
{ {
} }
@ -326,7 +326,7 @@ private:
int x; int x;
public: public:
MoveCardCompareFunctor(int _x) : x(_x) explicit MoveCardCompareFunctor(int _x) : x(_x)
{ {
} }
inline bool operator()(QPair<Server_Card *, int> a, QPair<Server_Card *, int> b) inline bool operator()(QPair<Server_Card *, int> a, QPair<Server_Card *, int> b)
@ -451,7 +451,6 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges,
} }
} }
int publicNewX;
if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) { if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) {
Event_DestroyCard event; Event_DestroyCard event;
event.set_zone_name(startzone->getName().toStdString()); event.set_zone_name(startzone->getName().toStdString());
@ -504,7 +503,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges,
if (startzone->getType() == ServerInfo_Zone::HiddenZone) if (startzone->getType() == ServerInfo_Zone::HiddenZone)
privatePosition = position; privatePosition = position;
publicNewX = newX; int publicNewX = newX;
Event_MoveCard eventOthers; Event_MoveCard eventOthers;
eventOthers.set_start_player_id(startzone->getPlayer()->getPlayerId()); eventOthers.set_start_player_id(startzone->getPlayer()->getPlayerId());
@ -674,7 +673,7 @@ Server_Player::cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &r
try { try {
newDeck = game->getRoom()->getServer()->getDatabaseInterface()->getDeckFromDatabase(cmd.deck_id(), newDeck = game->getRoom()->getServer()->getDatabaseInterface()->getDeckFromDatabase(cmd.deck_id(),
userInfo->id()); userInfo->id());
} catch (Response::ResponseCode r) { } catch (Response::ResponseCode &r) {
return r; return r;
} }
} else } else
@ -1600,9 +1599,8 @@ Server_Player::cmdRevealCards(const Command_RevealCards &cmd, ResponseContainer
if (conceded) if (conceded)
return Response::RespContextError; return Response::RespContextError;
Server_Player *otherPlayer = 0;
if (cmd.has_player_id()) { if (cmd.has_player_id()) {
otherPlayer = game->getPlayers().value(cmd.player_id()); Server_Player *otherPlayer = game->getPlayers().value(cmd.player_id());
if (!otherPlayer) if (!otherPlayer)
return Response::RespNameNotFound; return Response::RespNameNotFound;
} }

View file

@ -115,11 +115,6 @@ int main(int argc, char *argv[])
app.setApplicationName("Servatrice"); app.setApplicationName("Servatrice");
app.setApplicationVersion(VERSION_STRING); app.setApplicationVersion(VERSION_STRING);
bool testRandom = false;
bool testHashFunction = false;
bool logToConsole = false;
QString configPath;
QCommandLineParser parser; QCommandLineParser parser;
parser.addHelpOption(); parser.addHelpOption();
parser.addVersionOption(); parser.addVersionOption();
@ -138,10 +133,10 @@ int main(int argc, char *argv[])
parser.process(app); parser.process(app);
testRandom = parser.isSet(testRandomOpt); bool testRandom = parser.isSet(testRandomOpt);
testHashFunction = parser.isSet(testHashFunctionOpt); bool testHashFunction = parser.isSet(testHashFunctionOpt);
logToConsole = parser.isSet(logToConsoleOpt); bool logToConsole = parser.isSet(logToConsoleOpt);
configPath = parser.value(configPathOpt); QString configPath = parser.value(configPathOpt);
qRegisterMetaType<QList<int>>("QList<int>"); qRegisterMetaType<QList<int>>("QList<int>");

View file

@ -178,7 +178,9 @@ void Servatrice_IslServer::incomingConnection(qintptr socketDescriptor)
QMetaObject::invokeMethod(interface, "initServer", Qt::QueuedConnection); QMetaObject::invokeMethod(interface, "initServer", Qt::QueuedConnection);
} }
Servatrice::Servatrice(QObject *parent) : Server(parent), uptime(0), shutdownTimer(0), isFirstShutdownMessage(true) Servatrice::Servatrice(QObject *parent)
: Server(parent), authenticationMethod(AuthenticationNone), uptime(0), shutdownTimer(0),
isFirstShutdownMessage(true)
{ {
qRegisterMetaType<QSqlDatabase>("QSqlDatabase"); qRegisterMetaType<QSqlDatabase>("QSqlDatabase");
} }
@ -398,7 +400,7 @@ bool Servatrice::initServer()
else else
throw QString("islServer->listen()"); throw QString("islServer->listen()");
} }
} catch (QString error) { } catch (QString &error) {
qDebug() << "ERROR --" << error; qDebug() << "ERROR --" << error;
return false; return false;
} }

View file

@ -3,7 +3,7 @@
#include <QThread> #include <QThread>
Servatrice_ConnectionPool::Servatrice_ConnectionPool(Servatrice_DatabaseInterface *_databaseInterface) Servatrice_ConnectionPool::Servatrice_ConnectionPool(Servatrice_DatabaseInterface *_databaseInterface)
: databaseInterface(_databaseInterface), clientCount(0) : databaseInterface(_databaseInterface), threaded(false), clientCount(0)
{ {
} }

View file

@ -1015,7 +1015,7 @@ void Servatrice_DatabaseInterface::updateUsersLastLoginData(const QString &userN
} }
if (usersID) { if (usersID) {
int userCount; int userCount = 0;
query = prepareQuery("select count(id) from {prefix}_user_analytics where id = :user_id"); query = prepareQuery("select count(id) from {prefix}_user_analytics where id = :user_id");
query->bindValue(":user_id", usersID); query->bindValue(":user_id", usersID);
if (!execSqlQuery(query)) if (!execSqlQuery(query))

View file

@ -564,7 +564,7 @@ Response::ResponseCode AbstractServerSocketInterface::cmdDeckDownload(const Comm
DeckList *deck; DeckList *deck;
try { try {
deck = sqlInterface->getDeckFromDatabase(cmd.deck_id(), userInfo->id()); deck = sqlInterface->getDeckFromDatabase(cmd.deck_id(), userInfo->id());
} catch (Response::ResponseCode r) { } catch (Response::ResponseCode &r) {
return r; return r;
} }

View file

@ -10,7 +10,6 @@ class SettingsCache : public QSettings
{ {
Q_OBJECT Q_OBJECT
private: private:
QSettings *settings;
bool isPortableBuild; bool isPortableBuild;
public: public:

View file

@ -19,7 +19,7 @@
int SignalHandler::sigHupFD[2]; int SignalHandler::sigHupFD[2];
SignalHandler::SignalHandler(QObject *parent) : QObject(parent) SignalHandler::SignalHandler(QObject *parent) : QObject(parent), snHup(nullptr)
{ {
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
::socketpair(AF_UNIX, SOCK_STREAM, 0, sigHupFD); ::socketpair(AF_UNIX, SOCK_STREAM, 0, sigHupFD);