Skip to content

Commit

Permalink
chore: misc static analysis fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Nov 16, 2023
1 parent 9686adc commit 16b7ffd
Show file tree
Hide file tree
Showing 69 changed files with 176 additions and 173 deletions.
2 changes: 1 addition & 1 deletion docs/assets/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

/* General */

article h1:first-child
article h1:first-child,
article, h2:first-child {
margin-top: 0;
}
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/commands/szurubooru.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ async function updateTag(name, version, category) {
async function setTagCategory(name, category) {
const tag = await getTag(name);
if (tag === null) {
createTag(name, category);
await createTag(name, category);
} else if (tag.category !== category) {
updateTag(name, tag.version, category);
await updateTag(name, tag.version, category);
}
}

Expand Down Expand Up @@ -72,7 +72,7 @@ async function setTagCategory(name, category) {

// Parse tags and update categories
const tags = argv[0].split(" ");
for (i = 0; i < tags.length; ++i) {
for (let i = 0; i < tags.length; ++i) {
const parts = tags[i].split(":");
const category = parts.shift();
const name = parts.join(":");
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/sites/javascript-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Global match a PCRE regex in a string.
```
\d+ (\d+) (?<third>\d+)
```
```javascript
```json
"01 23 45 67 89 01 23 45 67 89"
```
```javascript
```json
[
{
"0": "01 23 45",
"1": "23",
"2": "45"
"2": "45",
"third": "45"
},
{
Expand Down Expand Up @@ -78,7 +78,7 @@ Parses the string passed and return the parsed XML tree.
</post>
</posts>
```
```javascript
```json
{
"posts": {
"@attributes": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-sources-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getLastCommit(path) {

const args = process.argv.slice(2);
const branch = args.length > 0 ? args[0] : "master";
const isNightly = branch == "develop";
const isNightly = branch === "develop";
const output = {
name: "Official Grabber sources" + (isNightly ? " (nightly)" : ""),
home: "https://github.com/Bionus/imgbrd-grabber",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/src/cli-commands/get-details-cli-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class GetDetailsCliCommand : public CliCommand
Image *m_image;
};

#endif // LOAD_TAG_DATABASE_CLI_COMMAND_H
#endif // GET_DETAILS_CLI_COMMAND_H
4 changes: 2 additions & 2 deletions src/cli/src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ int parseAndRunCliArgs(QCoreApplication *app, Profile *profile, bool defaultToGu

QTextStream stream(stdout);
Printer *printer = parser.isSet(jsonOption)
? (Printer*) new JsonPrinter(&stream, profile)
: (Printer*) new SimplePrinter(&stream, parser.value(tagsFormatOption));
? static_cast<Printer*>(new JsonPrinter(&stream, profile))
: static_cast<Printer*>(new SimplePrinter(&stream, parser.value(tagsFormatOption)));

CliCommand *cmd = nullptr;

Expand Down
11 changes: 7 additions & 4 deletions src/cli/src/printers/json-printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QList>
#include <QMetaType>
#include <QSharedPointer>
#include <QTextStream>
#include "logger.h"
Expand Down Expand Up @@ -90,17 +91,19 @@ QJsonObject JsonPrinter::serializeImage(const Image &image) const

QJsonObject jsObject;

const auto tokens = image.tokens(m_profile);
for (auto& key : tokens.keys()) {
typedef QVariant::Type Type;
const auto &tokens = image.tokens(m_profile);
for (auto it = tokens.constBegin(); it != tokens.constEnd(); ++it) {
typedef QMetaType::Type Type;

const QString &key = it.key();
if (ignoreKeys.contains(key)) {
continue;
}
if (key.contains("search_")) {
continue;
}

const QVariant& qvalue = tokens.value(key).value();
const QVariant &qvalue = it.value().value();
auto type = qvalue.type();

if (type == QVariant::Type::StringList) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/src/printers/json-printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class JsonPrinter : public Printer
void print(int val) const override;
void print(const QString &val) const override;

void print(const Image &val) const override;
void print(const Image &image) const override;
void print(const QList<QSharedPointer<Image>> &images) const override;
void print(const Tag &tag, Site *site) const override;
void print(const QList<Tag> &tags, Site *site) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/src/printers/simple-printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SimplePrinter : public Printer
void print(int val) const override;
void print(const QString &val) const override;

void print(const Image &val) const override;
void print(const Image &image) const override;
void print(const QList<QSharedPointer<Image>> &images) const override;
void print(const Tag &tag, Site *site) const override;
void print(const QList<Tag> &tags, Site *site) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/async-image-provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ QQuickImageResponse *AsyncImageProvider::requestImageResponse(const QString &id,
auto *reply = manager->get(request);

auto *ret = new AsyncImageResponse(reply, rect);
QObject::connect(ret, &AsyncImageResponse::finished, manager, &QNetworkAccessManager::deleteLater);
connect(ret, &AsyncImageResponse::finished, manager, &QNetworkAccessManager::deleteLater);

return ret;
}
2 changes: 1 addition & 1 deletion src/gui-qml/src/async-image-response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ void AsyncImageResponse::replyFinished()
}

emit finished();
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ColumnLayout {
}
SpinBoxSetting {
name: qsTr("Keep n tags")
visible: multipleSetting.value == "keepN"
visible: multipleSetting.value === "keepN"
setting: Setting {
key: "Save/" + key + "_multiple_keepN"
def: 1
Expand All @@ -71,7 +71,7 @@ ColumnLayout {
}
SpinBoxSetting {
name: qsTr("Keep n tags")
visible: multipleSetting.value == "keepNThenAdd"
visible: multipleSetting.value === "keepNThenAdd"
setting: Setting {
key: "Save/" + key + "_multiple_keepNThenAdd_keep"
def: 1
Expand All @@ -80,7 +80,7 @@ ColumnLayout {
}
TextFieldSetting {
name: qsTr("Then add")
visible: multipleSetting.value == "keepNThenAdd"
visible: multipleSetting.value === "keepNThenAdd"
setting: Setting {
key: "Save/" + key + "_multiple_keepNThenAdd_add"
def: " (+ %count%)"
Expand All @@ -89,7 +89,7 @@ ColumnLayout {
}
TextFieldSetting {
name: qsTr("Replace all tags by")
visible: multipleSetting.value == "replaceAll"
visible: multipleSetting.value === "replaceAll"
setting: Setting {
key: "Save/" + key + "_value"
def: defaultMultiple
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/loaders/search-loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


SearchLoader::SearchLoader(QObject *parent)
: Loader(parent), m_page(1), m_perPage(20), m_hasPrev(false), m_hasNext(false)
: Loader(parent), m_page(1), m_perPage(20), m_profile(nullptr), m_hasPrev(false), m_hasNext(false)
{}


Expand Down
4 changes: 2 additions & 2 deletions src/gui-qml/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ int main(int argc, char *argv[])
// Define a few globals
engine.rootContext()->setContextProperty("VERSION", QString(VERSION));
#ifdef NIGHTLY
engine.rootContext()->setContextProperty("NIGHTLY", true);
engine.rootContext()->setContextProperty("NIGHTLY", QVariant(true));
engine.rootContext()->setContextProperty("NIGHTLY_COMMIT", QString(NIGHTLY_COMMIT));
#else
engine.rootContext()->setContextProperty("NIGHTLY", false);
engine.rootContext()->setContextProperty("NIGHTLY", QVariant(false));
engine.rootContext()->setContextProperty("NIGHTLY_COMMIT", QString());
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/models/qml-image.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class QmlImage : public QObject
bool isGallery() const { return m_image->isGallery(); }

public slots:
void loadTags() { m_image->loadDetails(); };
void loadTags() { m_image->loadDetails(); }

private:
QSharedPointer<Image> m_image;
Expand Down
1 change: 1 addition & 0 deletions src/gui-qml/src/share/android/android-share-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AndroidShareUtils::AndroidShareUtils(QQuickItem* parent)
: BaseShareUtils(parent)
{}


bool AndroidShareUtils::share(const QString &text)
{
if (!QJniObject::isClassAvailable("org/bionus/grabber/ShareUtils")) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/share/android/android-share-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AndroidShareUtils : public BaseShareUtils
Q_OBJECT

public:
AndroidShareUtils(QQuickItem* parent = 0);
explicit AndroidShareUtils(QQuickItem *parent = nullptr);

bool share(const QString &text) override;
bool sendFile(const QString &path, const QString &mimeType, const QString &title) override;
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/share/base-share-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class BaseShareUtils : public QQuickItem
{
public:
BaseShareUtils(QQuickItem *parent = 0) : QQuickItem(parent){}
explicit BaseShareUtils(QQuickItem *parent = nullptr) : QQuickItem(parent){}
virtual ~BaseShareUtils() {}

virtual bool share(const QString &text) { return true; }
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/share/share-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ShareUtils : public QQuickItem
Q_OBJECT

public:
explicit ShareUtils(QQuickItem *parent = 0);
explicit ShareUtils(QQuickItem *parent = nullptr);

public slots:
void share(const QString &text);
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/share/windows/windows-share-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class WindowsShareUtils : public BaseShareUtils
Q_OBJECT

public:
WindowsShareUtils(QQuickItem *parent = nullptr);
explicit WindowsShareUtils(QQuickItem *parent = nullptr);

bool share(const QString &text) override;
bool shareUrl(const QUrl &url);
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/src/syntax-highlighter-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SyntaxHighlighterHelper : public QObject
Q_PROPERTY(QQuickTextDocument * quickDocument READ quickDocument WRITE setQuickDocument NOTIFY quickDocumentChanged)

public:
SyntaxHighlighterHelper(QObject *parent = nullptr) : QObject(parent), m_quickDocument(nullptr) {}
explicit SyntaxHighlighterHelper(QObject *parent = nullptr) : QObject(parent), m_quickDocument(nullptr) {}
QQuickTextDocument *quickDocument() const { return m_quickDocument; }
void setQuickDocument(QQuickTextDocument *quickDocument)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/about-window.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AboutWindow : public QDialog
Q_OBJECT

public:
explicit AboutWindow(const QString &v, QWidget *parent = nullptr);
explicit AboutWindow(const QString &version, QWidget *parent = nullptr);
~AboutWindow() override;

public slots:
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/batch/add-unique-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void AddUniqueWindow::loadNext()
connect(m_image.data(), &Image::finishedLoadingTags, this, &AddUniqueWindow::addLoadedImage);
m_image->loadDetails();
} else {
const QString query = (q.id.isEmpty() ? "md5:" + q.md5 : "id:" + q.id);
const QString query = q.id.isEmpty() ? "md5:" + q.md5 : "id:" + q.id;
const QStringList search { query, "status:any" };
m_page = new Page(m_profile, q.site, m_sites.values(), search, 1, 1);
connect(m_page, &Page::finishedLoading, this, &AddUniqueWindow::replyFinished);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/batch/batch-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void BatchWindow::addImage(const QUrl &url, int batch, double size)
}

static QIcon pendingIcon(":/images/status/pending.png");
QTableWidgetItem *id = new QTableWidgetItem(QString::number(m_items + 1));
auto *id = new QTableWidgetItem(QString::number(m_items + 1));
id->setIcon(pendingIcon);

ui->tableWidget->setItem(m_items, 0, id);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/docks/dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


Dock::Dock(QWidget *parent)
: QWidget(parent)
: QWidget(parent), m_currentTab(nullptr)
{}

void Dock::tabChanged(SearchTab *tab)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/src/docks/favorites-dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void FavoritesDock::contextMenu(const QPoint &pos)
}

const QList<Site*> sites = m_currentTab->loadSites();
TagContextMenu *menu = new TagContextMenu(m_hover, {}, {}, m_profile, sites, false, this);
auto *menu = new TagContextMenu(m_hover, {}, {}, m_profile, sites, false, this);
connect(menu, &TagContextMenu::openNewTab, this, &FavoritesDock::emitOpenInNewTab);
menu->exec(QCursor::pos());
}
Expand Down Expand Up @@ -101,7 +101,7 @@ void FavoritesDock::refresh()

int i = 0;
for (const Favorite &fav : qAsConst(m_favorites)) {
QAffiche *lab = new QAffiche(QString(fav.getName()), 0, QColor(), this);
auto *lab = new QAffiche(QString(fav.getName()), 0, QColor(), this);
lab->setText(fav.getName());
lab->setToolTip("<img src=\"" + fav.getImagePath() + "\" /><br/>" + tr("<b>Name:</b> %1<br/><b>Note:</b> %2 %%<br/><b>Last view:</b> %3").arg(fav.getName(), QString::number(fav.getNote()), QLocale().toString(fav.getLastViewed(), QLocale::ShortFormat)));
lab->setCursor(Qt::PointingHandCursor);
Expand Down
4 changes: 2 additions & 2 deletions src/gui/src/docks/settings-dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ void SettingsDock::reset()
{
// Reload filename history
QFile f(m_profile->getPath() + "/filenamehistory.txt");
QStringList filenames;
QSet<QString> filenames;
if (f.open(QFile::ReadOnly | QFile::Text)) {
QString line;
while (!(line = f.readLine()).isEmpty()) {
QString l = line.trimmed();
if (!l.isEmpty() && !filenames.contains(l)) {
filenames.append(l);
filenames.insert(l);
ui->comboFilename->addItem(l);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/src/download-group-table-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Qt::ItemFlags DownloadGroupTableModel::flags(const QModelIndex &index) const
return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;
}

Qt::ItemFlags flags = QAbstractItemModel::flags(index);
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
flags |= Qt::ItemIsDragEnabled;

const int minColumn = m_downloads[index.row()].query.gallery.isNull() ? 1 : 2; // Cannot edit gallery queries
Expand Down Expand Up @@ -188,11 +188,11 @@ bool DownloadGroupTableModel::setData(const QModelIndex &index, const QVariant &
break;

case 9:
download.getBlacklisted = (val != "false");
download.getBlacklisted = val != "false";
break;

case 10:
download.galleriesCountAsOne = (val != "false");
download.galleriesCountAsOne = val != "false";
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/src/full-width-drop-proxy-style.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QWidget;
class FullWidthDropProxyStyle : public QProxyStyle
{
public:
FullWidthDropProxyStyle(QStyle *style = nullptr);
explicit FullWidthDropProxyStyle(QStyle *style = nullptr);
void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
};

Expand Down
Loading

0 comments on commit 16b7ffd

Please sign in to comment.