1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2025-06-01 10:34:08 +02:00

Enable the modernize-use-using check on clang-tidy

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2020-08-12 15:23:11 +02:00
parent 7bb54e34d7
commit d58ec4bf70
No known key found for this signature in database
GPG Key ID: 074BBBCB8DECC9E2
30 changed files with 65 additions and 70 deletions

View File

@ -20,6 +20,7 @@ Checks: '-*,
modernize-user-override, modernize-user-override,
modernize-use-transparent-functors, modernize-use-transparent-functors,
modernize-use-uncaught-exceptions, modernize-use-uncaught-exceptions,
modernize-use-using,
' '
WarningsAsErrors: '*' WarningsAsErrors: '*'
HeaderFilterRegex: '.*' HeaderFilterRegex: '.*'

View File

@ -30,7 +30,7 @@ class OwncloudDolphinPlugin : public KOverlayIconPlugin
Q_PLUGIN_METADATA(IID "com.owncloud.ovarlayiconplugin" FILE "ownclouddolphinoverlayplugin.json") Q_PLUGIN_METADATA(IID "com.owncloud.ovarlayiconplugin" FILE "ownclouddolphinoverlayplugin.json")
Q_OBJECT Q_OBJECT
typedef QHash<QByteArray, QByteArray> StatusMap; using StatusMap = QHash<QByteArray, QByteArray>;
StatusMap m_status; StatusMap m_status;
public: public:

View File

@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
template <class T, class const_iterator> template <class T, class const_iterator>
struct QTokenizerPrivate { struct QTokenizerPrivate {
typedef typename T::value_type char_type; using char_type = typename T::value_type;
struct State { struct State {
bool inQuote = false; bool inQuote = false;
@ -113,7 +113,7 @@ struct QTokenizerPrivate {
template <class T, class const_iterator> template <class T, class const_iterator>
class QTokenizer { class QTokenizer {
public: public:
typedef typename T::value_type char_type; using char_type = typename T::value_type;
/*! /*!
\class QTokenizer \class QTokenizer
@ -253,9 +253,9 @@ public:
} }
}; };
typedef QTokenizer<QByteArray, QByteArray::const_iterator> QByteArrayTokenizer; using QByteArrayTokenizer = QTokenizer<QByteArray, QByteArray::const_iterator>;
typedef QTokenizer<std::string, std::string::const_iterator> StringTokenizer; using StringTokenizer = QTokenizer<std::string, std::string::const_iterator>;
typedef QTokenizer<std::wstring, std::wstring::const_iterator> WStringTokenizer; using WStringTokenizer = QTokenizer<std::wstring, std::wstring::const_iterator>;
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -36,7 +36,7 @@
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#include <QLibrary> #include <QLibrary>
#include <qt_windows.h> #include <qt_windows.h>
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); using PProcessIdToSessionId = BOOL (WINAPI*)(DWORD, DWORD*);
static PProcessIdToSessionId pProcessIdToSessionId = 0; static PProcessIdToSessionId pProcessIdToSessionId = 0;
#endif #endif

View File

@ -27,7 +27,7 @@ namespace OCC {
class NetrcParser class NetrcParser
{ {
public: public:
typedef QPair<QString, QString> LoginPair; using LoginPair = QPair<QString, QString>;
NetrcParser(const QString &file = QString()); NetrcParser(const QString &file = QString());
bool parse(); bool parse();

View File

@ -95,7 +95,7 @@ enum csync_status_codes_e {
CSYNC_STATUS_INDIVIDUAL_CANNOT_ENCODE CSYNC_STATUS_INDIVIDUAL_CANNOT_ENCODE
}; };
typedef enum csync_status_codes_e CSYNC_STATUS; using CSYNC_STATUS = enum csync_status_codes_e;
#ifndef likely #ifndef likely
# define likely(x) (x) # define likely(x) (x)
@ -146,7 +146,7 @@ enum ItemType {
// currently specified at https://github.com/owncloud/core/issues/8322 are 9 to 10 // currently specified at https://github.com/owncloud/core/issues/8322 are 9 to 10
#define REMOTE_PERM_BUF_SIZE 15 #define REMOTE_PERM_BUF_SIZE 15
typedef struct csync_file_stat_s csync_file_stat_t; using csync_file_stat_t = struct csync_file_stat_s;
struct OCSYNC_EXPORT csync_file_stat_s { struct OCSYNC_EXPORT csync_file_stat_s {
time_t modtime = 0; time_t modtime = 0;
@ -193,26 +193,19 @@ struct OCSYNC_EXPORT csync_file_stat_s {
/** /**
* csync handle * csync handle
*/ */
typedef struct csync_s CSYNC; using CSYNC = struct csync_s;
typedef int (*csync_auth_callback) (const char *prompt, char *buf, size_t len, using csync_auth_callback = int (*)(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata);
int echo, int verify, void *userdata);
typedef void (*csync_update_callback) (bool local, using csync_update_callback = void (*)(bool local, const char *dirUrl, void *userdata);
const char *dirUrl,
void *userdata);
typedef void csync_vio_handle_t; using csync_vio_handle_t = void;
typedef csync_vio_handle_t* (*csync_vio_opendir_hook) (const char *url, using csync_vio_opendir_hook = csync_vio_handle_t *(*)(const char *url, void *userdata);
void *userdata); using csync_vio_readdir_hook = std::unique_ptr<csync_file_stat_t> (*)(csync_vio_handle_t *dhandle, void *userdata);
typedef std::unique_ptr<csync_file_stat_t> (*csync_vio_readdir_hook) (csync_vio_handle_t *dhhandle, using csync_vio_closedir_hook = void (*)(csync_vio_handle_t *dhandle, void *userdata);
void *userdata);
typedef void (*csync_vio_closedir_hook) (csync_vio_handle_t *dhhandle,
void *userdata);
/* Compute the checksum of the given \a checksumTypeId for \a path. */ /* Compute the checksum of the given \a checksumTypeId for \a path. */
typedef QByteArray (*csync_checksum_hook)( using csync_checksum_hook = QByteArray (*)(const QByteArray &path, const QByteArray &otherChecksumHeader, void *userdata);
const QByteArray &path, const QByteArray &otherChecksumHeader, void *userdata);
/** /**
* @brief Update detection * @brief Update detection

View File

@ -45,7 +45,7 @@ enum csync_exclude_type_e {
CSYNC_FILE_EXCLUDE_CONFLICT, CSYNC_FILE_EXCLUDE_CONFLICT,
CSYNC_FILE_EXCLUDE_CANNOT_ENCODE CSYNC_FILE_EXCLUDE_CANNOT_ENCODE
}; };
typedef enum csync_exclude_type_e CSYNC_EXCLUDE_TYPE; using CSYNC_EXCLUDE_TYPE = enum csync_exclude_type_e;
class ExcludedFilesTest; class ExcludedFilesTest;

View File

@ -37,7 +37,7 @@
* @{ * @{
*/ */
typedef int (*csync_walker_fn) (CSYNC *ctx, std::unique_ptr<csync_file_stat_t> fs); using csync_walker_fn = int (*)(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> fs);
/** /**
* @brief The walker function to use in the file tree walker. * @brief The walker function to use in the file tree walker.

View File

@ -37,10 +37,10 @@
Q_LOGGING_CATEGORY(lcCSyncUtils, "nextcloud.sync.csync.utils", QtInfoMsg) Q_LOGGING_CATEGORY(lcCSyncUtils, "nextcloud.sync.csync.utils", QtInfoMsg)
typedef struct { using _instr_code_struct = struct {
const char *instr_str; const char *instr_str;
enum csync_instructions_e instr_code; enum csync_instructions_e instr_code;
} _instr_code_struct; };
static const _instr_code_struct _instr[] = static const _instr_code_struct _instr[] =
{ {

View File

@ -80,10 +80,10 @@
#ifdef _WIN32 #ifdef _WIN32
typedef struct stat64 csync_stat_t; typedef struct stat64 csync_stat_t; // NOLINT this is sometimes compiled in C mode
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#else #else
typedef struct stat csync_stat_t; typedef struct stat csync_stat_t; // NOLINT this is sometimes compiled in C mode
#endif #endif
#ifndef O_NOATIME #ifndef O_NOATIME
@ -112,7 +112,7 @@ typedef struct stat csync_stat_t;
#endif #endif
#if defined _WIN32 && defined _UNICODE #if defined _WIN32 && defined _UNICODE
typedef wchar_t mbchar_t; typedef wchar_t mbchar_t; // NOLINT this is sometimes compiled in C mode
#define _topen _wopen #define _topen _wopen
#define _tdirent _wdirent #define _tdirent _wdirent
#define _topendir _wopendir #define _topendir _wopendir
@ -133,7 +133,7 @@ typedef wchar_t mbchar_t;
#define _tchdir _wchdir #define _tchdir _wchdir
#define _tgetcwd _wgetcwd #define _tgetcwd _wgetcwd
#else #else
typedef char mbchar_t; typedef char mbchar_t; // NOLINT this is sometimes compiled in C mode
#define _tdirent dirent #define _tdirent dirent
#define _topen open #define _topen open
#define _topendir opendir #define _topendir opendir

View File

@ -28,9 +28,11 @@
#include "csync.h" #include "csync.h"
#include "csync_private.h" #include "csync_private.h"
typedef struct fhandle_s { using fhandle_t = struct fhandle_s {
int fd; int fd;
} fhandle_t;
};
csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name); csync_vio_handle_t *csync_vio_opendir(CSYNC *ctx, const char *name);
int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle); int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle);

View File

@ -43,10 +43,10 @@ Q_LOGGING_CATEGORY(lcCSyncVIOLocal, "nextcloud.sync.csync.vio_local", QtInfoMsg)
* directory functions * directory functions
*/ */
typedef struct dhandle_s { using dhandle_t = struct dhandle_s {
DIR *dh; DIR *dh;
char *path; char *path;
} dhandle_t; };
static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf); static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf);

View File

@ -43,12 +43,12 @@ Q_LOGGING_CATEGORY(lcCSyncVIOLocal, "nextcloud.sync.csync.vio_local", QtInfoMsg)
* directory functions * directory functions
*/ */
typedef struct dhandle_s { using dhandle_t = struct dhandle_s {
WIN32_FIND_DATA ffd; WIN32_FIND_DATA ffd;
HANDLE hFind; HANDLE hFind;
int firstFind; int firstFind;
mbchar_t *path; // Always ends with '\' mbchar_t *path; // Always ends with '\'
} dhandle_t; };
static int _csync_vio_local_stat_mb(const mbchar_t *uri, csync_file_stat_t *buf); static int _csync_vio_local_stat_mb(const mbchar_t *uri, csync_file_stat_t *buf);

View File

@ -32,8 +32,8 @@ class Account;
class AccountApp; class AccountApp;
class RemoteWipe; class RemoteWipe;
typedef QExplicitlySharedDataPointer<AccountState> AccountStatePtr; using AccountStatePtr = QExplicitlySharedDataPointer<AccountState>;
typedef QList<AccountApp*> AccountAppList; using AccountAppList = QList<AccountApp *>;
/** /**
* @brief Extra info about an ownCloud server account. * @brief Extra info about an ownCloud server account.
@ -75,7 +75,7 @@ public:
}; };
/// The actual current connectivity status. /// The actual current connectivity status.
typedef ConnectionValidator::Status ConnectionStatus; using ConnectionStatus = ConnectionValidator::Status;
/// Use the account as parent /// Use the account as parent
explicit AccountState(AccountPtr account); explicit AccountState(AccountPtr account);

View File

@ -20,17 +20,17 @@
/* Forward declaration required since gio header files interfere with QObject headers */ /* Forward declaration required since gio header files interfere with QObject headers */
struct _CloudProvidersProviderExporter; struct _CloudProvidersProviderExporter;
typedef _CloudProvidersProviderExporter CloudProvidersProviderExporter; using CloudProvidersProviderExporter = _CloudProvidersProviderExporter;
struct _CloudProvidersAccountExporter; struct _CloudProvidersAccountExporter;
typedef _CloudProvidersAccountExporter CloudProvidersAccountExporter; using CloudProvidersAccountExporter = _CloudProvidersAccountExporter;
struct _GMenuModel; struct _GMenuModel;
typedef _GMenuModel GMenuModel; using GMenuModel = _GMenuModel;
struct _GMenu; struct _GMenu;
typedef _GMenu GMenu; using GMenu = _GMenu;
struct _GActionGroup; struct _GActionGroup;
typedef _GActionGroup GActionGroup; using GActionGroup = _GActionGroup;
typedef char gchar; using gchar = char;
typedef void* gpointer; using gpointer = void*;
using namespace OCC; using namespace OCC;

View File

@ -95,8 +95,8 @@ public:
~Folder(); ~Folder();
typedef QMap<QString, Folder *> Map; using Map = QMap<QString, Folder *>;
typedef QMapIterator<QString, Folder *> MapIterator; using MapIterator = QMapIterator<QString, Folder *>;
/** /**
* The account the folder is configured on. * The account the folder is configured on.

View File

@ -66,7 +66,7 @@ class ShareeModel : public QAbstractListModel
public: public:
explicit ShareeModel(const AccountPtr &account, const QString &type, QObject *parent = nullptr); explicit ShareeModel(const AccountPtr &account, const QString &type, QObject *parent = nullptr);
typedef QVector<QSharedPointer<Sharee>> ShareeSet; // FIXME: make it a QSet<Sharee> when Sharee can be compared using ShareeSet = QVector<QSharedPointer<Sharee>>; // FIXME: make it a QSet<Sharee> when Sharee can be compared
void fetch(const QString &search, const ShareeSet &blacklist); void fetch(const QString &search, const ShareeSet &blacklist);
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override; QVariant data(const QModelIndex &index, int role) const override;

View File

@ -48,7 +48,7 @@ public:
TypeCircle = Sharee::Circle TypeCircle = Sharee::Circle
}; };
typedef SharePermissions Permissions; using Permissions = SharePermissions;
/* /*
* Constructor for shares * Constructor for shares

View File

@ -25,7 +25,7 @@
#include "socketapisocket_mac.h" #include "socketapisocket_mac.h"
#else #else
#include <QLocalServer> #include <QLocalServer>
typedef QLocalServer SocketApiServer; using SocketApiServer = QLocalServer;
#endif #endif
class QUrl; class QUrl;

View File

@ -45,7 +45,7 @@ public:
class Activity class Activity
{ {
public: public:
typedef QPair<qlonglong, QString> Identifier; using Identifier = QPair<qlonglong, QString>;
enum Type { enum Type {
ActivityType, ActivityType,
@ -92,8 +92,7 @@ bool operator<(const Activity &rhs, const Activity &lhs);
* *
* A QList based list of Activities * A QList based list of Activities
*/ */
using ActivityList = QList<Activity>;
typedef QList<Activity> ActivityList;
} }
Q_DECLARE_METATYPE(OCC::Activity::Type) Q_DECLARE_METATYPE(OCC::Activity::Type)

View File

@ -51,7 +51,7 @@ namespace OCC {
class AbstractCredentials; class AbstractCredentials;
class Account; class Account;
typedef QSharedPointer<Account> AccountPtr; using AccountPtr = QSharedPointer<Account>;
class AccessManager; class AccessManager;
class SimpleNetworkJob; class SimpleNetworkJob;

View File

@ -20,9 +20,9 @@
namespace OCC { namespace OCC {
class Account; class Account;
typedef QSharedPointer<Account> AccountPtr; using AccountPtr = QSharedPointer<Account>;
class AccountState; class AccountState;
typedef QExplicitlySharedDataPointer<AccountState> AccountStatePtr; using AccountStatePtr = QExplicitlySharedDataPointer<AccountState>;
} // namespace OCC } // namespace OCC

View File

@ -201,7 +201,7 @@ private:
QString keychainProxyPasswordKey() const; QString keychainProxyPasswordKey() const;
private: private:
typedef QSharedPointer<AbstractCredentials> SharedCreds; using SharedCreds = QSharedPointer<AbstractCredentials>;
static bool _askedUser; static bool _askedUser;
static QString _oCVersion; static QString _oCVersion;

View File

@ -27,7 +27,7 @@ namespace OCC {
class SyncFileItem; class SyncFileItem;
class SyncJournalFileRecord; class SyncJournalFileRecord;
typedef QSharedPointer<SyncFileItem> SyncFileItemPtr; using SyncFileItemPtr = QSharedPointer<SyncFileItem>;
/** /**
* @brief The SyncFileItem class * @brief The SyncFileItem class
@ -254,7 +254,7 @@ inline bool operator<(const SyncFileItemPtr &item1, const SyncFileItemPtr &item2
return *item1 < *item2; return *item1 < *item2;
} }
typedef QVector<SyncFileItemPtr> SyncFileItemVector; using SyncFileItemVector = QVector<SyncFileItemPtr>;
} }
Q_DECLARE_METATYPE(OCC::SyncFileItem) Q_DECLARE_METATYPE(OCC::SyncFileItem)

View File

@ -54,7 +54,7 @@ private:
struct PathComparator { struct PathComparator {
bool operator()( const QString& lhs, const QString& rhs ) const; bool operator()( const QString& lhs, const QString& rhs ) const;
}; };
typedef std::map<QString, SyncFileStatus::SyncFileStatusTag, PathComparator> ProblemsMap; using ProblemsMap = std::map<QString, SyncFileStatus::SyncFileStatusTag, PathComparator>;
SyncFileStatus::SyncFileStatusTag lookupProblem(const QString &pathToMatch, const ProblemsMap &problemMap); SyncFileStatus::SyncFileStatusTag lookupProblem(const QString &pathToMatch, const ProblemsMap &problemMap);
enum SharedFlag { UnknownShared, enum SharedFlag { UnknownShared,

View File

@ -698,7 +698,7 @@ static void check_csync_exclude_expand_escapes(void **state)
int torture_run_tests(void) int torture_run_tests(void)
{ {
typedef ExcludedFilesTest T; using T = ExcludedFilesTest;
const struct CMUnitTest tests[] = { const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(T::check_csync_exclude_add, T::setup, T::teardown), cmocka_unit_test_setup_teardown(T::check_csync_exclude_add, T::setup, T::teardown),

View File

@ -43,11 +43,11 @@
static mbchar_t wd_buffer[WD_BUFFER_SIZE]; static mbchar_t wd_buffer[WD_BUFFER_SIZE];
typedef struct { using statevar = struct {
CSYNC *csync; CSYNC *csync;
char *result; char *result;
char *ignored_dir; char *ignored_dir;
} statevar; };
/* remove the complete test dir */ /* remove the complete test dir */
static int wipe_testdir() static int wipe_testdir()

View File

@ -14,7 +14,7 @@
using namespace OCC; using namespace OCC;
typedef QList< QPair<QString,QString> > QueryItems; using QueryItems = QList<QPair<QString, QString>>;
Q_DECLARE_METATYPE(QueryItems) Q_DECLARE_METATYPE(QueryItems)

View File

@ -65,7 +65,7 @@ private slots:
void testParseEtag() void testParseEtag()
{ {
typedef QPair<const char*, const char*> Test; using Test = QPair<const char*, const char*>;
QList<Test> tests; QList<Test> tests;
tests.append(Test("\"abcd\"", "abcd")); tests.append(Test("\"abcd\"", "abcd"));
tests.append(Test("\"\"", "")); tests.append(Test("\"\"", ""));

View File

@ -130,7 +130,7 @@ private slots:
void testDownloadInfo() void testDownloadInfo()
{ {
typedef SyncJournalDb::DownloadInfo Info; using Info = SyncJournalDb::DownloadInfo;
Info record = _db.getDownloadInfo("nonexistant"); Info record = _db.getDownloadInfo("nonexistant");
QVERIFY(!record._valid); QVERIFY(!record._valid);