diff --git a/.clang-tidy b/.clang-tidy index f167698..8a05294 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,10 +1,16 @@ Checks: > bugprone-*, clang-analyzer-*, + modernize-*, -bugprone-easily-swappable-parameters, -bugprone-narrowing-conversions, -clang-analyzer-core.NonNullParamChecker, -clang-analyzer-security.insecureAPI.strcpy, + -modernize-avoid-c-arrays, + -modernize-macro-to-enum, + -modernize-redundant-void-arg, + -modernize-use-trailing-return-type, + -modernize-use-using, HeaderFilterRegex: '.*' WarningsAsErrors: '*' UseColor: true diff --git a/src/CSFML/Audio/Music.cpp b/src/CSFML/Audio/Music.cpp index de7884f..4e155b4 100644 --- a/src/CSFML/Audio/Music.cpp +++ b/src/CSFML/Audio/Music.cpp @@ -33,7 +33,7 @@ //////////////////////////////////////////////////////////// sfMusic* sfMusic_createFromFile(const char* filename) { - sfMusic* music = new sfMusic; + auto* music = new sfMusic; if (!music->This.openFromFile(filename)) { delete music; @@ -47,7 +47,7 @@ sfMusic* sfMusic_createFromFile(const char* filename) //////////////////////////////////////////////////////////// sfMusic* sfMusic_createFromMemory(const void* data, size_t sizeInBytes) { - sfMusic* music = new sfMusic; + auto* music = new sfMusic; if (!music->This.openFromMemory(data, sizeInBytes)) { delete music; @@ -63,8 +63,8 @@ sfMusic* sfMusic_createFromStream(sfInputStream* stream) { assert(stream); - sfMusic* music = new sfMusic; - music->Stream = CallbackStream(stream); + auto* music = new sfMusic; + music->Stream = CallbackStream(stream); if (!music->This.openFromStream(music->Stream)) { delete music; diff --git a/src/CSFML/Char32.hpp b/src/CSFML/Char32.hpp index 204cc24..a754cc0 100644 --- a/src/CSFML/Char32.hpp +++ b/src/CSFML/Char32.hpp @@ -31,7 +31,7 @@ #include -#include +#include //////////////////////////////////////////////////////////// @@ -49,7 +49,7 @@ static_assert(alignof(sfChar32) == alignof(char32_t)); inline sfChar32* copyToChar32(const sf::String& str) { std::size_t byteCount = sizeof(sfChar32) * str.getSize(); - sfChar32* utf32 = static_cast(malloc(byteCount + sizeof(sfChar32))); + auto* utf32 = static_cast(malloc(byteCount + sizeof(sfChar32))); memcpy(utf32, str.getData(), byteCount); utf32[str.getSize()] = 0; diff --git a/src/CSFML/Graphics/CircleShape.cpp b/src/CSFML/Graphics/CircleShape.cpp index a3bb226..b652f10 100644 --- a/src/CSFML/Graphics/CircleShape.cpp +++ b/src/CSFML/Graphics/CircleShape.cpp @@ -38,8 +38,8 @@ //////////////////////////////////////////////////////////// sfCircleShape* sfCircleShape_create() { - sfCircleShape* shape = new sfCircleShape; - shape->Texture = nullptr; + auto* shape = new sfCircleShape; + shape->Texture = nullptr; return shape; } diff --git a/src/CSFML/Graphics/Color.cpp b/src/CSFML/Graphics/Color.cpp index 124b9fc..95175fe 100644 --- a/src/CSFML/Graphics/Color.cpp +++ b/src/CSFML/Graphics/Color.cpp @@ -66,10 +66,10 @@ sfColor sfColor_fromRGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha //////////////////////////////////////////////////////////// sfColor sfColor_fromInteger(uint32_t color) { - uint8_t red = static_cast((color & 0xff000000) >> 24); - uint8_t green = static_cast((color & 0x00ff0000) >> 16); - uint8_t blue = static_cast((color & 0x0000ff00) >> 8); - uint8_t alpha = static_cast((color & 0x000000ff) >> 0); + auto red = static_cast((color & 0xff000000) >> 24); + auto green = static_cast((color & 0x00ff0000) >> 16); + auto blue = static_cast((color & 0x0000ff00) >> 8); + auto alpha = static_cast((color & 0x000000ff) >> 0); return sfColor_fromRGBA(red, green, blue, alpha); } diff --git a/src/CSFML/Graphics/Font.cpp b/src/CSFML/Graphics/Font.cpp index 1a6a5ba..2f2e27d 100644 --- a/src/CSFML/Graphics/Font.cpp +++ b/src/CSFML/Graphics/Font.cpp @@ -58,7 +58,7 @@ sfFont* sfFont_createFromStream(sfInputStream* stream) { assert(stream); - sfFont* font = new sfFont; + auto* font = new sfFont; font->Stream = CallbackStream(stream); if (!font->This.openFromStream(font->Stream)) { diff --git a/src/CSFML/Graphics/RenderWindow.cpp b/src/CSFML/Graphics/RenderWindow.cpp index cf15102..ee4ee15 100644 --- a/src/CSFML/Graphics/RenderWindow.cpp +++ b/src/CSFML/Graphics/RenderWindow.cpp @@ -59,7 +59,7 @@ sfRenderWindow* sfRenderWindow_create(sfVideoMode mode, const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings(); // Create the window - sfRenderWindow* renderWindow = new sfRenderWindow; + auto* renderWindow = new sfRenderWindow; renderWindow->This.create(convertVideoMode(mode), title, style, static_cast(state), params); renderWindow->DefaultView.This = renderWindow->This.getDefaultView(); renderWindow->CurrentView.This = renderWindow->This.getView(); @@ -79,7 +79,7 @@ sfRenderWindow* sfRenderWindow_createUnicode( const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings(); // Create the window - sfRenderWindow* renderWindow = new sfRenderWindow; + auto* renderWindow = new sfRenderWindow; renderWindow->This.create(convertVideoMode(mode), reinterpret_cast(title), style, @@ -99,7 +99,7 @@ sfRenderWindow* sfRenderWindow_createFromHandle(sfWindowHandle handle, const sfC const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings(); // Create the window - sfRenderWindow* renderWindow = new sfRenderWindow; + auto* renderWindow = new sfRenderWindow; renderWindow->This.create(handle, params); renderWindow->DefaultView.This = renderWindow->This.getDefaultView(); renderWindow->CurrentView.This = renderWindow->This.getView(); diff --git a/src/CSFML/Graphics/Texture.cpp b/src/CSFML/Graphics/Texture.cpp index 40590c6..09d6736 100644 --- a/src/CSFML/Graphics/Texture.cpp +++ b/src/CSFML/Graphics/Texture.cpp @@ -38,7 +38,7 @@ //////////////////////////////////////////////////////////// sfTexture* sfTexture_create(sfVector2u size) { - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; if (!texture->This->resize(convertVector2(size))) { @@ -53,7 +53,7 @@ sfTexture* sfTexture_create(sfVector2u size) //////////////////////////////////////////////////////////// sfTexture* sfTexture_createFromFile(const char* filename, const sfIntRect* area) { - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); @@ -69,7 +69,7 @@ sfTexture* sfTexture_createFromFile(const char* filename, const sfIntRect* area) //////////////////////////////////////////////////////////// sfTexture* sfTexture_createSrgbFromFile(const char* filename, const sfIntRect* area) { - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); @@ -85,7 +85,7 @@ sfTexture* sfTexture_createSrgbFromFile(const char* filename, const sfIntRect* a //////////////////////////////////////////////////////////// sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area) { - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); @@ -101,7 +101,7 @@ sfTexture* sfTexture_createFromMemory(const void* data, size_t sizeInBytes, cons //////////////////////////////////////////////////////////// sfTexture* sfTexture_createSrgbFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area) { - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); @@ -120,7 +120,7 @@ sfTexture* sfTexture_createFromStream(sfInputStream* stream, const sfIntRect* ar { assert(stream); - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); @@ -139,7 +139,7 @@ sfTexture* sfTexture_createSrgbFromStream(sfInputStream* stream, const sfIntRect { assert(stream); - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); @@ -159,7 +159,7 @@ sfTexture* sfTexture_createFromImage(const sfImage* image, const sfIntRect* area { assert(image); - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); @@ -177,7 +177,7 @@ sfTexture* sfTexture_createSrgbFromImage(const sfImage* image, const sfIntRect* { assert(image); - sfTexture* texture = new sfTexture; + auto* texture = new sfTexture; const sf::IntRect rect = area ? convertRect(*area) : sf::IntRect(); diff --git a/src/CSFML/Graphics/Transformable.cpp b/src/CSFML/Graphics/Transformable.cpp index c6d2b23..e092026 100644 --- a/src/CSFML/Graphics/Transformable.cpp +++ b/src/CSFML/Graphics/Transformable.cpp @@ -34,7 +34,7 @@ //////////////////////////////////////////////////////////// sfTransformable* sfTransformable_create() { - sfTransformable* transformable = new sfTransformable; + auto* transformable = new sfTransformable; return transformable; } diff --git a/src/CSFML/Graphics/VertexBuffer.cpp b/src/CSFML/Graphics/VertexBuffer.cpp index 592137b..2589bda 100644 --- a/src/CSFML/Graphics/VertexBuffer.cpp +++ b/src/CSFML/Graphics/VertexBuffer.cpp @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////// sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType type, sfVertexBufferUsage usage) { - sfVertexBuffer* buffer = new sfVertexBuffer; + auto* buffer = new sfVertexBuffer; if (!buffer->This.create(vertexCount)) { @@ -52,8 +52,8 @@ sfVertexBuffer* sfVertexBuffer_create(unsigned int vertexCount, sfPrimitiveType //////////////////////////////////////////////////////////// sfVertexBuffer* sfVertexBuffer_copy(const sfVertexBuffer* vertexBuffer) { - sfVertexBuffer* buffer = new sfVertexBuffer; - buffer->This = sf::VertexBuffer(vertexBuffer->This); + auto* buffer = new sfVertexBuffer; + buffer->This = sf::VertexBuffer(vertexBuffer->This); return buffer; } diff --git a/src/CSFML/Network/Ftp.cpp b/src/CSFML/Network/Ftp.cpp index 35ae9c0..5dd0791 100644 --- a/src/CSFML/Network/Ftp.cpp +++ b/src/CSFML/Network/Ftp.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include //////////////////////////////////////////////////////////// diff --git a/src/CSFML/Network/FtpStruct.hpp b/src/CSFML/Network/FtpStruct.hpp index cf8c6ce..ce654ad 100644 --- a/src/CSFML/Network/FtpStruct.hpp +++ b/src/CSFML/Network/FtpStruct.hpp @@ -29,6 +29,7 @@ //////////////////////////////////////////////////////////// #include +#include #include @@ -46,7 +47,7 @@ struct sfFtp //////////////////////////////////////////////////////////// struct sfFtpResponse { - sfFtpResponse(const sf::Ftp::Response& Response) : This(Response) + sfFtpResponse(sf::Ftp::Response Response) : This(std::move(Response)) { } @@ -59,7 +60,7 @@ struct sfFtpResponse //////////////////////////////////////////////////////////// struct sfFtpDirectoryResponse { - sfFtpDirectoryResponse(const sf::Ftp::DirectoryResponse& Response) : This(Response) + sfFtpDirectoryResponse(sf::Ftp::DirectoryResponse Response) : This(std::move(Response)) { } @@ -72,7 +73,7 @@ struct sfFtpDirectoryResponse //////////////////////////////////////////////////////////// struct sfFtpListingResponse { - sfFtpListingResponse(const sf::Ftp::ListingResponse& Response) : This(Response) + sfFtpListingResponse(sf::Ftp::ListingResponse Response) : This(std::move(Response)) { } diff --git a/src/CSFML/Network/Http.cpp b/src/CSFML/Network/Http.cpp index 8ad0060..17d0ac0 100644 --- a/src/CSFML/Network/Http.cpp +++ b/src/CSFML/Network/Http.cpp @@ -162,8 +162,8 @@ sfHttpResponse* sfHttp_sendRequest(sfHttp* http, const sfHttpRequest* request, s assert(http); assert(request); - sfHttpResponse* response = new sfHttpResponse; - response->This = http->This.sendRequest(request->This, sf::microseconds(timeout.microseconds)); + auto* response = new sfHttpResponse; + response->This = http->This.sendRequest(request->This, sf::microseconds(timeout.microseconds)); return response; } diff --git a/src/CSFML/Network/IpAddress.cpp b/src/CSFML/Network/IpAddress.cpp index 90f3eed..b36077e 100644 --- a/src/CSFML/Network/IpAddress.cpp +++ b/src/CSFML/Network/IpAddress.cpp @@ -29,7 +29,7 @@ #include -#include +#include namespace diff --git a/src/CSFML/Network/TcpListener.cpp b/src/CSFML/Network/TcpListener.cpp index e99499a..2e1e370 100644 --- a/src/CSFML/Network/TcpListener.cpp +++ b/src/CSFML/Network/TcpListener.cpp @@ -90,8 +90,8 @@ sfSocketStatus sfTcpListener_accept(sfTcpListener* listener, sfTcpSocket** conne assert(listener); assert(connected); - *connected = new sfTcpSocket; - sfSocketStatus status = static_cast(listener->This.accept((*connected)->This)); + *connected = new sfTcpSocket; + auto status = static_cast(listener->This.accept((*connected)->This)); if (status != sfSocketDone) { diff --git a/src/CSFML/Network/TcpSocket.cpp b/src/CSFML/Network/TcpSocket.cpp index 422381d..79d3091 100644 --- a/src/CSFML/Network/TcpSocket.cpp +++ b/src/CSFML/Network/TcpSocket.cpp @@ -31,7 +31,7 @@ #include -#include +#include //////////////////////////////////////////////////////////// diff --git a/src/CSFML/Network/UdpSocket.cpp b/src/CSFML/Network/UdpSocket.cpp index bde46f7..dce008c 100644 --- a/src/CSFML/Network/UdpSocket.cpp +++ b/src/CSFML/Network/UdpSocket.cpp @@ -31,7 +31,7 @@ #include -#include +#include //////////////////////////////////////////////////////////// diff --git a/src/CSFML/System/Alloc.cpp b/src/CSFML/System/Alloc.cpp index a59dedc..83adacc 100644 --- a/src/CSFML/System/Alloc.cpp +++ b/src/CSFML/System/Alloc.cpp @@ -27,7 +27,7 @@ //////////////////////////////////////////////////////////// #include -#include +#include //////////////////////////////////////////////////////////// diff --git a/src/CSFML/Window/Keyboard.cpp b/src/CSFML/Window/Keyboard.cpp index acbb246..93bddfa 100644 --- a/src/CSFML/Window/Keyboard.cpp +++ b/src/CSFML/Window/Keyboard.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include //////////////////////////////////////////////////////////// diff --git a/src/CSFML/Window/Vulkan.cpp b/src/CSFML/Window/Vulkan.cpp index feb0467..6a7ca8c 100644 --- a/src/CSFML/Window/Vulkan.cpp +++ b/src/CSFML/Window/Vulkan.cpp @@ -31,8 +31,8 @@ #include -#include -#include +#include +#include //////////////////////////////////////////////////////////// diff --git a/src/CSFML/Window/Window.cpp b/src/CSFML/Window/Window.cpp index f0d61ed..7532cb7 100644 --- a/src/CSFML/Window/Window.cpp +++ b/src/CSFML/Window/Window.cpp @@ -41,7 +41,7 @@ sfWindow* sfWindow_create(sfVideoMode mode, const char* title, uint32_t style, s const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings(); // Create the window - sfWindow* window = new sfWindow; + auto* window = new sfWindow; window->This.create(convertVideoMode(mode), title, style, static_cast(state), params); return window; @@ -58,7 +58,7 @@ sfWindow* sfWindow_createUnicode(sfVideoMode mode, const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings(); // Create the window - sfWindow* window = new sfWindow; + auto* window = new sfWindow; window->This.create(convertVideoMode(mode), reinterpret_cast(title), style, @@ -76,7 +76,7 @@ sfWindow* sfWindow_createFromHandle(sfWindowHandle handle, const sfContextSettin const sf::ContextSettings params = settings ? convertContextSettings(*settings) : sf::ContextSettings(); // Create the window - sfWindow* window = new sfWindow; + auto* window = new sfWindow; window->This.create(handle, params); return window; diff --git a/src/CSFML/Window/WindowBase.cpp b/src/CSFML/Window/WindowBase.cpp index 86dca49..00db758 100644 --- a/src/CSFML/Window/WindowBase.cpp +++ b/src/CSFML/Window/WindowBase.cpp @@ -39,7 +39,7 @@ sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t style) { // Create the window - sfWindowBase* windowBase = new sfWindowBase; + auto* windowBase = new sfWindowBase; windowBase->This.create(convertVideoMode(mode), title, style); return windowBase; @@ -50,7 +50,7 @@ sfWindowBase* sfWindowBase_create(sfVideoMode mode, const char* title, uint32_t sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfChar32* title, uint32_t style) { // Create the window - sfWindowBase* windowBase = new sfWindowBase; + auto* windowBase = new sfWindowBase; windowBase->This.create(convertVideoMode(mode), reinterpret_cast(title), style); return windowBase; @@ -61,7 +61,7 @@ sfWindowBase* sfWindowBase_createUnicode(sfVideoMode mode, const sfChar32* title sfWindowBase* sfWindowBase_createFromHandle(sfWindowHandle handle) { // Create the window - sfWindowBase* windowBase = new sfWindowBase; + auto* windowBase = new sfWindowBase; windowBase->This.create(handle); return windowBase;