Skip to content

Commit bc72e8b

Browse files
committed
fix MISRA 15.5 in binary.hpp and use .hpp instead of .h and fix Rule 3.1 form link using // and more
1 parent 0f8a570 commit bc72e8b

19 files changed

+201
-197
lines changed

CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@ endif()
3232
add_subdirectory(libs/miniz)
3333

3434
set(SOURCES_TESTS
35-
test/test.h
35+
test/test.hpp
3636
)
3737

3838
set(SOURCES_MC
3939
src/main.cpp
40-
src/binary.h
41-
src/gameTree.h
42-
src/staticData.h
43-
src/Network.h
40+
src/binary.hpp
41+
src/gameTree.hpp
42+
src/staticData.hpp
43+
src/Network.hpp
4444
src/Network.cpp
45-
src/Controller.h
45+
src/Controller.hpp
4646
src/Controller.cpp
47-
src/FileManager.h
47+
src/FileManager.hpp
4848
src/FileManager.cpp
49-
src/Model.h
49+
src/Model.hpp
5050
src/Model.cpp
51-
src/Data.h
51+
src/Data.hpp
5252
src/Data.cpp
5353
)
5454

5555
set(SOURCES_VIEW
56-
src/TombRaiderLinuxLauncher.h
56+
src/TombRaiderLinuxLauncher.hpp
5757
src/TombRaiderLinuxLauncher.cpp
5858
src/TombRaiderLinuxLauncher.ui
5959
src/resources.qrc

src/Controller.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#include "Controller.h"
14+
#include "Controller.hpp"
1815
#include <QDebug>
1916

2017
Controller::Controller(QObject *parent)

src/Controller.h renamed to src/Controller.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#ifndef SRC_CONTROLLER_H_
18-
#define SRC_CONTROLLER_H_
14+
#ifndef SRC_CONTROLLER_HPP_
15+
#define SRC_CONTROLLER_HPP_
1916
#include <QObject>
2017
#include <QThread>
21-
#include "Model.h"
18+
#include "Model.hpp"
2219

2320
/**
2421
* The controller activate UI thread work or light instant work on the model
@@ -70,4 +67,4 @@ class Controller : public QObject {
7067
Q_DISABLE_COPY(Controller)
7168
};
7269

73-
#endif // SRC_CONTROLLER_H_
70+
#endif // SRC_CONTROLLER_HPP_

src/Data.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#include "Data.h"
14+
#include "Data.hpp"
1815

1916
QVector<ListItemData> Data::getListItems() {
2017
QVector<ListItemData> items;

src/Data.h renamed to src/Data.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#ifndef SRC_DATA_H_
18-
#define SRC_DATA_H_
14+
#ifndef SRC_DATA_HPP_
15+
#define SRC_DATA_HPP_
1916

2017
#include <QObject>
2118
#include <QSqlDatabase>
@@ -181,4 +178,4 @@ class Data : public QObject {
181178
Q_DISABLE_COPY(Data)
182179
};
183180

184-
#endif // SRC_DATA_H_
181+
#endif // SRC_DATA_HPP_

src/FileManager.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#include "FileManager.h"
14+
#include "FileManager.hpp"
1815
#include <QFile>
1916
#include <QIODevice>
2017
#include <QDir>
@@ -23,7 +20,7 @@
2320
#include <QtCore>
2421
#include <QByteArray>
2522
#include <QDataStream>
26-
#include "gameTree.h"
23+
#include "gameTree.hpp"
2724

2825
bool FileManager::setUpCamp(const QString& levelDir, const QString& gameDir) {
2926
QDir levelDirPath(levelDir);
@@ -52,19 +49,26 @@ const QString FileManager::calculateMD5(const QString& file, bool lookGameDir) {
5249
gameDir_m.absolutePath() + QDir::separator()+file :
5350
levelDir_m.absolutePath() + QDir::separator()+file;
5451

52+
QFileInfo fileInfo(path);
53+
54+
if (fileInfo.exists() && !fileInfo.isFile()) {
55+
qDebug() << "Error: The path is not a regular file." << path;
56+
return"";
57+
}
58+
5559
QFile f(path);
56-
if (!f.open(QIODevice::ReadOnly)) {
60+
if (!f.open(QIODevice::ReadOnly)) { // flawfinder: ignore
5761
qDebug() << "Error opening file for reading: " << f.errorString();
5862
return "";
5963
}
6064

6165
QCryptographicHash md5(QCryptographicHash::Md5);
6266

63-
char buffer[1024];
67+
std::array<char, 1024> buffer;
6468
qint64 bytesRead;
6569

66-
while ((bytesRead = f.read(buffer, sizeof(buffer))) > 0) {
67-
md5.addData(buffer, static_cast<int>(bytesRead));
70+
while ((bytesRead = f.read(buffer.data(), buffer.size())) > 0) {
71+
md5.addData(buffer.data(), static_cast<int>(bytesRead));
6872
}
6973

7074
f.close();
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#ifndef SRC_FILEMANAGER_H_
18-
#define SRC_FILEMANAGER_H_
14+
#ifndef SRC_FILEMANAGER_HPP_
15+
#define SRC_FILEMANAGER_HPP_
1916

2017
#include <QString>
2118
#include <QObject>
@@ -72,4 +69,4 @@ class FileManager : public QObject {
7269
QDir gameDir_m;
7370
Q_DISABLE_COPY(FileManager)
7471
};
75-
#endif // SRC_FILEMANAGER_H_
72+
#endif // SRC_FILEMANAGER_HPP_

src/Model.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#include "Model.h"
14+
#include "Model.hpp"
1815

1916
// Those lambda should be in another header file
2017
Model::Model(QObject *parent) : QObject(parent), checkCommonFilesIndex_m(1) {

src/Model.h renamed to src/Model.hpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#ifndef SRC_MODEL_H_
18-
#define SRC_MODEL_H_
14+
#ifndef SRC_MODEL_HPP_
15+
#define SRC_MODEL_HPP_
1916

2017
#include <QObject>
2118
#include <QMap>
2219
#include <QDebug>
2320
#include <QtCore>
24-
#include <assert.h>
25-
#include "Data.h"
26-
#include "FileManager.h"
27-
#include "Network.h"
21+
#include <cassert>
22+
#include "Data.hpp"
23+
#include "FileManager.hpp"
24+
#include "Network.hpp"
2825

2926
class InstructionManager : public QObject {
3027
Q_OBJECT
@@ -53,11 +50,10 @@ class Model : public QObject {
5350
Q_OBJECT
5451

5552
public:
56-
static Model& getInstance()
57-
{
53+
static Model& getInstance() {
5854
static Model instance;
5955
return instance;
60-
};
56+
}
6157
void checkCommonFiles();
6258
int checkGameDirectory(int id);
6359
int checkLevelDirectory(int id);
@@ -90,4 +86,4 @@ class Model : public QObject {
9086
Q_DISABLE_COPY(Model)
9187
};
9288

93-
#endif // SRC_MODEL_H_
89+
#endif // SRC_MODEL_HPP_

src/Network.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111
* GNU General Public License for more details.
12-
13-
* You should have received a copy of the GNU General Public License
14-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1512
*/
1613

17-
#include "Network.h"
14+
#include "Network.hpp"
1815
#include <curl/curl.h>
1916
#include <cstdio>
2017
#include <iostream>
@@ -78,7 +75,7 @@ std::string get_ssl_certificate(const std::string& host) {
7875
}
7976

8077
struct WriteData {
81-
Downloader* downloader; // cppcheck-suppress unusedStructMember
78+
Downloader* downloader;
8279
FILE* file;
8380
};
8481

0 commit comments

Comments
 (0)