From 6ef8e487cccda366061fcbdc9e54a6017cf01c5b Mon Sep 17 00:00:00 2001 From: Norm Evangelista Date: Wed, 18 Jan 2023 08:27:17 -0800 Subject: [PATCH] Added readability-qualified-auto, -redundant-access-specifiers Fixed clang-format escapes Fixed OSX clang-tidy issues Collapsed extraneous lines Fixed clang-format escape --- .clang-tidy | 9 +++++++++ examples/shader/Effect.hpp | 1 - include/SFML/Graphics/Font.hpp | 1 - include/SFML/Graphics/Shader.hpp | 1 - include/SFML/Graphics/Shape.hpp | 1 - include/SFML/Graphics/Texture.hpp | 1 - include/SFML/Graphics/VertexArray.hpp | 1 - include/SFML/Graphics/VertexBuffer.hpp | 1 - include/SFML/Network/Packet.hpp | 1 - include/SFML/Network/Socket.hpp | 1 - include/SFML/System/Angle.hpp | 1 - include/SFML/System/Time.hpp | 1 - include/SFML/Window/Cursor.hpp | 2 -- src/SFML/Audio/SoundFileReaderFlac.hpp | 2 -- src/SFML/Audio/SoundFileReaderMp3.hpp | 1 - src/SFML/Audio/SoundFileReaderOgg.hpp | 1 - src/SFML/Audio/SoundFileReaderWav.hpp | 1 - src/SFML/Audio/SoundFileWriterFlac.hpp | 1 - src/SFML/Audio/SoundFileWriterOgg.hpp | 1 - src/SFML/Audio/SoundFileWriterWav.hpp | 1 - src/SFML/Graphics/Font.cpp | 18 +++++++++--------- src/SFML/Window/GlContext.hpp | 1 - src/SFML/Window/OSX/HIDInputManager.hpp | 2 -- src/SFML/Window/OSX/HIDJoystickManager.hpp | 3 --- src/SFML/Window/OSX/WindowImplCocoa.hpp | 1 - src/SFML/Window/WindowImpl.hpp | 1 - test/System/Err.test.cpp | 2 +- 27 files changed, 19 insertions(+), 39 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3086ff5a..ec566042 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,6 +6,8 @@ Checks: > readability-container-size-empty, readability-identifier-naming, readability-isolate-declaration, + readability-qualified-auto, + readability-redundant-access-specifiers, -clang-analyzer-core.NonNullParamChecker, -clang-analyzer-core.NullDereference, -clang-analyzer-nullability.NullablePassedToNonnull, @@ -22,6 +24,13 @@ Checks: > -modernize-use-auto, -modernize-use-nodiscard, -modernize-use-trailing-return-type, + -readability-braces-around-statements, + -readability-container-contains, + -readability-function-cognitive-complexity, + -readability-magic-numbers, + -readability-make-member-function-const, + -readability-implicit-bool-conversion + CheckOptions: - { key: readability-identifier-naming.ClassCase, value: CamelCase } - { key: readability-identifier-naming.FunctionCase, value: camelBack } diff --git a/examples/shader/Effect.hpp b/examples/shader/Effect.hpp index fd63b74b..41c8fc1e 100644 --- a/examples/shader/Effect.hpp +++ b/examples/shader/Effect.hpp @@ -70,7 +70,6 @@ private: virtual void onUpdate(float time, float x, float y) = 0; virtual void onDraw(sf::RenderTarget& target, const sf::RenderStates& states) const = 0; -private: std::string m_name; bool m_isLoaded{}; diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index e21e3ab7..aa1bb396 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -66,7 +66,6 @@ public: std::string family; //!< The font family }; -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/include/SFML/Graphics/Shader.hpp b/include/SFML/Graphics/Shader.hpp index aee8b83c..09d7f380 100644 --- a/include/SFML/Graphics/Shader.hpp +++ b/include/SFML/Graphics/Shader.hpp @@ -84,7 +84,6 @@ public: // NOLINTNEXTLINE(readability-identifier-naming) static CurrentTextureType CurrentTexture; -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/include/SFML/Graphics/Shape.hpp b/include/SFML/Graphics/Shape.hpp index b36a6134..51686aa7 100644 --- a/include/SFML/Graphics/Shape.hpp +++ b/include/SFML/Graphics/Shape.hpp @@ -299,7 +299,6 @@ private: //////////////////////////////////////////////////////////// void updateOutlineColors(); -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index a8ba0789..ea387875 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -61,7 +61,6 @@ public: Pixels //!< Texture coordinates in range [0 .. size] }; -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/include/SFML/Graphics/VertexArray.hpp b/include/SFML/Graphics/VertexArray.hpp index cd8425d4..8af2b6ed 100644 --- a/include/SFML/Graphics/VertexArray.hpp +++ b/include/SFML/Graphics/VertexArray.hpp @@ -180,7 +180,6 @@ private: //////////////////////////////////////////////////////////// void draw(RenderTarget& target, const RenderStates& states) const override; -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/include/SFML/Graphics/VertexBuffer.hpp b/include/SFML/Graphics/VertexBuffer.hpp index c08f63cc..0e845981 100644 --- a/include/SFML/Graphics/VertexBuffer.hpp +++ b/include/SFML/Graphics/VertexBuffer.hpp @@ -329,7 +329,6 @@ private: //////////////////////////////////////////////////////////// void draw(RenderTarget& target, const RenderStates& states) const override; -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp index 1d854e48..e37d0f62 100644 --- a/include/SFML/Network/Packet.hpp +++ b/include/SFML/Network/Packet.hpp @@ -162,7 +162,6 @@ public: //////////////////////////////////////////////////////////// bool endOfPacket() const; -public: //////////////////////////////////////////////////////////// /// \brief Test the validity of the packet, for reading /// diff --git a/include/SFML/Network/Socket.hpp b/include/SFML/Network/Socket.hpp index c456a275..d0edfd25 100644 --- a/include/SFML/Network/Socket.hpp +++ b/include/SFML/Network/Socket.hpp @@ -67,7 +67,6 @@ public: AnyPort = 0 //!< Special value that tells the system to pick any available port }; -public: //////////////////////////////////////////////////////////// /// \brief Destructor /// diff --git a/include/SFML/System/Angle.hpp b/include/SFML/System/Angle.hpp index b483daab..dff4a1f2 100644 --- a/include/SFML/System/Angle.hpp +++ b/include/SFML/System/Angle.hpp @@ -156,7 +156,6 @@ private: //////////////////////////////////////////////////////////// constexpr explicit Angle(float degrees); -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/include/SFML/System/Time.hpp b/include/SFML/System/Time.hpp index 849d4fb9..bce33f4a 100644 --- a/include/SFML/System/Time.hpp +++ b/include/SFML/System/Time.hpp @@ -115,7 +115,6 @@ private: friend constexpr Time milliseconds(std::int32_t); friend constexpr Time microseconds(std::int64_t); -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/Cursor.hpp b/include/SFML/Window/Cursor.hpp index 64519967..5f540b04 100644 --- a/include/SFML/Window/Cursor.hpp +++ b/include/SFML/Window/Cursor.hpp @@ -109,7 +109,6 @@ public: NotAllowed //!< Action not allowed cursor }; -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// @@ -204,7 +203,6 @@ private: //////////////////////////////////////////////////////////// const priv::CursorImpl& getImpl() const; -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/src/SFML/Audio/SoundFileReaderFlac.hpp b/src/SFML/Audio/SoundFileReaderFlac.hpp index 1219118d..6951f86d 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.hpp +++ b/src/SFML/Audio/SoundFileReaderFlac.hpp @@ -52,7 +52,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static bool check(InputStream& stream); -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// @@ -100,7 +99,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] std::uint64_t read(std::int16_t* samples, std::uint64_t maxCount) override; -public: //////////////////////////////////////////////////////////// /// \brief Hold the state that is passed to the decoder callbacks /// diff --git a/src/SFML/Audio/SoundFileReaderMp3.hpp b/src/SFML/Audio/SoundFileReaderMp3.hpp index 971a2ecf..e81d21ae 100644 --- a/src/SFML/Audio/SoundFileReaderMp3.hpp +++ b/src/SFML/Audio/SoundFileReaderMp3.hpp @@ -70,7 +70,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static bool check(InputStream& stream); -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/src/SFML/Audio/SoundFileReaderOgg.hpp b/src/SFML/Audio/SoundFileReaderOgg.hpp index cfe1e48e..b8f5b22d 100644 --- a/src/SFML/Audio/SoundFileReaderOgg.hpp +++ b/src/SFML/Audio/SoundFileReaderOgg.hpp @@ -51,7 +51,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static bool check(InputStream& stream); -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/src/SFML/Audio/SoundFileReaderWav.hpp b/src/SFML/Audio/SoundFileReaderWav.hpp index 2c443e83..8c0233ec 100644 --- a/src/SFML/Audio/SoundFileReaderWav.hpp +++ b/src/SFML/Audio/SoundFileReaderWav.hpp @@ -49,7 +49,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static bool check(InputStream& stream); -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/src/SFML/Audio/SoundFileWriterFlac.hpp b/src/SFML/Audio/SoundFileWriterFlac.hpp index cddae737..cdfc9146 100644 --- a/src/SFML/Audio/SoundFileWriterFlac.hpp +++ b/src/SFML/Audio/SoundFileWriterFlac.hpp @@ -53,7 +53,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static bool check(const std::filesystem::path& filename); -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/src/SFML/Audio/SoundFileWriterOgg.hpp b/src/SFML/Audio/SoundFileWriterOgg.hpp index db57ecc4..99b5c85f 100644 --- a/src/SFML/Audio/SoundFileWriterOgg.hpp +++ b/src/SFML/Audio/SoundFileWriterOgg.hpp @@ -54,7 +54,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static bool check(const std::filesystem::path& filename); -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/src/SFML/Audio/SoundFileWriterWav.hpp b/src/SFML/Audio/SoundFileWriterWav.hpp index 32d020e8..160792c6 100644 --- a/src/SFML/Audio/SoundFileWriterWav.hpp +++ b/src/SFML/Audio/SoundFileWriterWav.hpp @@ -52,7 +52,6 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static bool check(const std::filesystem::path& filename); -public: //////////////////////////////////////////////////////////// /// \brief Default constructor /// diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index e8051772..de5742ed 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -388,7 +388,7 @@ float Font::getKerning(std::uint32_t first, std::uint32_t second, unsigned int c if (first == 0 || second == 0) return 0.f; - auto face = m_fontHandles ? m_fontHandles->face.get() : nullptr; + auto* face = m_fontHandles ? m_fontHandles->face.get() : nullptr; if (face && setCurrentSize(characterSize)) { @@ -426,7 +426,7 @@ float Font::getKerning(std::uint32_t first, std::uint32_t second, unsigned int c //////////////////////////////////////////////////////////// float Font::getLineSpacing(unsigned int characterSize) const { - auto face = m_fontHandles ? m_fontHandles->face.get() : nullptr; + auto* face = m_fontHandles ? m_fontHandles->face.get() : nullptr; if (face && setCurrentSize(characterSize)) { @@ -442,7 +442,7 @@ float Font::getLineSpacing(unsigned int characterSize) const //////////////////////////////////////////////////////////// float Font::getUnderlinePosition(unsigned int characterSize) const { - auto face = m_fontHandles ? m_fontHandles->face.get() : nullptr; + auto* face = m_fontHandles ? m_fontHandles->face.get() : nullptr; if (face && setCurrentSize(characterSize)) { @@ -463,7 +463,7 @@ float Font::getUnderlinePosition(unsigned int characterSize) const //////////////////////////////////////////////////////////// float Font::getUnderlineThickness(unsigned int characterSize) const { - auto face = m_fontHandles ? m_fontHandles->face.get() : nullptr; + auto* face = m_fontHandles ? m_fontHandles->face.get() : nullptr; if (face && setCurrentSize(characterSize)) { @@ -557,7 +557,7 @@ Glyph Font::loadGlyph(std::uint32_t codePoint, unsigned int characterSize, bool return glyph; // Get our FT_Face - auto face = m_fontHandles->face.get(); + auto* face = m_fontHandles->face.get(); if (!face) return glyph; @@ -584,13 +584,13 @@ Glyph Font::loadGlyph(std::uint32_t codePoint, unsigned int characterSize, bool { if (bold) { - auto outlineGlyph = reinterpret_cast(glyphDesc); + auto* outlineGlyph = reinterpret_cast(glyphDesc); FT_Outline_Embolden(&outlineGlyph->outline, weight); } if (outlineThickness != 0) { - auto stroker = m_fontHandles->stroker.get(); + auto* stroker = m_fontHandles->stroker.get(); FT_Stroker_Set(stroker, static_cast(outlineThickness * static_cast(1 << 6)), @@ -605,7 +605,7 @@ Glyph Font::loadGlyph(std::uint32_t codePoint, unsigned int characterSize, bool // Warning! After this line, do not read any data from glyphDesc directly, use // bitmapGlyph.root to access the FT_Glyph data. FT_Glyph_To_Bitmap(&glyphDesc, FT_RENDER_MODE_NORMAL, nullptr, 1); - auto bitmapGlyph = reinterpret_cast(glyphDesc); + auto* bitmapGlyph = reinterpret_cast(glyphDesc); FT_Bitmap& bitmap = bitmapGlyph->bitmap; // Apply bold if necessary -- fallback technique using bitmap (lower quality) @@ -799,7 +799,7 @@ bool Font::setCurrentSize(unsigned int characterSize) const // only when necessary to avoid killing performances // m_fontHandles and m_fontHandles->face are checked to be non-null before calling this method - auto face = m_fontHandles->face.get(); + auto* face = m_fontHandles->face.get(); FT_UShort currentSize = face->size->metrics.x_ppem; if (currentSize != characterSize) diff --git a/src/SFML/Window/GlContext.hpp b/src/SFML/Window/GlContext.hpp index cc169331..58ef13be 100644 --- a/src/SFML/Window/GlContext.hpp +++ b/src/SFML/Window/GlContext.hpp @@ -134,7 +134,6 @@ public: //////////////////////////////////////////////////////////// static std::unique_ptr create(const ContextSettings& settings, const Vector2u& size); -public: //////////////////////////////////////////////////////////// /// \brief Check whether a given OpenGL extension is available /// diff --git a/src/SFML/Window/OSX/HIDInputManager.hpp b/src/SFML/Window/OSX/HIDInputManager.hpp index 3ee15d07..1b645343 100644 --- a/src/SFML/Window/OSX/HIDInputManager.hpp +++ b/src/SFML/Window/OSX/HIDInputManager.hpp @@ -83,7 +83,6 @@ public: //////////////////////////////////////////////////////////// bool isKeyPressed(Keyboard::Key key); -public: //////////////////////////////////////////////////////////// /// \brief Get the usb location ID of a given device /// @@ -213,7 +212,6 @@ private: //////////////////////////////////////////////////////////// static UInt8 usageToVirtualCode(UInt32 usage); -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/OSX/HIDJoystickManager.hpp b/src/SFML/Window/OSX/HIDJoystickManager.hpp index 29d5425a..5024737e 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.hpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.hpp @@ -66,7 +66,6 @@ public: //////////////////////////////////////////////////////////// static HIDJoystickManager& getInstance(); -public: //////////////////////////////////////////////////////////// /// \brief Get the number of currently connected joystick /// @@ -100,7 +99,6 @@ private: //////////////////////////////////////////////////////////// void update(); -private: //////////////////////////////////////////////////////////// /// \brief Private "plug-in" callback /// \note Only 'context' parameter is used. @@ -117,7 +115,6 @@ private: //////////////////////////////////////////////////////////// static void pluggedOut(void* context, IOReturn, void*, IOHIDDeviceRef); -private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/OSX/WindowImplCocoa.hpp b/src/SFML/Window/OSX/WindowImplCocoa.hpp index 638d32e7..38e3a142 100644 --- a/src/SFML/Window/OSX/WindowImplCocoa.hpp +++ b/src/SFML/Window/OSX/WindowImplCocoa.hpp @@ -239,7 +239,6 @@ public: //////////////////////////////////////////////////////////// static void setUpProcess(); -public: //////////////////////////////////////////////////////////// /// \brief Get the OS-specific handle of the window /// diff --git a/src/SFML/Window/WindowImpl.hpp b/src/SFML/Window/WindowImpl.hpp index bb15d82f..e41f3a1b 100644 --- a/src/SFML/Window/WindowImpl.hpp +++ b/src/SFML/Window/WindowImpl.hpp @@ -83,7 +83,6 @@ public: //////////////////////////////////////////////////////////// static std::unique_ptr create(WindowHandle handle); -public: //////////////////////////////////////////////////////////// /// \brief Destructor /// diff --git a/test/System/Err.test.cpp b/test/System/Err.test.cpp index 90eec56b..99d0e6c6 100644 --- a/test/System/Err.test.cpp +++ b/test/System/Err.test.cpp @@ -18,7 +18,7 @@ TEST_CASE("[System] sf::err") SUBCASE("Redirect buffer to observe contents") { sf::err() << "We'll never be able to observe this" << std::endl; // Ensure buffer is flushed - const auto defaultStreamBuffer = sf::err().rdbuf(); + auto* const defaultStreamBuffer = sf::err().rdbuf(); CHECK(defaultStreamBuffer != nullptr); std::stringstream stream;