-
Notifications
You must be signed in to change notification settings - Fork 128
chore: Add custom clang-tidy plugin for isEmpty() checks #1988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
chore: Add custom clang-tidy plugin for isEmpty() checks #1988
Conversation
|
Is AsciiString::compare, AsciiString::compareNoCase, UnicodeString::compare, ... also supported? |
Yes, both are implemented inline: |
|
I mean will it work together with the clang tidy refactor: if (myAscii.compare(otherAscii)) {} |
|
I looked in this change for keywords "compare" and "compareNoCase" and there was no match found. So I suspect that is missing. |
I misunderstood., sorry! Added this for both compare and compareNoCase |
Extends the clang-tidy readability-container-size-empty check to our other string types
AsciiString/UnicodeString:getLength() == 0→isEmpty()StringClass/WideStringClass:Get_Length() == 0→Is_Empty()Also handles
!=,>, and<=comparisonsDocumentation - README with build and usage instructions
Example Fixes
// Before
if (str.getLength() == 0) { ... }
if (str.Get_Length() > 0) { ... }
// After
if (str.isEmpty()) { ... }
if (!str.Is_Empty()) { ... }## Usage
clang-tidy -p build/clang-tidy
--checks='-*,generals-use-is-empty'
-load tools/clang-tidy-plugin/build/lib/libGeneralsGameCodeClangTidyPlugin.so
-fix-errors
file.cpp## Testing