From 099fea15ae0b847ec9802bdb36df4473af3f1e46 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Wed, 29 Jul 2020 18:26:41 +0530 Subject: [PATCH] Fixed code smells in runtime code reported by SonarQube. --- runtime/Logger.cpp | 2 +- runtime/Logger.h | 2 +- runtime/MenuActions.cpp | 4 ++-- runtime/MenuActions.h | 6 +++--- runtime/Runtime.cpp | 6 +++--- runtime/Runtime.h | 4 ++-- runtime/Server.h | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/runtime/Logger.cpp b/runtime/Logger.cpp index ed4364954..7b2cccbd9 100644 --- a/runtime/Logger.cpp +++ b/runtime/Logger.cpp @@ -41,7 +41,7 @@ Logger* Logger::GetLogger() return m_pThis; } -void Logger::Log(const QString& sMessage) +void Logger::Log(const QString& sMessage) const { QString text = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss: ") + sMessage + "\n"; if (m_Logfile != Q_NULLPTR) diff --git a/runtime/Logger.h b/runtime/Logger.h index 7f38996d6..4ac212ad0 100644 --- a/runtime/Logger.h +++ b/runtime/Logger.h @@ -20,7 +20,7 @@ class Logger : public QObject public: static Logger* GetLogger(); static void ReleaseLogger(); - void Log(const QString& sMessage); + void Log(const QString& sMessage) const; private: Logger(); diff --git a/runtime/MenuActions.cpp b/runtime/MenuActions.cpp index 2e9e6dbcc..ec4b98eeb 100644 --- a/runtime/MenuActions.cpp +++ b/runtime/MenuActions.cpp @@ -31,7 +31,7 @@ void MenuActions::setAppServerUrl(QString appServerUrl) // Create a new application browser window on user request -void MenuActions::onNew() +void MenuActions::onNew() const { QSettings settings; QString cmd = settings.value("BrowserCommand").toString(); @@ -55,7 +55,7 @@ void MenuActions::onNew() // Copy the application server URL to the clipboard -void MenuActions::onCopyUrl() +void MenuActions::onCopyUrl() const { QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(m_appServerUrl); diff --git a/runtime/MenuActions.h b/runtime/MenuActions.h index 6ab04956c..a48237f24 100644 --- a/runtime/MenuActions.h +++ b/runtime/MenuActions.h @@ -22,7 +22,7 @@ public: MenuActions(); void setAppServerUrl(QString appServerUrl); - QString getAppServerUrl() { return m_appServerUrl; } + QString getAppServerUrl() const { return m_appServerUrl; } private: QString m_appServerUrl = ""; @@ -33,8 +33,8 @@ public slots: void onConfigDone(bool needRestart) const; protected slots: - void onNew(); - void onCopyUrl(); + void onNew() const; + void onCopyUrl() const; void onConfig(); void onLog(); void onQuit(); diff --git a/runtime/Runtime.cpp b/runtime/Runtime.cpp index 9eb964625..9d5d686d9 100644 --- a/runtime/Runtime.cpp +++ b/runtime/Runtime.cpp @@ -91,7 +91,7 @@ bool Runtime::go(int argc, char *argv[]) floatingWindow = createFloatingWindow(splash, menuActions); // Fire up the app server - Server *server = startServerLoop(splash, floatingWindow, trayIcon, port, key); + const Server *server = startServerLoop(splash, floatingWindow, trayIcon, port, key); // Ensure we'll cleanup QObject::connect(server, SIGNAL(finished()), server, SLOT(deleteLater())); @@ -136,7 +136,7 @@ bool Runtime::go(int argc, char *argv[]) // Setup the styling -void Runtime::setupStyling(QApplication *app) +void Runtime::setupStyling(QApplication *app) const { // Setup the styling #ifndef Q_OS_LINUX @@ -222,7 +222,7 @@ bool Runtime::alreadyRunning() } -void Runtime::configureProxy() +void Runtime::configureProxy() const { // In windows and linux, it is required to set application level proxy // because socket bind logic to find free port gives socket creation error diff --git a/runtime/Runtime.h b/runtime/Runtime.h index b5bd2b026..4b94f617a 100644 --- a/runtime/Runtime.h +++ b/runtime/Runtime.h @@ -44,8 +44,8 @@ private: QSharedMemory *m_shmem; bool m_configDone; - void setupStyling(QApplication *app); - void configureProxy(); + void setupStyling(QApplication *app) const; + void configureProxy() const; QSplashScreen *displaySplash(QApplication *app); quint16 getPort() const; TrayIcon *createTrayIcon(QSplashScreen *splash, MenuActions *menuActions); diff --git a/runtime/Server.h b/runtime/Server.h index 1a5d17e54..30bf26167 100644 --- a/runtime/Server.h +++ b/runtime/Server.h @@ -26,7 +26,7 @@ public: ~Server(); bool Init(); - QString getError() { return m_error; } + QString getError() const { return m_error; } public slots: void shutdown(QUrl url);