mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-13 08:19:50 -05:00
Clean up code (#3431)
* Empty destructors are replaced with default destructors * A few loop variables made into const references to avoid copies * Add missing `override` spec for some `Command::execute` methods
This commit is contained in:
parent
7cbcea18e9
commit
b9e1088f74
@ -62,10 +62,6 @@ Add::Add()
|
||||
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to add."), QString("")});
|
||||
}
|
||||
|
||||
Add::~Add()
|
||||
{
|
||||
}
|
||||
|
||||
int Add::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
TextStream inputTextStream(Utils::STDIN, QIODevice::ReadOnly);
|
||||
|
@ -24,9 +24,8 @@ class Add : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Add();
|
||||
~Add();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||
|
||||
static const QCommandLineOption UsernameOption;
|
||||
static const QCommandLineOption UrlOption;
|
||||
|
@ -43,10 +43,6 @@ Clip::Clip()
|
||||
{QString("timeout"), QObject::tr("Timeout in seconds before clearing the clipboard."), QString("[timeout]")});
|
||||
}
|
||||
|
||||
Clip::~Clip()
|
||||
{
|
||||
}
|
||||
|
||||
int Clip::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
const QStringList args = parser->positionalArguments();
|
||||
|
@ -24,9 +24,8 @@ class Clip : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Clip();
|
||||
~Clip();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||
|
||||
static const QCommandLineOption TotpOption;
|
||||
};
|
||||
|
@ -80,14 +80,14 @@ QSharedPointer<QCommandLineParser> Command::getCommandLineParser(const QStringLi
|
||||
|
||||
QSharedPointer<QCommandLineParser> parser = QSharedPointer<QCommandLineParser>(new QCommandLineParser());
|
||||
parser->setApplicationDescription(description);
|
||||
for (CommandLineArgument positionalArgument : positionalArguments) {
|
||||
for (const CommandLineArgument& positionalArgument : positionalArguments) {
|
||||
parser->addPositionalArgument(
|
||||
positionalArgument.name, positionalArgument.description, positionalArgument.syntax);
|
||||
}
|
||||
for (CommandLineArgument optionalArgument : optionalArguments) {
|
||||
for (const CommandLineArgument& optionalArgument : optionalArguments) {
|
||||
parser->addPositionalArgument(optionalArgument.name, optionalArgument.description, optionalArgument.syntax);
|
||||
}
|
||||
for (QCommandLineOption option : options) {
|
||||
for (const QCommandLineOption& option : options) {
|
||||
parser->addOption(option);
|
||||
}
|
||||
parser->addHelpOption();
|
||||
|
@ -38,10 +38,6 @@ Create::Create()
|
||||
options.append(Command::KeyFileOption);
|
||||
}
|
||||
|
||||
Create::~Create()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a database file using the command line. A key file and/or
|
||||
* password can be specified to encrypt the password. If none is
|
||||
|
@ -27,12 +27,10 @@ class Create : public Command
|
||||
{
|
||||
public:
|
||||
Create();
|
||||
~Create();
|
||||
int execute(const QStringList& arguments);
|
||||
int execute(const QStringList& arguments) override;
|
||||
|
||||
private:
|
||||
QSharedPointer<PasswordKey> getPasswordFromStdin();
|
||||
QSharedPointer<FileKey> getFileKeyFromStdin();
|
||||
bool loadFileKey(const QString& path, QSharedPointer<FileKey>& fileKey);
|
||||
};
|
||||
|
||||
|
@ -44,10 +44,6 @@ Diceware::Diceware()
|
||||
options.append(Diceware::WordListOption);
|
||||
}
|
||||
|
||||
Diceware::~Diceware()
|
||||
{
|
||||
}
|
||||
|
||||
int Diceware::execute(const QStringList& arguments)
|
||||
{
|
||||
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);
|
||||
|
@ -24,9 +24,8 @@ class Diceware : public Command
|
||||
{
|
||||
public:
|
||||
Diceware();
|
||||
~Diceware();
|
||||
|
||||
int execute(const QStringList& arguments);
|
||||
int execute(const QStringList& arguments) override;
|
||||
|
||||
static const QCommandLineOption WordCountOption;
|
||||
static const QCommandLineOption WordListOption;
|
||||
|
@ -47,10 +47,6 @@ Edit::Edit()
|
||||
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to edit."), QString("")});
|
||||
}
|
||||
|
||||
Edit::~Edit()
|
||||
{
|
||||
}
|
||||
|
||||
int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
TextStream outputTextStream(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
|
@ -24,8 +24,7 @@ class Edit : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Edit();
|
||||
~Edit();
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||
|
||||
static const QCommandLineOption TitleOption;
|
||||
};
|
||||
|
@ -45,10 +45,6 @@ Estimate::Estimate()
|
||||
description = QObject::tr("Estimate the entropy of a password.");
|
||||
}
|
||||
|
||||
Estimate::~Estimate()
|
||||
{
|
||||
}
|
||||
|
||||
static void estimate(const char* pwd, bool advanced)
|
||||
{
|
||||
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
|
@ -24,7 +24,6 @@ class Estimate : public Command
|
||||
{
|
||||
public:
|
||||
Estimate();
|
||||
~Estimate();
|
||||
int execute(const QStringList& arguments) override;
|
||||
|
||||
static const QCommandLineOption AdvancedOption;
|
||||
|
@ -30,10 +30,6 @@ Extract::Extract()
|
||||
description = QObject::tr("Extract and print the content of a database.");
|
||||
}
|
||||
|
||||
Extract::~Extract()
|
||||
{
|
||||
}
|
||||
|
||||
int Extract::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser>)
|
||||
{
|
||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
|
@ -24,9 +24,8 @@ class Extract : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Extract();
|
||||
~Extract();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_EXTRACT_H
|
||||
|
@ -75,10 +75,6 @@ Generate::Generate()
|
||||
options.append(Generate::IncludeEveryGroupOption);
|
||||
}
|
||||
|
||||
Generate::~Generate()
|
||||
{
|
||||
}
|
||||
|
||||
int Generate::execute(const QStringList& arguments)
|
||||
{
|
||||
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);
|
||||
|
@ -24,7 +24,6 @@ class Generate : public Command
|
||||
{
|
||||
public:
|
||||
Generate();
|
||||
~Generate();
|
||||
int execute(const QStringList& arguments) override;
|
||||
|
||||
static const QCommandLineOption PasswordLengthOption;
|
||||
|
@ -45,10 +45,6 @@ List::List()
|
||||
{QString("group"), QObject::tr("Path of the group to list. Default is /"), QString("[group]")});
|
||||
}
|
||||
|
||||
List::~List()
|
||||
{
|
||||
}
|
||||
|
||||
int List::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
|
@ -24,9 +24,8 @@ class List : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
List();
|
||||
~List();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||
|
||||
static const QCommandLineOption RecursiveOption;
|
||||
static const QCommandLineOption FlattenOption;
|
||||
|
@ -36,10 +36,6 @@ Locate::Locate()
|
||||
positionalArguments.append({QString("term"), QObject::tr("Search term."), QString("")});
|
||||
}
|
||||
|
||||
Locate::~Locate()
|
||||
{
|
||||
}
|
||||
|
||||
int Locate::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
|
||||
|
@ -24,9 +24,8 @@ class Locate : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Locate();
|
||||
~Locate();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_LOCATE_H
|
||||
|
@ -54,10 +54,6 @@ Merge::Merge()
|
||||
positionalArguments.append({QString("database2"), QObject::tr("Path of the database to merge from."), QString("")});
|
||||
}
|
||||
|
||||
Merge::~Merge()
|
||||
{
|
||||
}
|
||||
|
||||
int Merge::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
TextStream outputTextStream(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
|
@ -24,9 +24,8 @@ class Merge : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Merge();
|
||||
~Merge();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;
|
||||
|
||||
static const QCommandLineOption SameCredentialsOption;
|
||||
static const QCommandLineOption KeyFileFromOption;
|
||||
|
@ -35,10 +35,6 @@ Remove::Remove()
|
||||
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to remove."), QString("")});
|
||||
}
|
||||
|
||||
Remove::~Remove()
|
||||
{
|
||||
}
|
||||
|
||||
int Remove::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
bool quiet = parser->isSet(Command::QuietOption);
|
||||
|
@ -24,7 +24,6 @@ class Remove : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Remove();
|
||||
~Remove();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
};
|
||||
|
@ -49,10 +49,6 @@ Show::Show()
|
||||
positionalArguments.append({QString("entry"), QObject::tr("Name of the entry to show."), QString("")});
|
||||
}
|
||||
|
||||
Show::~Show()
|
||||
{
|
||||
}
|
||||
|
||||
int Show::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
|
||||
{
|
||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
|
@ -24,7 +24,6 @@ class Show : public DatabaseCommand
|
||||
{
|
||||
public:
|
||||
Show();
|
||||
~Show();
|
||||
|
||||
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user