From 13144a08e496b89b34093ffd3d810d3442df3c44 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Thu, 14 May 2020 23:15:35 +0100 Subject: Enable some more clang-tidy linter checks (#4738) * Avoid inefficient AString -> c_str() -> AString round trip * Avoid redundant string init expressions * Avoid unnecessary return, continue, etc. * Add .clang-format to help with clang-tidy fix-its * Avoid unnecessary passing by value * Avoid unnecessary local copying * Avoid copying in range-for loops * Avoid over-complicated boolean expressions * Some violations missed by my local clang-tidy * Allow unnecessary continue statements * Add brackets * Another expression missed locally * Move BindingsProcessor call into clang-tidy.sh and add space * Fix pushd not found error * Different grouping of CheckBlockInteractionRate --- src/Root.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/Root.cpp') diff --git a/src/Root.cpp b/src/Root.cpp index 8ccf55d47..0cece9e6d 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -473,7 +473,7 @@ void cRoot::LoadWorlds(cDeadlockDetect & a_dd, cSettingsRepositoryInterface & a_ // Get the default world AString DefaultWorldName = a_Settings.GetValueSet("Worlds", "DefaultWorld", "world"); AString DefaultWorldPath = a_Settings.GetValueSet("WorldPaths", DefaultWorldName, DefaultWorldName); - m_pDefaultWorld = new cWorld(DefaultWorldName.c_str(), DefaultWorldPath.c_str(), a_dd, WorldNames); + m_pDefaultWorld = new cWorld(DefaultWorldName, DefaultWorldPath, a_dd, WorldNames); m_WorldsByName[ DefaultWorldName ] = m_pDefaultWorld; // Then load the other worlds @@ -505,7 +505,7 @@ void cRoot::LoadWorlds(cDeadlockDetect & a_dd, cSettingsRepositoryInterface & a_ */ bool FoundAdditionalWorlds = false; - for (auto WorldNameValue : Worlds) + for (const auto & WorldNameValue : Worlds) { AString ValueName = WorldNameValue.first; if (ValueName.compare("World") != 0) @@ -527,7 +527,7 @@ void cRoot::LoadWorlds(cDeadlockDetect & a_dd, cSettingsRepositoryInterface & a_ // The default world is an overworld with no links eDimension Dimension = dimOverworld; - AString LinkTo = ""; + AString LinkTo; // if the world is called x_nether if ((LowercaseName.size() > NetherAppend.size()) && (LowercaseName.substr(LowercaseName.size() - NetherAppend.size()) == NetherAppend)) @@ -571,7 +571,7 @@ void cRoot::LoadWorlds(cDeadlockDetect & a_dd, cSettingsRepositoryInterface & a_ } Dimension = dimEnd; } - NewWorld = new cWorld(WorldName.c_str(), WorldPath.c_str(), a_dd, WorldNames, Dimension, LinkTo); + NewWorld = new cWorld(WorldName, WorldPath, a_dd, WorldNames, Dimension, LinkTo); m_WorldsByName[WorldName] = NewWorld; } // for i - Worlds @@ -891,11 +891,7 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac m_BestRating = Rating; ++m_NumMatches; } - if (Rating == m_NameLength) // Perfect match - { - return true; - } - return false; + return (Rating == m_NameLength); // Perfect match } cCallback (const AString & a_CBPlayerName) : -- cgit v1.2.3