From 048534e89d8f0c946ff55cac86678576c2a9d0be Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 23 Jan 2016 20:58:03 +0100 Subject: [PATCH] Fixed some errors reported by colobot-lint --- src/CBot/CBotDebug.cpp | 3 ++- src/CBot/CBotEnums.h | 3 ++- src/CBot/CBotExternalCall.cpp | 2 +- src/CBot/CBotToken.cpp | 3 ++- src/CBot/CBotUtils.h | 6 ++++-- src/CBot/stdlib/FileFunctions.cpp | 3 ++- src/script/scriptfunc.cpp | 2 +- test/unit/CBot/CBotToken_test.cpp | 5 +++-- test/unit/CBot/{CBot.cpp => CBot_test.cpp} | 5 +++-- test/unit/CMakeLists.txt | 2 +- 10 files changed, 21 insertions(+), 13 deletions(-) rename test/unit/CBot/{CBot.cpp => CBot_test.cpp} (99%) diff --git a/src/CBot/CBotDebug.cpp b/src/CBot/CBotDebug.cpp index fc8c8742..986da851 100644 --- a/src/CBot/CBotDebug.cpp +++ b/src/CBot/CBotDebug.cpp @@ -55,7 +55,8 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program) } std::set finished; - std::function DumpInstr = [&](CBotInstr* instr) { + std::function DumpInstr = [&](CBotInstr* instr) + { if (finished.find(instr) != finished.end()) return; finished.insert(instr); diff --git a/src/CBot/CBotEnums.h b/src/CBot/CBotEnums.h index 8f6d691b..5d9c161c 100644 --- a/src/CBot/CBotEnums.h +++ b/src/CBot/CBotEnums.h @@ -170,7 +170,8 @@ enum TokenId /** * \brief Types of tokens */ -enum TokenType { +enum TokenType +{ TokenTypNone = 0, TokenTypKeyWord = 1, //!< keyword of the language (see TokenKeyWord) TokenTypNum = 2, //!< number diff --git a/src/CBot/CBotExternalCall.cpp b/src/CBot/CBotExternalCall.cpp index 54ab787b..e0ebd17d 100644 --- a/src/CBot/CBotExternalCall.cpp +++ b/src/CBot/CBotExternalCall.cpp @@ -168,4 +168,4 @@ bool CBotExternalCallDefault::Run(CBotVar* thisVar, CBotStack* pStack) return true; } -} \ No newline at end of file +} diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp index aff8431b..13ac8882 100644 --- a/src/CBot/CBotToken.cpp +++ b/src/CBot/CBotToken.cpp @@ -117,7 +117,8 @@ static const std::map KEYWORDS = { {TX_NAN, "not a number"} }; -namespace { +namespace +{ static const std::string emptyString = ""; } const std::string& LoadString(TokenId id) diff --git a/src/CBot/CBotUtils.h b/src/CBot/CBotUtils.h index a56a646b..b19d61d6 100644 --- a/src/CBot/CBotUtils.h +++ b/src/CBot/CBotUtils.h @@ -96,7 +96,8 @@ long GetNumInt(const std::string& str); */ float GetNumFloat(const std::string& str); -template class CBotLinkedList { +template class CBotLinkedList +{ public: /** * \brief Destructor. Be careful, destroys the whole linked list! @@ -134,7 +135,8 @@ protected: T* m_next = nullptr; }; -template class CBotDoublyLinkedList { +template class CBotDoublyLinkedList +{ public: /** * \brief Destructor. Be careful, destroys the whole linked list! diff --git a/src/CBot/stdlib/FileFunctions.cpp b/src/CBot/stdlib/FileFunctions.cpp index ebc52e6d..43ba4bf6 100644 --- a/src/CBot/stdlib/FileFunctions.cpp +++ b/src/CBot/stdlib/FileFunctions.cpp @@ -28,7 +28,8 @@ namespace CBot { -namespace { +namespace +{ std::unique_ptr g_fileHandler; std::unordered_map> g_files; int g_nextFileId = 1; diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index 4e16d409..39f8b0d3 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -3448,4 +3448,4 @@ void CScriptFunctions::DestroyObjectVar(CBotVar* botVar, bool permanent) bool CScriptFunctions::CheckOpenFiles() { return CBotFileColobot::m_numFilesOpen > 0; -} \ No newline at end of file +} diff --git a/test/unit/CBot/CBotToken_test.cpp b/test/unit/CBot/CBotToken_test.cpp index 517cfb5b..883a7590 100644 --- a/test/unit/CBot/CBotToken_test.cpp +++ b/test/unit/CBot/CBotToken_test.cpp @@ -51,7 +51,8 @@ protected: CBotToken* token = tokens.get()->GetNext(); // TODO: why do we always have to skip the first one :/ ASSERT_TRUE(token != nullptr); unsigned int i = 0; - do { + do + { ASSERT_LT(i, data.size()) << "too many tokens processed"; TokenTest correct = data[i]; @@ -120,4 +121,4 @@ TEST_F(CBotTokenUT, BasicProgram) {";", ID_SEP}, {"}", ID_CLBLK}, }); -} \ No newline at end of file +} diff --git a/test/unit/CBot/CBot.cpp b/test/unit/CBot/CBot_test.cpp similarity index 99% rename from test/unit/CBot/CBot.cpp rename to test/unit/CBot/CBot_test.cpp index 23c0bb4a..f7b25391 100644 --- a/test/unit/CBot/CBot.cpp +++ b/test/unit/CBot/CBot_test.cpp @@ -39,7 +39,8 @@ public: } private: - class CBotTestFail : public std::runtime_error { + class CBotTestFail : public std::runtime_error + { public: CBotTestFail(const std::string& message) : runtime_error(message) { @@ -982,4 +983,4 @@ TEST_F(CBotUT, DISABLED_TestNANParam_Issue642) " ASSERT(test(nan) == nan);\n" "}\n" ); -} \ No newline at end of file +} diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index cbf69564..446834f7 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -10,7 +10,7 @@ set(UT_SOURCES main.cpp app/app_test.cpp CBot/CBotToken_test.cpp - CBot/CBot.cpp + CBot/CBot_test.cpp common/config_file_test.cpp graphics/engine/lightman_test.cpp math/func_test.cpp