Commit e9d19fcd authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

add [[nodiscard]] attribute through clang-tidy

will warn for example when calling constant methods returning a value
and ignoring it
parent 0bad4a40
......@@ -32,11 +32,11 @@ public:
~AbstractFileListener() override;
DatabaseInterface* databaseInterface() const;
[[nodiscard]] DatabaseInterface* databaseInterface() const;
AbstractFileListing* fileListing() const;
[[nodiscard]] AbstractFileListing* fileListing() const;
bool canHandleRootPaths() const;
[[nodiscard]] bool canHandleRootPaths() const;
Q_SIGNALS:
......
......@@ -35,9 +35,9 @@ public:
virtual void applicationAboutToQuit();
const QStringList& allRootPaths() const;
[[nodiscard]] const QStringList& allRootPaths() const;
virtual bool canHandleRootPaths() const;
[[nodiscard]] virtual bool canHandleRootPaths() const;
Q_SIGNALS:
......@@ -113,11 +113,11 @@ protected:
FileScanner& fileScanner();
bool waitEndTrackRemoval() const;
[[nodiscard]] bool waitEndTrackRemoval() const;
void setWaitEndTrackRemoval(bool wait);
bool isActive() const;
[[nodiscard]] bool isActive() const;
private:
......
......@@ -68,23 +68,23 @@ public:
~AudioWrapper() override;
bool muted() const;
[[nodiscard]] bool muted() const;
qreal volume() const;
[[nodiscard]] qreal volume() const;
QUrl source() const;
[[nodiscard]] QUrl source() const;
QMediaPlayer::MediaStatus status() const;
[[nodiscard]] QMediaPlayer::MediaStatus status() const;
QMediaPlayer::State playbackState() const;
[[nodiscard]] QMediaPlayer::State playbackState() const;
QMediaPlayer::Error error() const;
[[nodiscard]] QMediaPlayer::Error error() const;
qint64 duration() const;
[[nodiscard]] qint64 duration() const;
qint64 position() const;
[[nodiscard]] qint64 position() const;
bool seekable() const;
[[nodiscard]] bool seekable() const;
Q_SIGNALS:
......
......@@ -23,7 +23,7 @@ public:
explicit BalooDetector(QObject *parent = nullptr);
bool balooAvailability() const;
[[nodiscard]] bool balooAvailability() const;
Q_SIGNALS:
......
......@@ -32,7 +32,7 @@ public:
void applicationAboutToQuit() override;
bool canHandleRootPaths() const override;
[[nodiscard]] bool canHandleRootPaths() const override;
Q_SIGNALS:
......
......@@ -1227,7 +1227,7 @@ void DatabaseInterface::removeTracksList(const QList<QUrl> &removedTracks)
Q_EMIT finishRemovingTracksList();
}
bool DatabaseInterface::startTransaction() const
bool DatabaseInterface::startTransaction()
{
auto result = false;
......@@ -1243,7 +1243,7 @@ bool DatabaseInterface::startTransaction() const
return result;
}
bool DatabaseInterface::finishTransaction() const
bool DatabaseInterface::finishTransaction()
{
auto result = false;
......@@ -1260,7 +1260,7 @@ bool DatabaseInterface::finishTransaction() const
return result;
}
bool DatabaseInterface::rollBackTransaction() const
bool DatabaseInterface::rollBackTransaction()
{
auto result = false;
......
......@@ -169,11 +169,11 @@ private:
void recordModifiedAlbum(qulonglong albumId);
bool startTransaction() const;
bool startTransaction();
bool finishTransaction() const;
bool finishTransaction();
bool rollBackTransaction() const;
bool rollBackTransaction();
QList<qulonglong> fetchTrackIds(qulonglong albumId);
......@@ -233,9 +233,9 @@ private:
qulonglong internalInsertTrack(const DataTypes::TrackDataType &oneModifiedTrack,
const QHash<QString, QUrl> &covers, bool &isInserted);
DataTypes::TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const;
[[nodiscard]] DataTypes::TrackDataType buildTrackDataFromDatabaseRecord(const QSqlRecord &trackRecord) const;
DataTypes::TrackDataType buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const;
[[nodiscard]] DataTypes::TrackDataType buildRadioDataFromDatabaseRecord(const QSqlRecord &trackRecord) const;
void internalRemoveTracksList(const QList<QUrl> &removedTracks);
......
......@@ -84,22 +84,22 @@ public:
public:
using DataType::DataType;
bool hasDatabaseId() const
[[nodiscard]] bool hasDatabaseId() const
{
return find(key_type::DatabaseIdRole) != end();
}
qulonglong databaseId() const
[[nodiscard]] qulonglong databaseId() const
{
return operator[](key_type::DatabaseIdRole).toULongLong();
}
bool hasElementType() const
[[nodiscard]] bool hasElementType() const
{
return find(key_type::ElementTypeRole) != end();
}
ElisaUtils::PlayListEntryType elementType() const
[[nodiscard]] ElisaUtils::PlayListEntryType elementType() const
{
return operator[](key_type::ElementTypeRole).value<ElisaUtils::PlayListEntryType>();
}
......@@ -128,158 +128,158 @@ public:
Q_UNUSED(aValid)
}
bool isValid() const
[[nodiscard]] bool isValid() const
{
return !isEmpty() && duration().isValid();
}
QString title() const
[[nodiscard]] QString title() const
{
return operator[](key_type::TitleRole).toString();
}
QString artist() const
[[nodiscard]] QString artist() const
{
return operator[](key_type::ArtistRole).toString();
}
qulonglong albumId() const
[[nodiscard]] qulonglong albumId() const
{
return operator[](key_type::AlbumIdRole).toULongLong();
}
bool hasAlbum() const
[[nodiscard]] bool hasAlbum() const
{
return find(key_type::AlbumRole) != end();
}
QString album() const
[[nodiscard]] QString album() const
{
return operator[](key_type::AlbumRole).toString();
}
QString albumArtist() const
[[nodiscard]] QString albumArtist() const
{
return operator[](key_type::AlbumArtistRole).toString();
}
bool hasAlbumArtist() const
[[nodiscard]] bool hasAlbumArtist() const
{
return find(key_type::AlbumArtistRole) != end();
}
bool hasTrackNumber() const
[[nodiscard]] bool hasTrackNumber() const
{
return find(key_type::TrackNumberRole) != end();
}
int trackNumber() const
[[nodiscard]] int trackNumber() const
{
return operator[](key_type::TrackNumberRole).toInt();
}
bool hasDiscNumber() const
[[nodiscard]] bool hasDiscNumber() const
{
return find(key_type::DiscNumberRole) != end();
}
int discNumber() const
[[nodiscard]] int discNumber() const
{
return operator[](key_type::DiscNumberRole).toInt();
}
QTime duration() const
[[nodiscard]] QTime duration() const
{
return operator[](key_type::DurationRole).toTime();
}
QUrl resourceURI() const
[[nodiscard]] QUrl resourceURI() const
{
return operator[](key_type::ResourceRole).toUrl();
}
QUrl albumCover() const
[[nodiscard]] QUrl albumCover() const
{
return operator[](key_type::ImageUrlRole).toUrl();
}
bool isSingleDiscAlbum() const
[[nodiscard]] bool isSingleDiscAlbum() const
{
return operator[](key_type::IsSingleDiscAlbumRole).toBool();
}
int rating() const
[[nodiscard]] int rating() const
{
return operator[](key_type::RatingRole).toInt();
}
QString genre() const
[[nodiscard]] QString genre() const
{
return operator[](key_type::GenreRole).toString();
}
QString composer() const
[[nodiscard]] QString composer() const
{
return operator[](key_type::ComposerRole).toString();
}
QString lyricist() const
[[nodiscard]] QString lyricist() const
{
return operator[](key_type::LyricistRole).toString();
}
QString lyrics() const
[[nodiscard]] QString lyrics() const
{
return operator[](key_type::LyricsRole).toString();
}
QString comment() const
[[nodiscard]] QString comment() const
{
return operator[](key_type::CommentRole).toString();
}
int year() const
[[nodiscard]] int year() const
{
return operator[](key_type::YearRole).toInt();
}
int channels() const
[[nodiscard]] int channels() const
{
return operator[](key_type::ChannelsRole).toInt();
}
bool hasChannels() const
[[nodiscard]] bool hasChannels() const
{
return find(key_type::ChannelsRole) != end();
}
int bitRate() const
[[nodiscard]] int bitRate() const
{
return operator[](key_type::BitRateRole).toInt();
}
bool hasBitRate() const
[[nodiscard]] bool hasBitRate() const
{
return find(key_type::BitRateRole) != end();
}
int sampleRate() const
[[nodiscard]] int sampleRate() const
{
return operator[](key_type::SampleRateRole).toInt();
}
bool hasSampleRate() const
[[nodiscard]] bool hasSampleRate() const
{
return find(key_type::SampleRateRole) != end();
}
bool hasEmbeddedCover() const
[[nodiscard]] bool hasEmbeddedCover() const
{
return operator[](key_type::HasEmbeddedCover).toBool();
}
QDateTime fileModificationTime() const
[[nodiscard]] QDateTime fileModificationTime() const
{
return operator[](key_type::FileModificationTime).toDateTime();
}
......@@ -295,38 +295,38 @@ public:
using MusicDataType::MusicDataType;
QString title() const
[[nodiscard]] QString title() const
{
return operator[](key_type::TitleRole).toString();
}
QString artist() const
[[nodiscard]] QString artist() const
{
return operator[](key_type::ArtistRole).toString();
}
bool isValidArtist() const
[[nodiscard]] bool isValidArtist() const
{
const auto &artistData = operator[](key_type::ArtistRole);
return artistData.isValid() && !artistData.toString().isEmpty();
}
QStringList genres() const
[[nodiscard]] QStringList genres() const
{
return operator[](key_type::GenreRole).toStringList();
}
QUrl albumArtURI() const
[[nodiscard]] QUrl albumArtURI() const
{
return operator[](key_type::ImageUrlRole).toUrl();
}
bool isSingleDiscAlbum() const
[[nodiscard]] bool isSingleDiscAlbum() const
{
return operator[](key_type::IsSingleDiscAlbumRole).toBool();
}
bool isValid() const
[[nodiscard]] bool isValid() const
{
return !isEmpty();
}
......@@ -341,12 +341,12 @@ public:
using MusicDataType::MusicDataType;
QString name() const
[[nodiscard]] QString name() const
{
return operator[](key_type::TitleRole).toString();
}
qulonglong databaseId() const
[[nodiscard]] qulonglong databaseId() const
{
return operator[](key_type::DatabaseIdRole).toULongLong();
}
......@@ -361,7 +361,7 @@ public:
using MusicDataType::MusicDataType;
QString title() const
[[nodiscard]] QString title() const
{
return operator[](key_type::TitleRole).toString();
}
......
......@@ -107,27 +107,27 @@ public:
bool eventFilter(QObject *object, QEvent *event) override;
const DataTypes::EntryDataList &arguments() const;
[[nodiscard]] const DataTypes::EntryDataList &arguments() const;
MusicListenersManager *musicManager() const;
[[nodiscard]] MusicListenersManager *musicManager() const;
MediaPlayList *mediaPlayList() const;
[[nodiscard]] MediaPlayList *mediaPlayList() const;
MediaPlayListProxyModel *mediaPlayListProxyModel() const;
[[nodiscard]] MediaPlayListProxyModel *mediaPlayListProxyModel() const;
AudioWrapper *audioPlayer() const;
[[nodiscard]] AudioWrapper *audioPlayer() const;
ManageAudioPlayer *audioControl() const;
[[nodiscard]] ManageAudioPlayer *audioControl() const;
ManageMediaPlayerControl *playerControl() const;
[[nodiscard]] ManageMediaPlayerControl *playerControl() const;
ManageHeaderBar *manageHeaderBar() const;
[[nodiscard]] ManageHeaderBar *manageHeaderBar() const;
bool showProgressOnTaskBar() const;
[[nodiscard]] bool showProgressOnTaskBar() const;
bool showSystemTrayIcon() const;
[[nodiscard]] bool showSystemTrayIcon() const;
ElisaUtils::PlayListEntryType embeddedView() const;
[[nodiscard]] ElisaUtils::PlayListEntryType embeddedView() const;
int initialViewIndex() const;
......@@ -221,7 +221,7 @@ private:
void setupActions(const QString &actionName);
DataTypes::EntryDataList checkFileListAndMakeAbsolute(const DataTypes::EntryDataList &filesList,
[[nodiscard]] DataTypes::EntryDataList checkFileListAndMakeAbsolute(const DataTypes::EntryDataList &filesList,
const QString &workingDirectory) const;
QAbstractItemModel *colorSchemesModel();
......
......@@ -20,7 +20,7 @@ public:
ElisaArguments(QObject *parent = nullptr);
DataTypes::EntryDataList arguments() const
[[nodiscard]] DataTypes::EntryDataList arguments() const
{
return mArguments;
}
......
......@@ -28,7 +28,7 @@ public:
}
}
QQuickTextureFactory *textureFactory() const override
[[nodiscard]] QQuickTextureFactory *textureFactory() const override
{
return QQuickTextureFactory::textureFactoryForImage(mCoverImage);
}
......
......@@ -23,7 +23,7 @@ public:
~FileListener() override;
const LocalFileListing& localFileIndexer() const;
[[nodiscard]] const LocalFileListing& localFileIndexer() const;
private:
......
......@@ -69,44 +69,44 @@ public:
~ElisaConfigurationDialog() override;
QStringList rootPath() const;
[[nodiscard]] QStringList rootPath() const;
bool isDirty() const
[[nodiscard]] bool isDirty() const
{
return mIsDirty;
}
bool showProgressInTaskBar() const
[[nodiscard]] bool showProgressInTaskBar() const
{
return mShowProgressInTaskBar;
}
bool showSystemTrayIcon() const
[[nodiscard]] bool showSystemTrayIcon() const
{
return mShowSystemTrayIcon;
}
bool forceUsageOfFastFileSearch() const
[[nodiscard]] bool forceUsageOfFastFileSearch() const
{
return mForceUsageOfFastFileSearch;
}
ElisaUtils::PlayListEntryType embeddedView() const
[[nodiscard]] ElisaUtils::PlayListEntryType embeddedView() const
{
return mEmbeddedView;
}
int initialViewIndex() const
[[nodiscard]] int initialViewIndex() const
{
return mInitialViewIndex;
}
bool playAtStartup() const
[[nodiscard]] bool playAtStartup() const
{
return mPlayAtStartup;
}
QString colorScheme() const
[[nodiscard]] QString colorScheme() const
{
return mColorScheme;
}
......
......@@ -104,39 +104,39 @@ public:
explicit ManageAudioPlayer(QObject *parent = nullptr);
QPersistentModelIndex currentTrack() const;
[[nodiscard]] QPersistentModelIndex currentTrack() const;
QAbstractItemModel* playListModel() const;
[[nodiscard]] QAbstractItemModel* playListModel() const;
int urlRole() const;
[[nodiscard]] int urlRole() const;
int isPlayingRole() const;
[[nodiscard]] int isPlayingRole() const;
QUrl playerSource() const;
[[nodiscard]] QUrl playerSource() const;
QMediaPlayer::MediaStatus playerStatus() const;
[[nodiscard]] QMediaPlayer::MediaStatus playerStatus() const;
QMediaPlayer::State playerPlaybackState() const;
[[nodiscard]] QMediaPlayer::State playerPlaybackState() const;
QMediaPlayer::Error playerError() const;
[[nodiscard]] QMediaPlayer::Error playerError() const;
qint64 audioDuration() const;
[[nodiscard]] qint64 audioDuration() const;
bool playerIsSeekable() const;
[[nodiscard]] bool playerIsSeekable() const;
qint64 playerPosition() const;
[[nodiscard]] qint64 playerPosition() const;
qint64 playControlPosition() const;
[[nodiscard]] qint64 playControlPosition() const;
QVariantMap persistentState() const;
[[nodiscard]] QVariantMap persistentState() const;