Add clang-tidy cppcoreguidelines-* checks

This commit is contained in:
Chris Thrasher committed 2024-09-03 12:15:01 -06:00
1 parent cc1b6f0c45
commit 4d23a89918
12 files changed
+65 -58

No files matched your search

+15
View File
@@ -1,11 +1,26 @@
Checks: > Checks: >
bugprone-*, bugprone-*,
clang-analyzer-*, clang-analyzer-*,
cppcoreguidelines-*,
modernize-*, modernize-*,
-bugprone-easily-swappable-parameters, -bugprone-easily-swappable-parameters,
-bugprone-narrowing-conversions, -bugprone-narrowing-conversions,
-clang-analyzer-core.NonNullParamChecker, -clang-analyzer-core.NonNullParamChecker,
-clang-analyzer-security.insecureAPI.strcpy, -clang-analyzer-security.insecureAPI.strcpy,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-special-member-functions,
-modernize-avoid-c-arrays, -modernize-avoid-c-arrays,
-modernize-macro-to-enum, -modernize-macro-to-enum,
-modernize-redundant-void-arg, -modernize-redundant-void-arg,
+9 -9
View File
@@ -43,15 +43,15 @@ typedef struct
} sfColor; } sfColor;
CSFML_GRAPHICS_API sfColor sfBlack; ///< Black predefined color CSFML_GRAPHICS_API const sfColor sfBlack; ///< Black predefined color
CSFML_GRAPHICS_API sfColor sfWhite; ///< White predefined color CSFML_GRAPHICS_API const sfColor sfWhite; ///< White predefined color
CSFML_GRAPHICS_API sfColor sfRed; ///< Red predefined color CSFML_GRAPHICS_API const sfColor sfRed; ///< Red predefined color
CSFML_GRAPHICS_API sfColor sfGreen; ///< Green predefined color CSFML_GRAPHICS_API const sfColor sfGreen; ///< Green predefined color
CSFML_GRAPHICS_API sfColor sfBlue; ///< Blue predefined color CSFML_GRAPHICS_API const sfColor sfBlue; ///< Blue predefined color
CSFML_GRAPHICS_API sfColor sfYellow; ///< Yellow predefined color CSFML_GRAPHICS_API const sfColor sfYellow; ///< Yellow predefined color
CSFML_GRAPHICS_API sfColor sfMagenta; ///< Magenta predefined color CSFML_GRAPHICS_API const sfColor sfMagenta; ///< Magenta predefined color
CSFML_GRAPHICS_API sfColor sfCyan; ///< Cyan predefined color CSFML_GRAPHICS_API const sfColor sfCyan; ///< Cyan predefined color
CSFML_GRAPHICS_API sfColor sfTransparent; ///< Transparent (black) predefined color CSFML_GRAPHICS_API const sfColor sfTransparent; ///< Transparent (black) predefined color
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+1 -1
View File
@@ -136,5 +136,5 @@ private:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfInputStream myStream; ///< The source CSFML input stream sfInputStream myStream{}; ///< The source CSFML input stream
}; };
+3 -3
View File
@@ -39,7 +39,7 @@
struct sfCircleShape struct sfCircleShape
{ {
sf::CircleShape This; sf::CircleShape This;
const sfTexture* Texture; const sfTexture* Texture{};
mutable sfTransform Transform; mutable sfTransform Transform{};
mutable sfTransform InverseTransform; mutable sfTransform InverseTransform{};
}; };
+9 -9
View File
@@ -31,15 +31,15 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
sfColor sfBlack = sfColor_fromRGB(0, 0, 0); const sfColor sfBlack = sfColor_fromRGB(0, 0, 0);
sfColor sfWhite = sfColor_fromRGB(255, 255, 255); const sfColor sfWhite = sfColor_fromRGB(255, 255, 255);
sfColor sfRed = sfColor_fromRGB(255, 0, 0); const sfColor sfRed = sfColor_fromRGB(255, 0, 0);
sfColor sfGreen = sfColor_fromRGB(0, 255, 0); const sfColor sfGreen = sfColor_fromRGB(0, 255, 0);
sfColor sfBlue = sfColor_fromRGB(0, 0, 255); const sfColor sfBlue = sfColor_fromRGB(0, 0, 255);
sfColor sfYellow = sfColor_fromRGB(255, 255, 0); const sfColor sfYellow = sfColor_fromRGB(255, 255, 0);
sfColor sfMagenta = sfColor_fromRGB(255, 0, 255); const sfColor sfMagenta = sfColor_fromRGB(255, 0, 255);
sfColor sfCyan = sfColor_fromRGB(0, 255, 255); const sfColor sfCyan = sfColor_fromRGB(0, 255, 255);
sfColor sfTransparent = sfColor_fromRGBA(0, 0, 0, 0); const sfColor sfTransparent = sfColor_fromRGBA(0, 0, 0, 0);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
+3 -3
View File
@@ -39,7 +39,7 @@
struct sfConvexShape struct sfConvexShape
{ {
sf::ConvexShape This; sf::ConvexShape This;
const sfTexture* Texture; const sfTexture* Texture{};
mutable sfTransform Transform; mutable sfTransform Transform{};
mutable sfTransform InverseTransform; mutable sfTransform InverseTransform{};
}; };
+3 -3
View File
@@ -39,7 +39,7 @@
struct sfRectangleShape struct sfRectangleShape
{ {
sf::RectangleShape This; sf::RectangleShape This;
const sfTexture* Texture; const sfTexture* Texture{};
mutable sfTransform Transform; mutable sfTransform Transform{};
mutable sfTransform InverseTransform; mutable sfTransform InverseTransform{};
}; };
+3 -3
View File
@@ -79,7 +79,7 @@ struct sfShape
} }
sfShapeImpl This; sfShapeImpl This;
const sfTexture* Texture; const sfTexture* Texture{};
mutable sfTransform Transform; mutable sfTransform Transform{};
mutable sfTransform InverseTransform; mutable sfTransform InverseTransform{};
}; };
+6 -14
View File
@@ -35,22 +35,14 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct sfTexture struct sfTexture
{ {
sfTexture() sfTexture() = default;
sfTexture(sf::Texture* texture) : This(texture), OwnInstance(false)
{ {
This = new sf::Texture;
OwnInstance = true;
} }
sfTexture(sf::Texture* texture) sfTexture(const sfTexture& texture) : This(texture.This ? new sf::Texture(*texture.This) : nullptr)
{ {
This = texture;
OwnInstance = false;
}
sfTexture(const sfTexture& texture)
{
This = texture.This ? new sf::Texture(*texture.This) : nullptr;
OwnInstance = true;
} }
~sfTexture() ~sfTexture()
@@ -59,6 +51,6 @@ struct sfTexture
delete This; delete This;
} }
sf::Texture* This; sf::Texture* This{new sf::Texture};
bool OwnInstance; bool OwnInstance{true};
}; };
+2 -2
View File
@@ -38,6 +38,6 @@
struct sfTransformable struct sfTransformable
{ {
sf::Transformable This; sf::Transformable This;
mutable sfTransform Transform; mutable sfTransform Transform{};
mutable sfTransform InverseTransform; mutable sfTransform InverseTransform{};
}; };
+8 -8
View File
@@ -117,56 +117,56 @@ bool sfPacket_readBool(sfPacket* packet)
int8_t sfPacket_readInt8(sfPacket* packet) int8_t sfPacket_readInt8(sfPacket* packet)
{ {
assert(packet); assert(packet);
int8_t value; int8_t value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
uint8_t sfPacket_readUint8(sfPacket* packet) uint8_t sfPacket_readUint8(sfPacket* packet)
{ {
assert(packet); assert(packet);
uint8_t value; uint8_t value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
int16_t sfPacket_readInt16(sfPacket* packet) int16_t sfPacket_readInt16(sfPacket* packet)
{ {
assert(packet); assert(packet);
int16_t value; int16_t value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
uint16_t sfPacket_readUint16(sfPacket* packet) uint16_t sfPacket_readUint16(sfPacket* packet)
{ {
assert(packet); assert(packet);
uint16_t value; uint16_t value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
int32_t sfPacket_readInt32(sfPacket* packet) int32_t sfPacket_readInt32(sfPacket* packet)
{ {
assert(packet); assert(packet);
int32_t value; int32_t value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
uint32_t sfPacket_readUint32(sfPacket* packet) uint32_t sfPacket_readUint32(sfPacket* packet)
{ {
assert(packet); assert(packet);
uint32_t value; uint32_t value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
float sfPacket_readFloat(sfPacket* packet) float sfPacket_readFloat(sfPacket* packet)
{ {
assert(packet); assert(packet);
float value; float value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
double sfPacket_readDouble(sfPacket* packet) double sfPacket_readDouble(sfPacket* packet)
{ {
assert(packet); assert(packet);
double value; double value = 0;
packet->This >> value; packet->This >> value;
return value; return value;
} }
+3 -3
View File
@@ -123,8 +123,8 @@ sfSocketStatus sfUdpSocket_receive(sfUdpSocket* socket,
assert(socket); assert(socket);
std::optional<sf::IpAddress> address; std::optional<sf::IpAddress> address;
unsigned short port; unsigned short port = 0;
std::size_t sizeReceived; std::size_t sizeReceived = 0;
sf::Socket::Status status = socket->This.receive(data, size, sizeReceived, address, port); sf::Socket::Status status = socket->This.receive(data, size, sizeReceived, address, port);
if (status != sf::Socket::Status::Done) if (status != sf::Socket::Status::Done)
@@ -175,7 +175,7 @@ sfSocketStatus sfUdpSocket_receivePacket(sfUdpSocket* socket, sfPacket* packet,
assert(packet); assert(packet);
std::optional<sf::IpAddress> address; std::optional<sf::IpAddress> address;
unsigned short port; unsigned short port = 0;
sf::Socket::Status status = socket->This.receive(packet->This, address, port); sf::Socket::Status status = socket->This.receive(packet->This, address, port);
if (status != sf::Socket::Status::Done) if (status != sf::Socket::Status::Done)