diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 1ef7c62aa..e04c23ed2 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -342,24 +342,21 @@ void ImportProject::importCompileCommands(std::istream &istr) const std::string directory = dirpath; std::ostringstream comm; - if( obj.find( "arguments" ) != obj.end() ) { - if( obj[ "arguments" ].is< picojson::array >() ) { - for( const picojson::value& arg : obj[ "arguments" ].get< picojson::array >() ) { - if( arg.is< std::string >() ) { + if (obj.find("arguments") != obj.end()) { + if (obj[ "arguments" ].is< picojson::array >()) { + for (const picojson::value& arg : obj[ "arguments" ].get< picojson::array >()) { + if (arg.is< std::string >()) { comm << arg.get< std::string >() << " "; } } - } - else { + } else { return; } - } - else if( obj.find( "command" ) != obj.end() ) { - if( obj[ "command" ].is< std::string >() ) { + } else if (obj.find("command") != obj.end()) { + if (obj[ "command" ].is< std::string >()) { comm << obj[ "command" ].get< std::string >(); } - } - else { + } else { return; } diff --git a/test/testimportproject.cpp b/test/testimportproject.cpp index 26df47eef..55ed6b52d 100644 --- a/test/testimportproject.cpp +++ b/test/testimportproject.cpp @@ -47,8 +47,8 @@ private: TEST_CASE(importCompileCommands2); // #8563 TEST_CASE(importCompileCommands3); // check with existing trailing / in directory TEST_CASE(importCompileCommands4); // only accept certain file types - TEST_CASE(importCompileCommandsArgumentsSection); // Handle arguments section - TEST_CASE(importCompileCommandsNoCommandSection); // gracefully handles malformed json + TEST_CASE(importCompileCommandsArgumentsSection); // Handle arguments section + TEST_CASE(importCompileCommandsNoCommandSection); // gracefully handles malformed json TEST_CASE(importCppcheckGuiProject); }