Zandronum Chat @ irc.zandronum.com
#zandronum
Get the latest version: 3.0
Source Code

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003817Doomseeker[All Projects] Cleanuppublic2020-06-07 06:412020-06-07 20:55
ReporterWubTheCaptain 
Assigned To 
PrioritynoneSeveritytweakReproducibilitysometimes
StatusconfirmedResolutionopen 
PlatformOSOS Version
Product Version1.3.1 
Target VersionFixed in Version 
Summary0003817: std::string compare method is sometimes used instead of equality/inequality operators
DescriptionI think some of these string comparisons with std::string's compare method don't make sense over equality or inequality operators (== or !=). Bad readability, clang-tidy seems to agree.
Steps To ReproduceAn example:
Quote from src/core/irc/ircuserinfo.cpp
bool IRCUserInfo::operator==(const IRCUserInfo &otherUser) const
{
        QString thisNickname = this->cleanNicknameLowerCase();
        QString otherNickname = otherUser.cleanNicknameLowerCase();

        return thisNickname.compare(otherNickname) == 0;
}

Could instead have written return thisNickname == otherNickname.
grep -r '\.compare' src/ | less to sort through some of these. Some Qt::CaseInsensitive cases make sense.
Additional Informationhttps://clang.llvm.org/extra/clang-tidy/checks/readability-string-compare.html [^]
Attached Files

- Relationships

-  Notes
User avatar (0021367)
WubTheCaptain (developer)
2020-06-07 06:46

Technically it's QString::compare, but the same idea.
User avatar (0021391)
Pol M (developer)
2020-06-07 20:55

As long as there is no reason to use the result for something like a switch or something, yep, I agree.

Issue Community Support
Only registered users can voice their support. Click here to register, or here to log in.
Supporters: No one explicitly supports this issue yet.
Opponents: No one explicitly opposes this issue yet.

- Issue History
Date Modified Username Field Change
2020-06-07 06:41 WubTheCaptain New Issue
2020-06-07 06:46 WubTheCaptain Note Added: 0021367
2020-06-07 20:55 Pol M Note Added: 0021391
2020-06-07 20:55 Pol M Status new => confirmed






Questions or other issues? Contact Us.

Links


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker