Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Checks: >
readability-delete-null-pointer,
readability-redundant-control-flow,
readability-redundant-string-cstr,
readability-string-compare,

WarningsAsErrors: '*'
HeaderFilterRegex: '/(?!external)/.*'
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCFastTMXTiledMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ TMXLayer * TMXTiledMap::getLayer(const std::string& layerName) const
TMXLayer* layer = dynamic_cast<TMXLayer*>(child);
if(layer)
{
if(layerName.compare( layer->getLayerName()) == 0)
if(layerName == layer->getLayerName())
{
return layer;
}
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& ima

void Label::setString(const std::string& text)
{
if (text.compare(_utf8Text))
if (text != _utf8Text)
{
_utf8Text = text;
_contentDirty = true;
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCLabelBMFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void LabelBMFont::setLineBreakWithoutSpace( bool breakWithoutSpace )
// LabelBMFont - FntFile
void LabelBMFont::setFntFile(const std::string& fntFile, const Vec2& imageOffset /* = Vec2::ZERO */)
{
if (_fntFile.compare(fntFile) != 0)
if (_fntFile != fntFile)
{
_fntFile = fntFile;
_label->setBMFontFilePath(fntFile,imageOffset);
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ Node* Node::getChildByName(const std::string& name) const
for (const auto& child : _children)
{
// Different strings may have the same hash code, but can use it to compare first for speed
if(child->_hashOfName == hash && child->_name.compare(name) == 0)
if(child->_hashOfName == hash && child->_name == name)
return child;
}
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/CCTMXTiledMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ TMXLayer * TMXTiledMap::getLayer(const std::string& layerName) const
TMXLayer* layer = dynamic_cast<TMXLayer*>(child);
if(layer)
{
if(layerName.compare( layer->getLayerName()) == 0)
if(layerName == layer->getLayerName())
{
return layer;
}
Expand Down
4 changes: 2 additions & 2 deletions cocos/base/CCConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ void Console::commandDebugMsg(int fd, const std::string& /*args*/)

void Console::commandDebugMsgSubCommandOnOff(int /*fd*/, const std::string& args)
{
_sendDebugStrings = (args.compare("on") == 0);
_sendDebugStrings = (args == "on");
}

void Console::commandDirectorSubCommandPause(int /*fd*/, const std::string& /*args*/)
Expand Down Expand Up @@ -1233,7 +1233,7 @@ void Console::commandFps(int fd, const std::string& /*args*/)

void Console::commandFpsSubCommandOnOff(int /*fd*/, const std::string& args)
{
bool state = (args.compare("on") == 0);
bool state = (args == "on");
Director *dir = Director::getInstance();
Scheduler *sched = dir->getScheduler();
sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, state));
Expand Down
2 changes: 1 addition & 1 deletion cocos/base/CCController-linux-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4740,7 +4740,7 @@ class CC_DLL ControllerImpl
// Check if we already have an available input controller profile. If so, attach it it to the controller.
for (const auto & it : s_controllerProfiles)
{
if ( deviceName.compare(it.first) == 0 )
if ( deviceName == it.first )
{
// Found controller profile. Attach it to the controller:
CCLOG("ControllerImpl: Found input profile for controller: %s", deviceName.c_str());
Expand Down
2 changes: 1 addition & 1 deletion cocos/deprecated/CCString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bool __String::isEqual(const Ref* pObject)
const __String* pStr = dynamic_cast<const __String*>(pObject);
if (pStr != nullptr)
{
if (0 == _string.compare(pStr->_string))
if (pStr->_string == _string)
{
bRet = true;
}
Expand Down
2 changes: 1 addition & 1 deletion cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ int CCBAnimationManager::getSequenceId(const char* pSequenceName)
string seqName(pSequenceName);
for (auto& seq : _sequences)
{
if (seqName.compare(seq->getName()) == 0)
if (seqName == seq->getName())
{
return seq->getSequenceId();
}
Expand Down
4 changes: 2 additions & 2 deletions cocos/editor-support/cocostudio/CCComRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ bool ComRender::serialize(void* r)
for (int i = 0; i < count; ++i)
{
std::string key = tpChildArray[i].GetName(&tCocoLoader);
if (key.compare("armature_data") == 0)
if (key == "armature_data")
{
int length = tpChildArray[i].GetChildNum();
stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
Expand All @@ -260,7 +260,7 @@ bool ComRender::serialize(void* r)
{
std::string key1 = armature_data[j].GetName(&tCocoLoader);
const char *str1 = armature_data[j].GetValue(&tCocoLoader);
if (key.compare("name") == 0)
if (key == "name")
{
if (str1 != nullptr)
{
Expand Down
Loading