Commit graph

47 commits

Author SHA1 Message Date
Robert Müller 02a66b301a Remove clang-tidy class/struct name exceptions
- `struct EnvelopedQuad` --> `class CEnvelopedQuad`
- `struct MapObject` --> `class CMapObject`
2024-09-22 16:03:15 +02:00
Robert Müller fd33f0fc1a Remove most clang-tidy parameter name exceptions
- `maxModes` --> `MaxModesAvailable` (`MaxModes` is already used differently)
- `numModes` --> `NumModesInserted` (`NumModes` is already used differently)
- `mode` --> `Mode`
- `rgb` --> `Color`
- `png_ptr` --> `pPngStruct`
- `error_msg` --> `pErrorMessage`
- `warning_msg` --> `pWarningMessage`
- `sw` --> `SubWidth`
- `sh` --> `SubHeight`
- `lhs` --> `Lhs`
- `rhs` --> `Rhs`
- `object` --> `pObject`
- `index` --> `pIndex`/`Index`
- `array` --> `pArray`
- `string` --> `pString`
- `integer` --> `pInteger`
- `boolean` --> `pBoolean`
- `p` --> `pObj`
- `id` --> `Id`/`Index`
- `width` --> `Width`
- `height` --> `Height`
- `ownId` --> `OwnId`
- `xoff` --> `OffsetX`
- `yoff` --> `OffsetY`
- `pos0` --> `Pos0`
- `pos1` --> `Pos1`
- `fnMatchCallback` --> `pfnMatchCallback`
- `dx` --> `DeltaX`
- `dy` --> `DeltaY`
- `wx`, `wy` --> `WorldPos` (`vec2` instead of two `float`s)
2024-09-22 15:47:31 +02:00
Robert Müller 2fa4c1f603 Remove clang-tidy static variable name exceptions
- Remove `readability-identifier-naming.StaticVariableIgnoredRegexp`.
- Mark `static` variables as `const` and use `UPPER_CASE` for names when possible.
- Use local variables instead of `static` variables when possible.
- Use member variables with correct name instead of `static` variables.
- Pass output buffer for `static` function `GetKeyBindModifiersName` by argument instead of returning pointer to `static` buffer.
2024-08-10 13:27:55 +02:00
ChillerDragon 7553ea6297 Improve clang variable naming checks
Introduces checks for more variable types.
And fixes false positives in newer clang versions.
2024-07-06 10:10:00 +08:00
Robert Müller f494826dcf
Merge pull request #8154 from ChillerDragon/pr_worst_style_offenders
Fix worst local variable style offenses
2024-06-06 20:18:19 +00:00
ChillerDragon c1a5e59d9f Exclude enough checks to pass with clang tidy 19 2024-05-26 19:31:54 +08:00
ChillerDragon ab64d64fed Whitelist class names starting with I
Fixes clang issues being detected in interface classes such as `class IJob`

Fixes the following clangd error:

``Invalid case style for class 'IJob' (fix available)``
2024-05-21 11:05:39 +08:00
ChillerDragon b422b0e927 Enforce more styling with clang tidy 2024-05-06 15:32:14 +08:00
ChillerDragon fcbd1fb1b1 Fix worst local variable style offenses
Removed member prefix m_ used for local variables.
Removed all b, c, i hungarian notation prefixes for boolean, const and integers.
Fixed local variables using lower_snake_case instead of UpperCamelCase.
Renamed all ``float wSearch = TextRender()->TextWidth..`` to ``float SearchWidth = ..``.
2024-05-04 11:17:06 +08:00
ChillerDragon 63c8172d11 Enforce UpperCamelCase for local variables 2024-05-02 18:52:16 +08:00
Robert Müller 6a12e209b6 Fix readability-make-member-function-const 2023-12-14 23:38:03 +01:00
Robert Müller 5a10ef049a Fix clang-tidy readability-static-accessed-through-instance
The crash that was occurring with this check was fixed in clang 15.
2023-10-06 14:07:02 +02:00
Robert Müller fb7669ebb0 Fix clang-tidy modernize-use-override 2023-10-06 14:06:52 +02:00
Robert Müller 6d71e119a2 Add suppression for clang-tidy bugprone-suspicious-realloc-usage
We generally don't handle memory allocation failures.
2023-10-06 14:06:33 +02:00
Robert Müller cc5ae51cb6 Add suppression for clang-tidy misc-use-anonymous-namespace
We don't want to use anonymous namespaces instead of static functions.
2023-10-06 14:06:11 +02:00
Dennis Felsing 1af3c2274a More minimal clang-tidy 15 run
Alternative to #6294

The only remaining problems are:
/home/deen/git/ddnet/src/engine/client/backend/glsl_shader_compiler.cpp:22:26: warning: unnecessary temporary object created while calling emplace_back [modernize-use-emplace]
        m_vDefines.emplace_back(SGLSLCompilerDefine(DefineName, DefineValue));
                                ^~~~~~~~~~~~~~~~~~~~                       ~
2023-01-23 11:20:05 +01:00
Dennis Felsing f3123086f8 Add portability-* clang-tidy checks 2022-05-26 12:18:56 +02:00
Dennis Felsing e3f27b6897 Enable less controversial cppcoreguidelines clang-tidy checks 2022-05-26 12:13:36 +02:00
Dennis Felsing 402cccf8f2 Add override in code behind CONF_DISCORD, disable clang-tidy check 2022-05-18 01:19:35 +02:00
Dennis Felsing 8d5693d483 Enable clang-tidy's modernize-use-override (fixes #5139)
except for destructors
2022-05-17 20:33:29 +02:00
Dennis Felsing fef7af806c Add some more modernize-* checks 2022-02-15 00:25:42 +01:00
Dennis Felsing dbfc62d2c0 Add modernize-deprecated-headers 2022-02-15 00:22:52 +01:00
Dennis Felsing 7da9f1b93b Add modernize-use-equals-delete 2022-02-15 00:20:34 +01:00
Dennis Felsing de17e9902e Add modernize-unary-static-assert 2022-02-15 00:18:05 +01:00
Dennis Felsing b58470fda4 Add modernize-use-equals-default 2022-02-15 00:17:57 +01:00
Dennis Felsing 2da5d7d289 Add modernize-use-emplace 2022-02-15 00:15:06 +01:00
Dennis Felsing 68e4eb21d5 Add modernize-use-bool-literals 2022-02-15 00:12:52 +01:00
Dennis Felsing 984aed2e03 Add more clang-tidy modernize-* checks 2022-02-15 00:09:48 +01:00
Dennis Felsing 62756dbda0 Enable modernize-make-unique clang-tidy check 2022-02-15 00:05:46 +01:00
Dennis Felsing 7903b40066 Quiet clang-tidy on macOS 2022-01-23 19:04:01 +01:00
Dennis Felsing 4da76e0e7d Fix any_of 2022-01-23 18:56:37 +01:00
def ddc279c80f Turn around readability: use all, exclude some 2022-01-23 18:50:11 +01:00
def 94272f82c7 Add more readability checks 2022-01-22 17:45:25 +01:00
def 47518561a8 Consider include directories as SYSTEM dirs
Uses -isystem instead of -I, so that warnings and clang-tidy checks are
ignored for those headers.

No longer need HeaderFilterRegex in clang-tidy since it only checks
non-system headers.
2022-01-22 17:23:46 +01:00
def 3f7befdd8b Add some further readability checks, mostly redundancy
/media/ddnet/src/engine/server/databases/sqlite.cpp:232:55: warning: the address of ‘char* sqlite3_expanded_sql(sqlite3_stmt*)’ will never be NULL [-Waddress]
  232 |         if(m_pStmt != nullptr && sqlite3_expanded_sql != nullptr)
      |                                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
2022-01-22 17:22:01 +01:00
def bc78ba57b9 Enable readability-inconsistent-declaration-parameter-name 2022-01-22 14:12:59 +01:00
def 7aac8b5386 Add readability-container-size-empty 2022-01-22 13:54:25 +01:00
def bcb50c1b29 Enable readability-const-return-type, readability-container-data-pointer, readability-delete-null-pointer 2022-01-22 13:49:14 +01:00
def 653c7715a5 Add readability-avoid-const-params-in-decls 2022-01-22 13:44:22 +01:00
def f3796e5455 Disable or fix some spammy new clang-tidy 13 warnings
src/engine/client/backend/opengles/opengles_sl_program.cpp:10:11: warning: suspicious #include of file with '.cpp' extension [bugprone-suspicious-include]
          ^

src/engine/graphics.h:330:67: warning: 2 adjacent parameters of 'CFreeformItem' of similar type ('float') are easily swapped by mistake [bugprone-easily-swappable-parameters]
                CFreeformItem(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) :
                                                                                ^~~~~~~~~~~~~~~~~~

src/game/editor/layer_tiles.cpp:1802:14: warning: result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result]
                        mem_zero(&m_pSwitchTile[y * m_Width], o * sizeof(CSwitchTile));
                                  ^

src/game/server/entities/plasma.cpp💯152: warning: operator has equivalent nested operands [misc-redundant-expression]
        if(SnapPlayer && SnapPlayer->GetTeam() != TEAM_SPECTATORS && !SnapPlayer->IsPaused() && SnapChar && SnapChar && SnapChar->Team() != m_ResponsibleTeam && SnapPlayer->m_ShowOthers != 1)
                                                                                                ~~~~~~~~    ~~~~~~~~                                          ^

src/game/editor/editor.cpp:4295:38: warning: The right operand of '>' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
                        if(m_FilePreviewImageInfo.m_Width > Preview.w)
                                                          ^ ~~~~~~~~~
2022-01-22 13:35:52 +01:00
def 1ed74af678 Update .clang-tidy file to 11 2020-12-22 12:28:37 +01:00
def 7a9a67c5d7 Enable most clang-tidy misc-* checks 2020-11-05 12:03:14 +01:00
def 312b9d3bd8 Enable clang-tidy performance-* checks 2020-11-05 11:34:20 +01:00
def ba53c7e20c Add most bugprone checks 2020-11-05 08:25:26 +01:00
def b1f0fd8969 Enable modernize-loop-convert clang-tidy check
and run clang-format afterwards

https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html
2020-11-02 22:40:24 +01:00
def dad91eb763 Enable readability-qualified-auto clang-tidy check
https://clang.llvm.org/extra/clang-tidy/checks/readability-qualified-auto.html
2020-11-02 22:40:02 +01:00
Edgar baa8b93d2f Add clang-tidy to CI and enable clang-analyzer checks
The actual work will be fixing those or at least
NOLINT(clang-analyzer-optin.cplusplus.VirtualCall) them so we can enable
this. Disable checks that we don't want.

Exclude external directory from clang-tidy.
2020-10-14 14:54:33 +02:00