Commit 2029e703 authored by Linus Jahn's avatar Linus Jahn 🍙

Add clang-tidy script to use modern C++

parent 9ba820bf
Pipeline #256 passed with stage
in 2 minutes and 27 seconds
......@@ -40,7 +40,7 @@ class AvatarFileStorage : public QObject
Q_OBJECT
public:
AvatarFileStorage(QObject *parent = 0);
AvatarFileStorage(QObject *parent = nullptr);
struct AddAvatarResult {
/* SHA1 HEX Hash */
......
......@@ -92,7 +92,7 @@ ClientWorker::~ClientWorker()
void ClientWorker::main()
{
// initialize random generator
qsrand(time(NULL));
qsrand(time(nullptr));
connect(client, &QXmppClient::stateChanged, kaidan, &Kaidan::setConnectionState);
connect(client, &QXmppClient::connected, this, &ClientWorker::onConnect);
......
......@@ -41,7 +41,7 @@ class Database : public QObject
Q_OBJECT
public:
Database(QObject *parent = 0);
Database(QObject *parent = nullptr);
~Database();
QSqlDatabase* getDatabase();
......
......@@ -71,7 +71,7 @@ class Kaidan : public QObject
Q_PROPERTY(bool uploadServiceFound READ getUploadServiceFound NOTIFY uploadServiceFoundChanged)
public:
Kaidan(QGuiApplication *app, bool enableLogging = true, QObject *parent = 0);
Kaidan(QGuiApplication *app, bool enableLogging = true, QObject *parent = nullptr);
~Kaidan();
......
......@@ -72,7 +72,7 @@ MessageHandler::MessageHandler(Kaidan *kaidan, QXmppClient *client, MessageModel
client, &QXmppClient::messageReceived);
// carbons discovery
QXmppDiscoveryManager *discoManager = client->findExtension<QXmppDiscoveryManager>();
auto *discoManager = client->findExtension<QXmppDiscoveryManager>();
if (!discoManager)
return;
......
......@@ -43,7 +43,7 @@ class MessageModel : public QSqlTableModel
Q_OBJECT
public:
MessageModel(QSqlDatabase *database, QObject *parent = 0);
MessageModel(QSqlDatabase *database, QObject *parent = nullptr);
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
......
......@@ -43,7 +43,7 @@ class RosterModel : public QSqlTableModel
Q_OBJECT
public:
RosterModel(QSqlDatabase *database, QObject *parent = 0);
RosterModel(QSqlDatabase *database, QObject *parent = nullptr);
QHash<int, QByteArray> roleNames() const;
QVariant data(const QModelIndex &index, int role) const;
......
......@@ -82,7 +82,7 @@ void UploadManager::sendFile(QString jid, QString fileUrl, QString body)
QMimeType mimeType = QMimeDatabase().mimeTypeForFile(file);
MessageModel::Message *msg = new MessageModel::Message();
auto *msg = new MessageModel::Message();
msg->author = client->configuration().jidBare();
msg->recipient = jid;
msg->id = QXmppUtils::generateStanzaHash(48);
......
......@@ -126,7 +126,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
}
#endif
// initialize random generator
qsrand(time(NULL));
qsrand(time(nullptr));
//
// App
......
......@@ -217,7 +217,7 @@ QXmppUploadManager::QXmppUploadManager()
int QXmppUploadManager::uploadFile(const QFileInfo &file, bool allowParallel, QString customFileName)
{
QXmppHttpUpload *upload = new QXmppHttpUpload(this);
auto *upload = new QXmppHttpUpload(this);
upload->setFileInfo(file);
upload->setCustomFileName(customFileName);
upload->setId(m_nextJobId++);
......@@ -317,7 +317,7 @@ void QXmppUploadManager::handleUploadProgressed(qint64 sent, qint64 total)
void QXmppUploadManager::handleUploadFinished()
{
QXmppHttpUpload *upload = (QXmppHttpUpload*) sender();
auto *upload = (QXmppHttpUpload*) sender();
if (upload) {
m_uploads.removeAll(upload);
emit uploadSucceeded(upload);
......
......@@ -144,7 +144,7 @@ void QXmppUploadRequestManager::setClient(QXmppClient *client)
{
QXmppClientExtension::setClient(client);
// connect to service discovery manager
QXmppDiscoveryManager *disco = client->findExtension<QXmppDiscoveryManager>();
auto *disco = client->findExtension<QXmppDiscoveryManager>();
if (disco) {
// scan info of all entities for upload services
// Could this lead to another client being added as upload service?
......
#!/usr/bin/env bash
# Tidy up code to use modern C++
KAIDAN_SOURCES=$(dirname "$(readlink -f "${0}")")/..
mkdir -p .tidy-tmp
cd .tidy-tmp
cmake $KAIDAN_SOURCES -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# will output an error about moc files: just ignore, we don't want to tidy moc generated files
run-clang-tidy -header-filter='.*' -checks='-*,modernize-avoid-bind,modernize-deprecated-headers,modernize-loop-convert,modernize-make-shared,modernize-make-unique,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-shrink-to-fit,modernize-use-auto,modernize-use-bool-literals,modernize-use-default,modernize-use-emplace,modernize-use-nullptr,modernize-use-using' -fix
git -C $KAIDAN_SOURCES checkout -- src/singleapp
cd ..
rm -rf .tidy-tmp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment