Skip to content

Commit c99a708

Browse files
committed
fix misra mostly rule 14.4
1 parent 1922327 commit c99a708

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/Data.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ qint64 Data::getListRowCount() {
1717
QSqlQuery query(db);
1818
qint64 result = 0;
1919

20-
if (query.prepare("SELECT COUNT(*) FROM Level")) {
21-
if (query.exec()) {
20+
if (query.prepare("SELECT COUNT(*) FROM Level") == true) {
21+
if (query.exec() == true) {
2222
// Move to the first (and only) result row
23-
if (query.next()) {
23+
if (query.next() == true) {
2424
// Assign the count value to result
2525
result = query.value(0).toInt();
2626
qWarning() << "Number of rows in 'Level' table:" << result;
@@ -58,11 +58,11 @@ QVector<ListItemData> Data::getListItems() {
5858
status = false;
5959
}
6060

61-
if (status) {
61+
if (status == true) {
6262
for (qint64 i = 1; i <= rowCount; i++) {
6363
query.bindValue(":id", i); // Bind the current LevelID
64-
if (query.exec()) {
65-
while (query.next()) {
64+
if (query.exec() == true) {
65+
while (query.next() == true) {
6666
items.append(ListItemData(
6767
query.value("Info.title").toString(),
6868
query.value("Author.value").toString(),
@@ -96,9 +96,9 @@ InfoData Data::getInfo(const int id) {
9696
"WHERE Level.LevelID = :id");
9797
query.bindValue(":id", id);
9898

99-
if (status) {
100-
if (query.exec()) {
101-
if (query.next()) {
99+
if (status == true) {
100+
if (query.exec() == true) {
101+
if (query.next() == true) {
102102
QString body = query.value("body").toString();
103103
// notice that we jump over the fist image
104104
// the first image is the cover image

src/FileManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ bool FileManager::extractZip(
131131
}
132132

133133
QString filename = QString::fromUtf8(file_stat.m_filename);
134-
if (filename.endsWith('/')) {
134+
if (filename.endsWith('/') == true) {
135135
continue; // Skip directories
136136
}
137137

@@ -317,7 +317,7 @@ int FileManager::createDirectory(const QString &file, bool gameDir) {
317317
const QString path = FileManager::lookGameDir(file, gameDir);
318318
// Create the directory if it doesn't exist
319319
if (!QDir(path).exists()) {
320-
if (QDir().mkpath(path)) {
320+
if (QDir().mkpath(path) == true) {
321321
qDebug() << "Directory created successfully.";
322322
status = 0;
323323
} else {
@@ -473,7 +473,7 @@ bool FileManager::moveFilesToParentDirectory(
473473
QString destPath = levelDirectoryUpPath.absolutePath() + sep +
474474
fileInfo.fileName();
475475

476-
if (fileInfo.isDir()) {
476+
if (fileInfo.isDir() == true) {
477477
// Move the directory recursively
478478
QDir srcDir(srcPath);
479479
if (!srcDir.rename(srcPath, destPath)) {

src/Model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ bool Model::getLevelDontHaveFile(
230230
bool Model::getLevel(int id) {
231231
assert(id > 0);
232232
bool status = false;
233-
if (id) {
233+
if (id > 0) {
234234
ZipData zipData = data.getDownload(id);
235235
downloader.setUrl(zipData.url);
236236
downloader.setSaveFile(zipData.name);

src/Network.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@ std::string get_ssl_certificate(const std::string& host) {
7575
}
7676

7777
bool Downloader::setUpCamp(const QString& levelDir) {
78+
bool status = false;
7879
QFileInfo levelPathInfo(levelDir);
79-
if (levelPathInfo.isDir()) {
80+
if (levelPathInfo.isDir() == true) {
8081
m_levelDir.setPath(levelDir);
81-
return true;
82+
status = true;
8283
}
83-
return false;
84+
return status;
8485
}
8586

8687
void Downloader::setUrl(QUrl url) {

0 commit comments

Comments
 (0)