Skip to content

Commit 9b1b0f5

Browse files
gnawmeChrisThrasher
authored andcommitted
Streamlined readability-* clang-tidy checks
Addressed CI complaints Addressed review comments, CI issues Reverted files exempted from linting Fixed missing comma Fixed clang-format escape Disabled spurious readability-non-const-parameter Addressed review comment Moved NOLINT inside namespace per review Remove const from function argument decls Fixed rebase and formatting issues Fixed macOS CI issues
1 parent b48f4b7 commit 9b1b0f5

16 files changed

+39
-44
lines changed

.clang-tidy

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ Checks: >
33
clang-analyzer-*,
44
modernize-*,
55
portability-*,
6-
readability-container-size-empty,
7-
readability-identifier-naming,
8-
readability-isolate-declaration,
9-
readability-qualified-auto,
10-
readability-redundant-access-specifiers,
11-
readability-redundant-*,
12-
readability-simplify-*,
6+
readability-*,
137
-clang-analyzer-core.NonNullParamChecker,
148
-clang-analyzer-core.NullDereference,
159
-clang-analyzer-nullability.NullablePassedToNonnull,
@@ -28,10 +22,15 @@ Checks: >
2822
-modernize-use-trailing-return-type,
2923
-readability-braces-around-statements,
3024
-readability-container-contains,
25+
-readability-convert-member-functions-to-static,
26+
-readability-else-after-return,
3127
-readability-function-cognitive-complexity,
28+
-readability-function-size,
29+
-readability-identifier-length,
30+
-readability-implicit-bool-conversion,
3231
-readability-magic-numbers,
33-
-readability-make-member-function-const,
34-
-readability-implicit-bool-conversion
32+
-readability-named-parameter,
33+
-readability-uppercase-literal-suffix,
3534
3635
CheckOptions:
3736
- { key: readability-identifier-naming.ClassCase, value: CamelCase }

include/SFML/Audio/SoundSource.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
namespace sf
3737
{
38+
// NOLINTBEGIN(readability-make-member-function-const)
3839
////////////////////////////////////////////////////////////
3940
/// \brief Base class defining a sound's properties
4041
///
@@ -291,6 +292,7 @@ class SFML_AUDIO_API SoundSource : AlResource
291292
unsigned int m_source; //!< OpenAL source identifier
292293
};
293294

295+
// NOLINTEND(readability-make-member-function-const)
294296
} // namespace sf
295297

296298

src/SFML/Audio/SoundFileReaderOgg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ long tell(void* data)
6464
return static_cast<long>(stream->tell());
6565
}
6666

67-
static ov_callbacks callbacks = {&read, &seek, nullptr, &tell};
67+
ov_callbacks callbacks = {&read, &seek, nullptr, &tell};
6868
} // namespace
6969

7070
namespace sf::priv

src/SFML/Audio/SoundSource.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
namespace sf
3636
{
37+
// NOLINTBEGIN(readability-make-member-function-const)
3738
////////////////////////////////////////////////////////////
3839
SoundSource::SoundSource()
3940
{
@@ -204,5 +205,6 @@ SoundSource::Status SoundSource::getStatus() const
204205

205206
return Stopped;
206207
}
208+
// NOLINTEND(readability-make-member-function-const)
207209

208210
} // namespace sf

src/SFML/System/Vector2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ Angle Vector2<T>::angle() const
6767

6868
////////////////////////////////////////////////////////////
6969
template <typename T>
70-
Vector2<T> Vector2<T>::rotatedBy(Angle angle) const
70+
Vector2<T> Vector2<T>::rotatedBy(Angle phi) const
7171
{
7272
static_assert(std::is_floating_point_v<T>, "Vector2::rotatedBy() is only supported for floating point types");
7373

7474
// No zero vector assert, because rotating a zero vector is well-defined (yields always itself)
75-
T cos = std::cos(static_cast<T>(angle.asRadians()));
76-
T sin = std::sin(static_cast<T>(angle.asRadians()));
75+
T cos = std::cos(static_cast<T>(phi.asRadians()));
76+
T sin = std::sin(static_cast<T>(phi.asRadians()));
7777

7878
// Don't manipulate x and y separately, otherwise they're overwritten too early
7979
return Vector2<T>(cos * x - sin * y, sin * x + cos * y);

src/SFML/Window/DRM/DRMContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ int contextCount = 0;
6464
EGLDisplay display = EGL_NO_DISPLAY;
6565
int waitingForFlip = 0;
6666

67-
static void pageFlipHandler(int /* fd */, unsigned int /* frame */, unsigned int /* sec */, unsigned int /* usec */, void* data)
67+
void pageFlipHandler(int /* fd */, unsigned int /* frame */, unsigned int /* sec */, unsigned int /* usec */, void* data)
6868
{
6969
int* temp = static_cast<int*>(data);
7070
*temp = 0;
7171
}
7272

73-
static bool waitForFlip(int timeout)
73+
bool waitForFlip(int timeout)
7474
{
7575
while (waitingForFlip)
7676
{

src/SFML/Window/DRM/InputImplUDev.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <SFML/System/Err.hpp>
2929
#include <SFML/Window/DRM/InputImplUDev.hpp>
3030

31+
#include <algorithm>
3132
#include <cerrno>
3233
#include <cstdio>
3334
#include <cstdlib>
@@ -664,13 +665,9 @@ void InputImpl::setMousePosition(const Vector2i& position, const WindowBase& /*r
664665
////////////////////////////////////////////////////////////
665666
bool InputImpl::isTouchDown(unsigned int finger)
666667
{
667-
for (const auto& slot : touchSlots)
668-
{
669-
if (slot.id == static_cast<int>(finger))
670-
return true;
671-
}
672-
673-
return false;
668+
return std::any_of(touchSlots.cbegin(),
669+
touchSlots.cend(),
670+
[finger](const TouchSlot& slot) { return slot.id == static_cast<int>(finger); });
674671
}
675672

676673

src/SFML/Window/GlContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ void GlContext::initialize(const ContextSettings& requestedSettings)
913913

914914

915915
////////////////////////////////////////////////////////////
916-
void GlContext::checkSettings(const ContextSettings& requestedSettings)
916+
void GlContext::checkSettings(const ContextSettings& requestedSettings) const
917917
{
918918
// Perform checks to inform the user if they are getting a context they might not have expected
919919

src/SFML/Window/GlContext.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class GlContext
311311
/// \param requestedSettings Requested settings during context creation
312312
///
313313
////////////////////////////////////////////////////////////
314-
void checkSettings(const ContextSettings& requestedSettings);
314+
void checkSettings(const ContextSettings& requestedSettings) const;
315315

316316
////////////////////////////////////////////////////////////
317317
// Member data

src/SFML/Window/OSX/HIDInputManager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class HIDInputManager
257257
/// \see isKeyPressed, isMouseButtonPressed
258258
///
259259
////////////////////////////////////////////////////////////
260-
bool isPressed(IOHIDElements& elements);
260+
bool isPressed(IOHIDElements& elements) const;
261261

262262
////////////////////////////////////////////////////////////
263263
/// \brief Convert a HID key usage to its corresponding scancode

0 commit comments

Comments
 (0)