Skip to content

Commit

Permalink
fix MISRA 15.5 in binary.hpp and use .hpp instead of .h and fix Rule …
Browse files Browse the repository at this point in the history
…3.1 form link using // and more
  • Loading branch information
noisecode3 committed Dec 14, 2024
1 parent 0f8a570 commit bc72e8b
Show file tree
Hide file tree
Showing 19 changed files with 201 additions and 197 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ endif()
add_subdirectory(libs/miniz)

set(SOURCES_TESTS
test/test.h
test/test.hpp
)

set(SOURCES_MC
src/main.cpp
src/binary.h
src/gameTree.h
src/staticData.h
src/Network.h
src/binary.hpp
src/gameTree.hpp
src/staticData.hpp
src/Network.hpp
src/Network.cpp
src/Controller.h
src/Controller.hpp
src/Controller.cpp
src/FileManager.h
src/FileManager.hpp
src/FileManager.cpp
src/Model.h
src/Model.hpp
src/Model.cpp
src/Data.h
src/Data.hpp
src/Data.cpp
)

set(SOURCES_VIEW
src/TombRaiderLinuxLauncher.h
src/TombRaiderLinuxLauncher.hpp
src/TombRaiderLinuxLauncher.cpp
src/TombRaiderLinuxLauncher.ui
src/resources.qrc
Expand Down
5 changes: 1 addition & 4 deletions src/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Controller.h"
#include "Controller.hpp"
#include <QDebug>

Controller::Controller(QObject *parent)
Expand Down
11 changes: 4 additions & 7 deletions src/Controller.h → src/Controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_CONTROLLER_H_
#define SRC_CONTROLLER_H_
#ifndef SRC_CONTROLLER_HPP_
#define SRC_CONTROLLER_HPP_
#include <QObject>
#include <QThread>
#include "Model.h"
#include "Model.hpp"

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

#endif // SRC_CONTROLLER_H_
#endif // SRC_CONTROLLER_HPP_
5 changes: 1 addition & 4 deletions src/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Data.h"
#include "Data.hpp"

QVector<ListItemData> Data::getListItems() {
QVector<ListItemData> items;
Expand Down
9 changes: 3 additions & 6 deletions src/Data.h → src/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_DATA_H_
#define SRC_DATA_H_
#ifndef SRC_DATA_HPP_
#define SRC_DATA_HPP_

#include <QObject>
#include <QSqlDatabase>
Expand Down Expand Up @@ -181,4 +178,4 @@ class Data : public QObject {
Q_DISABLE_COPY(Data)
};

#endif // SRC_DATA_H_
#endif // SRC_DATA_HPP_
22 changes: 13 additions & 9 deletions src/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "FileManager.h"
#include "FileManager.hpp"
#include <QFile>
#include <QIODevice>
#include <QDir>
Expand All @@ -23,7 +20,7 @@
#include <QtCore>
#include <QByteArray>
#include <QDataStream>
#include "gameTree.h"
#include "gameTree.hpp"

bool FileManager::setUpCamp(const QString& levelDir, const QString& gameDir) {
QDir levelDirPath(levelDir);
Expand Down Expand Up @@ -52,19 +49,26 @@ const QString FileManager::calculateMD5(const QString& file, bool lookGameDir) {
gameDir_m.absolutePath() + QDir::separator()+file :
levelDir_m.absolutePath() + QDir::separator()+file;

QFileInfo fileInfo(path);

if (fileInfo.exists() && !fileInfo.isFile()) {
qDebug() << "Error: The path is not a regular file." << path;
return"";
}

QFile f(path);
if (!f.open(QIODevice::ReadOnly)) {
if (!f.open(QIODevice::ReadOnly)) { // flawfinder: ignore
qDebug() << "Error opening file for reading: " << f.errorString();
return "";
}

QCryptographicHash md5(QCryptographicHash::Md5);

char buffer[1024];
std::array<char, 1024> buffer;
qint64 bytesRead;

while ((bytesRead = f.read(buffer, sizeof(buffer))) > 0) {
md5.addData(buffer, static_cast<int>(bytesRead));
while ((bytesRead = f.read(buffer.data(), buffer.size())) > 0) {
md5.addData(buffer.data(), static_cast<int>(bytesRead));
}

f.close();
Expand Down
9 changes: 3 additions & 6 deletions src/FileManager.h → src/FileManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_FILEMANAGER_H_
#define SRC_FILEMANAGER_H_
#ifndef SRC_FILEMANAGER_HPP_
#define SRC_FILEMANAGER_HPP_

#include <QString>
#include <QObject>
Expand Down Expand Up @@ -72,4 +69,4 @@ class FileManager : public QObject {
QDir gameDir_m;
Q_DISABLE_COPY(FileManager)
};
#endif // SRC_FILEMANAGER_H_
#endif // SRC_FILEMANAGER_HPP_
5 changes: 1 addition & 4 deletions src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Model.h"
#include "Model.hpp"

// Those lambda should be in another header file
Model::Model(QObject *parent) : QObject(parent), checkCommonFilesIndex_m(1) {
Expand Down
22 changes: 9 additions & 13 deletions src/Model.h → src/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_MODEL_H_
#define SRC_MODEL_H_
#ifndef SRC_MODEL_HPP_
#define SRC_MODEL_HPP_

#include <QObject>
#include <QMap>
#include <QDebug>
#include <QtCore>
#include <assert.h>
#include "Data.h"
#include "FileManager.h"
#include "Network.h"
#include <cassert>
#include "Data.hpp"
#include "FileManager.hpp"
#include "Network.hpp"

class InstructionManager : public QObject {
Q_OBJECT
Expand Down Expand Up @@ -53,11 +50,10 @@ class Model : public QObject {
Q_OBJECT

public:
static Model& getInstance()
{
static Model& getInstance() {
static Model instance;
return instance;
};
}
void checkCommonFiles();
int checkGameDirectory(int id);
int checkLevelDirectory(int id);
Expand Down Expand Up @@ -90,4 +86,4 @@ class Model : public QObject {
Q_DISABLE_COPY(Model)
};

#endif // SRC_MODEL_H_
#endif // SRC_MODEL_HPP_
7 changes: 2 additions & 5 deletions src/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Network.h"
#include "Network.hpp"
#include <curl/curl.h>
#include <cstdio>
#include <iostream>
Expand Down Expand Up @@ -78,7 +75,7 @@ std::string get_ssl_certificate(const std::string& host) {
}

struct WriteData {
Downloader* downloader; // cppcheck-suppress unusedStructMember
Downloader* downloader;
FILE* file;
};

Expand Down
9 changes: 3 additions & 6 deletions src/Network.h → src/Network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_NETWORK_H_
#define SRC_NETWORK_H_
#ifndef SRC_NETWORK_HPP_
#define SRC_NETWORK_HPP_

#include <QObject>
#include <QUrl>
Expand Down Expand Up @@ -74,4 +71,4 @@ class Downloader : public QObject {
Q_DISABLE_COPY(Downloader)
};

#endif // SRC_NETWORK_H_
#endif // SRC_NETWORK_HPP_
10 changes: 3 additions & 7 deletions src/TombRaiderLinuxLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#include "TombRaiderLinuxLauncher.h"
#include "ui_TombRaiderLinuxLauncher.h"
#include <algorithm>
#include "staticData.h"
#include "TombRaiderLinuxLauncher.hpp"
#include "ui_TombRaiderLinuxLauncher.h"
#include "staticData.hpp"

TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
:QMainWindow(parent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SRC_TOMBRAIDERLINUXLAUNCHER_H_
#define SRC_TOMBRAIDERLINUXLAUNCHER_H_
#ifndef SRC_TOMBRAIDERLINUXLAUNCHER_HPP_
#define SRC_TOMBRAIDERLINUXLAUNCHER_HPP_

#include <QMainWindow>
#include <QSettings>
Expand All @@ -29,7 +26,7 @@
#include <QVector>
#include <QString>

#include "Controller.h"
#include "Controller.hpp"

QT_BEGIN_NAMESPACE
namespace Ui { class TombRaiderLinuxLauncher; }
Expand Down Expand Up @@ -126,4 +123,4 @@ class TombRaiderLinuxLauncher : public QMainWindow {
// cppcheck-suppress unusedStructMember
Ui::TombRaiderLinuxLauncher *ui;
};
#endif // SRC_TOMBRAIDERLINUXLAUNCHER_H_
#endif // SRC_TOMBRAIDERLINUXLAUNCHER_HPP_
Loading

0 comments on commit bc72e8b

Please sign in to comment.