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:
James Ring 2019-08-19 12:19:32 -07:00 committed by Janek Bevendorff
parent 7cbcea18e9
commit b9e1088f74
27 changed files with 12 additions and 78 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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;
};

View File

@ -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();

View File

@ -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

View File

@ -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);
};

View File

@ -44,10 +44,6 @@ Diceware::Diceware()
options.append(Diceware::WordListOption);
}
Diceware::~Diceware()
{
}
int Diceware::execute(const QStringList& arguments)
{
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);

View File

@ -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;

View File

@ -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,

View File

@ -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;
};

View File

@ -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);

View File

@ -24,7 +24,6 @@ class Estimate : public Command
{
public:
Estimate();
~Estimate();
int execute(const QStringList& arguments) override;
static const QCommandLineOption AdvancedOption;

View File

@ -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);

View File

@ -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

View File

@ -75,10 +75,6 @@ Generate::Generate()
options.append(Generate::IncludeEveryGroupOption);
}
Generate::~Generate()
{
}
int Generate::execute(const QStringList& arguments)
{
QSharedPointer<QCommandLineParser> parser = getCommandLineParser(arguments);

View File

@ -24,7 +24,6 @@ class Generate : public Command
{
public:
Generate();
~Generate();
int execute(const QStringList& arguments) override;
static const QCommandLineOption PasswordLengthOption;

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -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

View File

@ -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,

View File

@ -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;

View File

@ -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);

View File

@ -24,7 +24,6 @@ class Remove : public DatabaseCommand
{
public:
Remove();
~Remove();
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
};

View File

@ -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);

View File

@ -24,7 +24,6 @@ class Show : public DatabaseCommand
{
public:
Show();
~Show();
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);