for Qstrings and QByteArrays prefer isEmpty() over size() and length()#1409
Merged
tsteven4 merged 2 commits intoGPSBabel:masterfrom Feb 13, 2025
Merged
for Qstrings and QByteArrays prefer isEmpty() over size() and length()#1409tsteven4 merged 2 commits intoGPSBabel:masterfrom
tsteven4 merged 2 commits intoGPSBabel:masterfrom
Conversation
Collaborator
|
Nice!
Some day, we should get that going on patches coming in so we don't
introduce regressions.
…On Thu, Feb 13, 2025 at 2:44 PM tsteven4 ***@***.***> wrote:
Merged #1409 <#1409> into master.
—
Reply to this email directly, view it on GitHub
<#1409 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACCSD3ZQHDD2FZOCKCSMPGD2PT7Z7AVCNFSM6AAAAABXCQ6HT6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJWGMYDENBZG4ZDGMA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This applies the clang-tidy readability-container-size-empty check to QString and QByteArrays.
This check normally doesn't work because unlike QList QString and QByteArray don't have an empty() method. By editing qstring.h and qbytearray.h an empty() method can be added. When running clang-tidy use the export-fixes option as the fixes will use empty() instead of isEmpty(). Edit the fixes file changing the replacment text to use isEmpty() instead of empty(): 'g/ReplacementText/s/\.empty()/.isEmpty()/g' and 'g/ReplacementText/s/->empty()/->isEmpty()/g', and then run clang-apply-replacements.
You may note some replacements where the original code didn't use size() or length(), but instead used equality comparisons to "" or QString(). These were generated by the readability-container-size-empty check, and should work fine. I did compare the optionList generated by formatload and found it equivalent.