Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/CsvParser.cpp59
-rw-r--r--src/core/Entry.cpp6
-rw-r--r--src/core/Tools.cpp3
-rw-r--r--src/format/HtmlExporter.cpp3
-rw-r--r--src/gui/FileDialog.cpp3
-rw-r--r--src/gui/csvImport/CsvImportWidget.cpp17
-rw-r--r--src/gui/csvImport/CsvParserModel.cpp26
-rw-r--r--src/gui/group/GroupView.cpp5
-rw-r--r--src/gui/widgets/ElidedLabel.cpp9
-rw-r--r--tests/TestCsvParser.cpp3
-rw-r--r--tests/TestSymmetricCipher.cpp12
-rw-r--r--tests/TestYkChallengeResponseKey.cpp6
12 files changed, 98 insertions, 54 deletions
diff --git a/src/core/CsvParser.cpp b/src/core/CsvParser.cpp
index 7e4929481..adda56e49 100644
--- a/src/core/CsvParser.cpp
+++ b/src/core/CsvParser.cpp
@@ -67,15 +67,17 @@ bool CsvParser::parse(QFile* device)
appendStatusMsg(QObject::tr("NULL device"), true);
return false;
}
- if (!readFile(device))
+ if (!readFile(device)) {
return false;
+ }
return parseFile();
}
bool CsvParser::readFile(QFile* device)
{
- if (device->isOpen())
+ if (device->isOpen()) {
device->close();
+ }
device->open(QIODevice::ReadOnly);
if (!Tools::readAllFromDevice(device, m_array)) {
@@ -86,8 +88,9 @@ bool CsvParser::readFile(QFile* device)
m_array.replace("\r\n", "\n");
m_array.replace("\r", "\n");
- if (0 == m_array.size())
+ if (0 == m_array.size()) {
appendStatusMsg(QObject::tr("file empty").append("\n"));
+ }
m_isFileLoaded = true;
}
return m_isFileLoaded;
@@ -124,8 +127,9 @@ bool CsvParser::parseFile()
{
parseRecord();
while (!m_isEof) {
- if (!skipEndline())
+ if (!skipEndline()) {
appendStatusMsg(QObject::tr("malformed string"), true);
+ }
m_currRow++;
m_currCol = 1;
parseRecord();
@@ -146,15 +150,17 @@ void CsvParser::parseRecord()
getChar(m_ch);
} while (isSeparator(m_ch) && !m_isEof);
- if (!m_isEof)
+ if (!m_isEof) {
ungetChar();
+ }
if (isEmptyRow(row)) {
row.clear();
return;
}
m_table.push_back(row);
- if (m_maxCols < row.size())
+ if (m_maxCols < row.size()) {
m_maxCols = row.size();
+ }
m_currCol++;
}
@@ -163,10 +169,11 @@ void CsvParser::parseField(CsvRow& row)
QString field;
peek(m_ch);
if (!isTerminator(m_ch)) {
- if (isQualifier(m_ch))
+ if (isQualifier(m_ch)) {
parseQuoted(field);
- else
+ } else {
parseSimple(field);
+ }
}
row.push_back(field);
}
@@ -179,8 +186,9 @@ void CsvParser::parseSimple(QString& s)
s.append(c);
getChar(c);
}
- if (!m_isEof)
+ if (!m_isEof) {
ungetChar();
+ }
}
void CsvParser::parseQuoted(QString& s)
@@ -189,17 +197,20 @@ void CsvParser::parseQuoted(QString& s)
getChar(m_ch);
parseEscaped(s);
// getChar(m_ch);
- if (!isQualifier(m_ch))
+ if (!isQualifier(m_ch)) {
appendStatusMsg(QObject::tr("missing closing quote"), true);
+ }
}
void CsvParser::parseEscaped(QString& s)
{
parseEscapedText(s);
- while (processEscapeMark(s, m_ch))
+ while (processEscapeMark(s, m_ch)) {
parseEscapedText(s);
- if (!m_isEof)
+ }
+ if (!m_isEof) {
ungetChar();
+ }
}
void CsvParser::parseEscapedText(QString& s)
@@ -233,8 +244,9 @@ bool CsvParser::processEscapeMark(QString& s, QChar c)
}
} else {
// double quote syntax, e.g. ""
- if (!isQualifier(c))
+ if (!isQualifier(c)) {
return false;
+ }
peek(c2);
if (!m_isEof) { // not EOF, can read one char
if (isQualifier(c2)) {
@@ -294,16 +306,18 @@ void CsvParser::ungetChar()
void CsvParser::peek(QChar& c)
{
getChar(c);
- if (!m_isEof)
+ if (!m_isEof) {
ungetChar();
+ }
}
bool CsvParser::isQualifier(const QChar& c) const
{
- if (true == m_isBackslashSyntax && (c != m_qualifier))
+ if (true == m_isBackslashSyntax && (c != m_qualifier)) {
return (c == '\\');
- else
+ } else {
return (c == m_qualifier);
+ }
}
bool CsvParser::isComment()
@@ -312,12 +326,13 @@ bool CsvParser::isComment()
QChar c2;
qint64 pos = m_ts.pos();
- do
+ do {
getChar(c2);
- while ((isSpace(c2) || isTab(c2)) && (!m_isEof));
+ } while ((isSpace(c2) || isTab(c2)) && (!m_isEof));
- if (c2 == m_comment)
+ if (c2 == m_comment) {
result = true;
+ }
m_ts.seek(pos);
return result;
}
@@ -330,9 +345,11 @@ bool CsvParser::isText(QChar c) const
bool CsvParser::isEmptyRow(const CsvRow& row) const
{
CsvRow::const_iterator it = row.constBegin();
- for (; it != row.constEnd(); ++it)
- if (((*it) != "\n") && ((*it) != ""))
+ for (; it != row.constEnd(); ++it) {
+ if (((*it) != "\n") && ((*it) != "")) {
return false;
+ }
+ }
return true;
}
diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp
index 4e6911c37..d53fa6468 100644
--- a/src/core/Entry.cpp
+++ b/src/core/Entry.cpp
@@ -779,8 +779,9 @@ Entry* Entry::clone(CloneFlags flags) const
entry->m_data.timeInfo.setLocationChanged(now);
}
- if (flags & CloneRenameTitle)
+ if (flags & CloneRenameTitle) {
entry->setTitle(tr("%1 - Clone").arg(entry->title()));
+ }
entry->setUpdateTimeinfo(true);
@@ -1075,8 +1076,9 @@ QString Entry::resolvePlaceholder(const QString& placeholder) const
QString Entry::resolveUrlPlaceholder(const QString& str, Entry::PlaceholderType placeholderType) const
{
- if (str.isEmpty())
+ if (str.isEmpty()) {
return QString();
+ }
const QUrl qurl(str);
switch (placeholderType) {
diff --git a/src/core/Tools.cpp b/src/core/Tools.cpp
index 5d8889fae..1b3eafcca 100644
--- a/src/core/Tools.cpp
+++ b/src/core/Tools.cpp
@@ -113,8 +113,9 @@ namespace Tools
extensions += "\n- " + QObject::tr("Secret Service Integration");
#endif
- if (extensions.isEmpty())
+ if (extensions.isEmpty()) {
extensions = " " + QObject::tr("None");
+ }
debugInfo.append(QObject::tr("Enabled extensions:").append(extensions).append("\n"));
return debugInfo;
diff --git a/src/format/HtmlExporter.cpp b/src/format/HtmlExporter.cpp
index 457623ec9..cd3654e36 100644
--- a/src/format/HtmlExporter.cpp
+++ b/src/format/HtmlExporter.cpp
@@ -28,8 +28,9 @@ namespace
{
QString PixmapToHTML(const QPixmap& pixmap)
{
- if (pixmap.isNull())
+ if (pixmap.isNull()) {
return "";
+ }
// Based on https://stackoverflow.com/a/6621278
QByteArray a;
diff --git a/src/gui/FileDialog.cpp b/src/gui/FileDialog.cpp
index 12f582775..c2b774ceb 100644
--- a/src/gui/FileDialog.cpp
+++ b/src/gui/FileDialog.cpp
@@ -65,8 +65,9 @@ QStringList FileDialog::getOpenFileNames(QWidget* parent,
const auto& workingDir = dir.isEmpty() ? config()->get("LastDir").toString() : dir;
auto results = QFileDialog::getOpenFileNames(parent, caption, workingDir, filter, selectedFilter, options);
- for (auto& path : results)
+ for (auto& path : results) {
path = QDir::toNativeSeparators(path);
+ }
#ifdef Q_OS_MACOS
// on Mac OS X the focus is lost after closing the native dialog
diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp
index 6e6c282b9..85c9e591c 100644
--- a/src/gui/csvImport/CsvImportWidget.cpp
+++ b/src/gui/csvImport/CsvImportWidget.cpp
@@ -294,27 +294,30 @@ void CsvImportWidget::setRootGroup()
for (int r = 0; r < m_parserModel->rowCount(); ++r) {
// use validity of second column as a GO/NOGO for all others fields
- if (not m_parserModel->data(m_parserModel->index(r, 1)).isValid())
+ if (not m_parserModel->data(m_parserModel->index(r, 1)).isValid()) {
continue;
+ }
groupLabel = m_parserModel->data(m_parserModel->index(r, 0)).toString();
// check if group name is either "root", "" (empty) or some other label
groupList = groupLabel.split("/", QString::SkipEmptyParts);
- if (groupList.isEmpty())
+ if (groupList.isEmpty()) {
is_empty = true;
- else if (not groupList.first().compare("Root", Qt::CaseSensitive))
+ } else if (not groupList.first().compare("Root", Qt::CaseSensitive)) {
is_root = true;
- else if (not groupLabel.compare(""))
+ } else if (not groupLabel.compare("")) {
is_empty = true;
- else
+ } else {
is_label = true;
+ }
groupList.clear();
}
- if ((is_empty and is_root) or (is_label and not is_empty and is_root))
+ if ((is_empty and is_root) or (is_label and not is_empty and is_root)) {
m_db->rootGroup()->setName("CSV IMPORTED");
- else
+ } else {
m_db->rootGroup()->setName("Root");
+ }
}
Group* CsvImportWidget::splitGroups(const QString& label)
diff --git a/src/gui/csvImport/CsvParserModel.cpp b/src/gui/csvImport/CsvParserModel.cpp
index a6c24667d..d18db87c5 100644
--- a/src/gui/csvImport/CsvParserModel.cpp
+++ b/src/gui/csvImport/CsvParserModel.cpp
@@ -55,8 +55,9 @@ bool CsvParserModel::parse()
QFile csv(m_filename);
r = CsvParser::parse(&csv);
}
- for (int i = 0; i < columnCount(); ++i)
+ for (int i = 0; i < columnCount(); ++i) {
m_columnMap.insert(i, 0);
+ }
addEmptyColumn();
endResetModel();
return r;
@@ -73,13 +74,15 @@ void CsvParserModel::addEmptyColumn()
void CsvParserModel::mapColumns(int csvColumn, int dbColumn)
{
- if ((csvColumn < 0) || (dbColumn < 0))
+ if ((csvColumn < 0) || (dbColumn < 0)) {
return;
+ }
beginResetModel();
- if (csvColumn >= getCsvCols())
+ if (csvColumn >= getCsvCols()) {
m_columnMap[dbColumn] = 0; // map to the empty column
- else
+ } else {
m_columnMap[dbColumn] = csvColumn;
+ }
endResetModel();
}
@@ -99,15 +102,17 @@ void CsvParserModel::setHeaderLabels(const QStringList& labels)
int CsvParserModel::rowCount(const QModelIndex& parent) const
{
- if (parent.isValid())
+ if (parent.isValid()) {
return 0;
+ }
return getCsvRows();
}
int CsvParserModel::columnCount(const QModelIndex& parent) const
{
- if (parent.isValid())
+ if (parent.isValid()) {
return 0;
+ }
return m_columnHeader.size();
}
@@ -116,8 +121,9 @@ QVariant CsvParserModel::data(const QModelIndex& index, int role) const
if ((index.column() >= m_columnHeader.size()) || (index.row() + m_skipped >= rowCount()) || !index.isValid()) {
return QVariant();
}
- if (role == Qt::DisplayRole)
+ if (role == Qt::DisplayRole) {
return m_table.at(index.row() + m_skipped).at(m_columnMap[index.column()]);
+ }
return QVariant();
}
@@ -125,12 +131,14 @@ QVariant CsvParserModel::headerData(int section, Qt::Orientation orientation, in
{
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
- if ((section < 0) || (section >= m_columnHeader.size()))
+ if ((section < 0) || (section >= m_columnHeader.size())) {
return QVariant();
+ }
return m_columnHeader.at(section);
} else if (orientation == Qt::Vertical) {
- if (section + m_skipped >= rowCount())
+ if (section + m_skipped >= rowCount()) {
return QVariant();
+ }
return QString::number(section + 1);
}
}
diff --git a/src/gui/group/GroupView.cpp b/src/gui/group/GroupView.cpp
index 33c591696..48945085b 100644
--- a/src/gui/group/GroupView.cpp
+++ b/src/gui/group/GroupView.cpp
@@ -155,10 +155,11 @@ void GroupView::syncExpandedState(const QModelIndex& parent, int start, int end)
void GroupView::setCurrentGroup(Group* group)
{
- if (group == nullptr)
+ if (group == nullptr) {
setCurrentIndex(QModelIndex());
- else
+ } else {
setCurrentIndex(m_model->index(group));
+ }
}
void GroupView::modelReset()
diff --git a/src/gui/widgets/ElidedLabel.cpp b/src/gui/widgets/ElidedLabel.cpp
index 749f075c8..5e71fbceb 100644
--- a/src/gui/widgets/ElidedLabel.cpp
+++ b/src/gui/widgets/ElidedLabel.cpp
@@ -56,8 +56,9 @@ QString ElidedLabel::url() const
void ElidedLabel::setElideMode(Qt::TextElideMode elideMode)
{
- if (m_elideMode == elideMode)
+ if (m_elideMode == elideMode) {
return;
+ }
if (m_elideMode != Qt::ElideNone) {
setWordWrap(false);
@@ -69,8 +70,9 @@ void ElidedLabel::setElideMode(Qt::TextElideMode elideMode)
void ElidedLabel::setRawText(const QString& elidedText)
{
- if (m_rawText == elidedText)
+ if (m_rawText == elidedText) {
return;
+ }
m_rawText = elidedText;
emit rawTextChanged(m_rawText);
@@ -78,8 +80,9 @@ void ElidedLabel::setRawText(const QString& elidedText)
void ElidedLabel::setUrl(const QString& url)
{
- if (m_url == url)
+ if (m_url == url) {
return;
+ }
m_url = url;
emit urlChanged(m_url);
diff --git a/tests/TestCsvParser.cpp b/tests/TestCsvParser.cpp
index f31e30414..758c31ecc 100644
--- a/tests/TestCsvParser.cpp
+++ b/tests/TestCsvParser.cpp
@@ -30,8 +30,9 @@ void TestCsvParser::initTestCase()
void TestCsvParser::init()
{
file.reset(new QTemporaryFile());
- if (not file->open())
+ if (not file->open()) {
QFAIL("Cannot open file!");
+ }
parser->setBackslashSyntax(false);
parser->setComment('#');
parser->setFieldSeparator(',');
diff --git a/tests/TestSymmetricCipher.cpp b/tests/TestSymmetricCipher.cpp
index 752fc09df..173f328ee 100644
--- a/tests/TestSymmetricCipher.cpp
+++ b/tests/TestSymmetricCipher.cpp
@@ -289,14 +289,16 @@ void TestSymmetricCipher::testTwofish256CbcEncryption()
QCOMPARE(cipher.blockSize(), 16);
for (int j = 0; j < 5000; ++j) {
ctCur = cipher.process(ptNext, &ok);
- if (!ok)
+ if (!ok) {
break;
+ }
ptNext = ctPrev;
ctPrev = ctCur;
ctCur = cipher.process(ptNext, &ok);
- if (!ok)
+ if (!ok) {
break;
+ }
ptNext = ctPrev;
ctPrev = ctCur;
}
@@ -342,13 +344,15 @@ void TestSymmetricCipher::testTwofish256CbcDecryption()
QCOMPARE(cipher.blockSize(), 16);
for (int j = 0; j < 5000; ++j) {
ptCur = cipher.process(ctNext, &ok);
- if (!ok)
+ if (!ok) {
break;
+ }
ctNext = ptCur;
ptCur = cipher.process(ctNext, &ok);
- if (!ok)
+ if (!ok) {
break;
+ }
ctNext = ptCur;
}
diff --git a/tests/TestYkChallengeResponseKey.cpp b/tests/TestYkChallengeResponseKey.cpp
index 0d6f9b5c3..a4dd76270 100644
--- a/tests/TestYkChallengeResponseKey.cpp
+++ b/tests/TestYkChallengeResponseKey.cpp
@@ -84,12 +84,14 @@ void TestYubiKeyChalResp::ykDetected(int slot, bool blocking)
{
Q_UNUSED(blocking);
- if (slot > 0)
+ if (slot > 0) {
m_detected++;
+ }
/* Key used for later testing */
- if (!m_key)
+ if (!m_key) {
m_key.reset(new YkChallengeResponseKey(slot, blocking));
+ }
}
void TestYubiKeyChalResp::deinit()