Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues found by sonarcloud #2666

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
project = 'CopyQ'
copyright = '2024, Lukas Holecek'
author = 'Lukas Holecek'
title = 'CopyQ Documentation'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -131,8 +132,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'CopyQ.tex', 'CopyQ Documentation',
'Lukas Holecek', 'manual'),
(master_doc, 'CopyQ.tex', title, author, 'manual'),
]


Expand All @@ -141,8 +141,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'copyq', 'CopyQ Documentation',
[author], 1)
(master_doc, 'copyq', title, [author], 1)
]


Expand All @@ -152,7 +151,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'CopyQ', 'CopyQ Documentation',
(master_doc, 'CopyQ', title,
author, 'CopyQ', 'One line description of project.',
'Miscellaneous'),
]
Expand Down
10 changes: 4 additions & 6 deletions plugins/itemencrypted/itemencrypted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ bool verifyProcess(QProcess *p, int timeoutMs = 30000)
}

if (exitCode != 0) {
const QString errors = p->readAllStandardError();
if ( !errors.isEmpty() )
if (const QString errors = p->readAllStandardError(); !errors.isEmpty()) {
log( QStringLiteral("ItemEncrypt: GnuPG stderr:\n%1")
.arg(errors), LogError );
}
return false;
}

Expand Down Expand Up @@ -330,8 +330,7 @@ void startGenerateKeysProcess(QProcess *process, bool useTransientPasswordlessKe

QString exportImportGpgKeys()
{
const auto error = exportGpgKey();
if ( !error.isEmpty() )
if (const auto error = exportGpgKey(); !error.isEmpty())
return error;

return importGpgKey();
Expand Down Expand Up @@ -597,8 +596,7 @@ QString ItemEncryptedScriptable::generateTestKeys()
QString::fromUtf8(process.readAllStandardError()) );
}

const auto error = exportImportGpgKeys();
if ( !error.isEmpty() )
if ( const auto error = exportImportGpgKeys(); !error.isEmpty() )
return error;

for (const auto &keyFileName : keys) {
Expand Down
6 changes: 4 additions & 2 deletions plugins/itemfakevim/fakevim/fakevimhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6159,9 +6159,11 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd)
if (cmd.args.contains('=')) {
// Non-boolean config to set.
int p = cmd.args.indexOf('=');
QString error = s.trySetValue(cmd.args.left(p), cmd.args.mid(p + 1));
if (!error.isEmpty())
if ( const QString error = s.trySetValue(cmd.args.left(p), cmd.args.mid(p + 1));
!error.isEmpty() )
{
showMessage(MessageError, error);
}
} else {
QString optionName = cmd.args;

Expand Down
4 changes: 2 additions & 2 deletions plugins/itemfakevim/itemfakevim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace {

const char propertyWrapped[] = "CopyQ_fakevim_wrapped";

QLatin1String configReallyEnabled("really_enable");
QLatin1String configSourceFile("source_file");
const QLatin1String configReallyEnabled("really_enable");
const QLatin1String configSourceFile("source_file");

// The same method for rendering document doesn't work for QPlainTextEdit.
// This is simplified code from Qt source code.
Expand Down
6 changes: 3 additions & 3 deletions plugins/itemnotes/itemnotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const int defaultMaxBytes = 10*1024;

const int notesIndent = 16;

QLatin1String configNotesAtBottom("notes_at_bottom");
QLatin1String configNotesBeside("notes_beside");
QLatin1String configShowTooltip("show_tooltip");
const QLatin1String configNotesAtBottom("notes_at_bottom");
const QLatin1String configNotesBeside("notes_beside");
const QLatin1String configShowTooltip("show_tooltip");

QWidget *createIconWidget(const QByteArray &icon, QWidget *parent)
{
Expand Down
1 change: 1 addition & 0 deletions src/platform/win/winplatformclipboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class WinPlatformClipboard final : public DummyClipboard
protected:
void onChanged(int) override;

private:
DWORD m_lastClipboardSequenceNumber = -1;
};

Expand Down
15 changes: 5 additions & 10 deletions src/scriptable/scriptable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,7 @@ QJSValue Scriptable::removeTab()
m_skipArguments = 1;

const QString &name = arg(0);
const QString error = m_proxy->removeTab(name);
if ( !error.isEmpty() )
if ( const QString error = m_proxy->removeTab(name); !error.isEmpty() )
return throwError(error);
return QJSValue();
}
Expand All @@ -1036,8 +1035,7 @@ QJSValue Scriptable::renameTab()
m_skipArguments = 2;
const QString &name = arg(0);
const QString &newName = arg(1);
const QString error = m_proxy->renameTab(newName, name);
if ( !error.isEmpty() )
if ( const QString error = m_proxy->renameTab(newName, name); !error.isEmpty() )
return throwError(error);
return QJSValue();
}
Expand Down Expand Up @@ -1117,8 +1115,7 @@ QJSValue Scriptable::remove()
if ( rows.empty() )
rows.append(0);

const auto error = m_proxy->browserRemoveRows(m_tabName, rows);
if ( !error.isEmpty() )
if ( const auto error = m_proxy->browserRemoveRows(m_tabName, rows); !error.isEmpty() )
return throwError(error);
return QJSValue();
}
Expand Down Expand Up @@ -2332,8 +2329,7 @@ QJSValue Scriptable::loadTheme()
m_skipArguments = 1;

const QString path = getAbsoluteFilePath(arg(0));
const QString error = m_proxy->loadTheme(path);
if ( !error.isEmpty() )
if ( const QString error = m_proxy->loadTheme(path); !error.isEmpty() )
return throwError(error);

return QJSValue();
Expand Down Expand Up @@ -3322,8 +3318,7 @@ void Scriptable::insert(int row, int argumentsBegin, int argumentsEnd)
m_skipArguments = argumentsEnd;

const VariantMapList items{getItemList(argumentsBegin, argumentsEnd, argumentsArray())};
const auto error = m_proxy->browserInsert(m_tabName, row, items);
if ( !error.isEmpty() )
if ( const auto error = m_proxy->browserInsert(m_tabName, row, items); !error.isEmpty() )
throwError(error);
}

Expand Down
9 changes: 6 additions & 3 deletions src/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QTest>
#include <QTimer>

#include <array>
#include <memory>

#define WITH_TIMEOUT "afterMilliseconds(10000, fail); "
Expand Down Expand Up @@ -149,7 +150,7 @@ bool testStderr(const QByteArray &stderrData, TestInterface::ReadStderrFlag flag
};
// Ignore exceptions and errors from clients in application log
// (these are expected in some tests).
static const std::vector<QRegularExpression> ignoreList{
static const std::array ignoreList{
regex(R"(CopyQ Note \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\] <Client-[^\n]*)"),

plain("Event handler maximum recursion reached"),
Expand Down Expand Up @@ -500,9 +501,11 @@ class TestInterfaceImpl final : public TestInterface {

QByteArray setClipboard(const QByteArray &bytes, const QString &mime, ClipboardMode mode) override
{
const QByteArray error = setClipboard( createDataMap(mime, bytes), mode );
if (!error.isEmpty())
if ( const QByteArray error = setClipboard(createDataMap(mime, bytes), mode);
!error.isEmpty() )
{
return error;
}

return verifyClipboard(bytes, mime);
}
Expand Down