• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IJHack / QtPass / 25576477093

08 May 2026 07:56PM UTC coverage: 28.048% (+0.03%) from 28.015%
25576477093

push

github

web-flow
refactor: clang-tidy cleanup (1 real bug + bulk modernize/performance fixes) (#1432)

* fix(trayicon): remove dead misleading setVisible method

TrayIcon::setVisible(bool) was a name collision with its base
class QWidget::setVisible(bool) — same signature, but the
implementation didn't toggle the tray icon's visibility. It
shows/hides the parent window:

  void TrayIcon::setVisible(bool visible) {
    if (visible) parentwin->show();
    else         parentwin->hide();
  }

Two problems:
- Misleading name: doesn't do what the QWidget API contract
  promises.
- Virtual shadowing without override: calling through a QWidget*
  pointer would call the base implementation, not this one,
  silently breaking caller intent.

Searched for callers — there are none. The method is dead code.
Removed the declaration and implementation together. Show/hide
of the parent window already happens elsewhere (via showAction
/ hideAction signals in createActions).

Caught by clang-tidy modernize-use-override.

* chore(clang-tidy): drop noisy stylistic checks

Two clang-tidy checks were producing high-volume findings that
the project doesn't actually want to fix:

- modernize-use-trailing-return-type (~55 in QtPass code, ~11K
  total counting Qt headers): suggests "auto foo() -> int"
  style. Project codebase mixes both; not enforcing the trailing
  form is a deliberate stylistic choice.

- modernize-use-nodiscard (~5 in QtPass code, ~3.7K total):
  suggests [[nodiscard]] on every getter. Project is selective
  about which getters need it; auto-applying everywhere creates
  noise and doesn't reflect intent.

Disabled both. Keeps the rest of modernize-* / performance-*
active so genuine improvements (default-member-init, override,
braced-init-list, enum-size, etc.) keep getting flagged.

Also added HeaderFilterRegex to keep findings from vendored
qprogressindicator out of the diagnostic stream.

* refactor: apply clang-tidy auto-fixes (modernize-* + performance-*)

Bulk pass o... (continued)

5 of 18 new or added lines in 12 files covered. (27.78%)

9 existing lines in 1 file now uncovered.

1854 of 6610 relevant lines covered (28.05%)

27.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/singleapplication.cpp
1
// SPDX-FileCopyrightText: 2014 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
3
#include "singleapplication.h"
4
#include <QLocalSocket>
5
#include <utility>
6
#ifdef QT_DEBUG
7
#include "debughelper.h"
8
#endif
9

10
/**
11
 * @brief SingleApplication::SingleApplication this replaces the QApplication
12
 * allowing for local socket based communications.
13
 * @param argc
14
 * @param argv
15
 * @param uniqueKey
16
 */
NEW
17
SingleApplication::SingleApplication(
×
18
    int &argc, char *argv[], // NOLINT(modernize-avoid-c-arrays)
NEW
19
    QString uniqueKey)
×
20
    : QApplication(argc, argv), _uniqueKey(std::move(uniqueKey)) {
×
21
  sharedMemory.setKey(_uniqueKey);
×
22
  if (sharedMemory.attach()) {
×
23
    _isRunning = true;
×
24
  } else {
25
    _isRunning = false;
×
26
    // create shared memory.
27
    if (!sharedMemory.create(1)) {
×
28
#ifdef QT_DEBUG
29
      dbg() << "Unable to create single instance.";
30
#endif
31
      return;
32
    }
33
    // create local server and listen to incoming messages from other
34
    // instances.
35
    localServer.reset(new QLocalServer(this));
×
36
    connect(localServer.data(), &QLocalServer::newConnection, this,
×
37
            &SingleApplication::receiveMessage);
×
38
    localServer->listen(_uniqueKey);
×
39
  }
40
}
×
41

42
// public slots.
43

44
/**
45
 * @brief SingleApplication::receiveMessage we have received (a command line)
46
 * message.
47
 */
48
void SingleApplication::receiveMessage() {
×
49
  QLocalSocket *localSocket = localServer->nextPendingConnection();
×
50
  if (!localSocket->waitForReadyRead(timeout)) {
×
51
#ifdef QT_DEBUG
52
    dbg() << localSocket->errorString().toLatin1();
53
#endif
54
    return;
×
55
  }
56
  QByteArray byteArray = localSocket->readAll();
×
57
  QString message = QString::fromUtf8(byteArray.constData());
×
58
  emit messageAvailable(message);
×
59
  localSocket->disconnectFromServer();
×
60
}
61

62
// public functions.
63
/**
64
 * @brief SingleApplication::isRunning is there already a QtPass instance
65
 * running, to check whether to be server or client.
66
 * @return
67
 */
68
auto SingleApplication::isRunning() -> bool { return _isRunning; }
×
69

70
/**
71
 * @brief SingleApplication::sendMessage send a message (from commandline) to an
72
 * already running QtPass instance.
73
 * @param message
74
 * @return
75
 */
76
auto SingleApplication::sendMessage(const QString &message) -> bool {
×
77
  if (!_isRunning) {
×
78
    return false;
79
  }
80
  QLocalSocket localSocket(this);
×
81
  localSocket.connectToServer(_uniqueKey, QIODevice::WriteOnly);
×
82
  if (!localSocket.waitForConnected(timeout)) {
×
83
#ifdef QT_DEBUG
84
    dbg() << localSocket.errorString().toLatin1();
85
#endif
86
    return false;
87
  }
88
  QByteArray payload = message.toUtf8();
89
  if (payload.isEmpty()) {
×
90
    payload = QByteArray(1, '\0');
×
91
  }
92
  localSocket.write(payload);
×
93
  if (!localSocket.waitForBytesWritten(timeout)) {
×
94
#ifdef QT_DEBUG
95
    dbg() << localSocket.errorString().toLatin1();
96
#endif
97
    return false;
98
  }
99
  localSocket.disconnectFromServer();
×
100
  return true;
101
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc