diff --git a/src/Converter.cc b/src/Converter.cc index 542c14813..451f4b696 100644 --- a/src/Converter.cc +++ b/src/Converter.cc @@ -88,7 +88,7 @@ bool Converter::Convert(tinyxml2::XMLDocument *_doc, return false; } - if (!elem || !elem->Attribute("version")) + if (!elem->Attribute("version")) { sdferr << " Unable to determine original SDF version\n"; return false; diff --git a/src/FrameSemantics.cc b/src/FrameSemantics.cc index 94893dcf5..6081aac97 100644 --- a/src/FrameSemantics.cc +++ b/src/FrameSemantics.cc @@ -44,7 +44,6 @@ inline namespace SDF_VERSION_NAMESPACE { // Helpful functions when debugging in gdb void printGraph(const ScopedGraph &_graph) { - std::stringstream ss; std::cout << _graph.Graph() << std::endl; } void printGraph(const ScopedGraph &_graph) @@ -258,7 +257,7 @@ std::pair /// be modified. static Errors resolveModelPoseWithPlacementFrame( const ignition::math::Pose3d &_rawPose, - const std::string _placementFrame, + const std::string &_placementFrame, const sdf::ScopedGraph &_graph, ignition::math::Pose3d &_resolvedPose) { diff --git a/src/parser.cc b/src/parser.cc index 0b11d0f03..699c15fab 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -661,6 +661,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, SDFPtr _sdf, tinyxml2::XMLElement *sdfNode = _xmlDoc->FirstChildElement("sdf"); if (!sdfNode) { + sdfdbg << "No element in file[" << _source << "]\n"; return false; } @@ -675,7 +676,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, SDFPtr _sdf, _sdf->SetFilePath(_source); } - if (sdfNode && sdfNode->Attribute("version")) + if (sdfNode->Attribute("version")) { if (_sdf->OriginalVersion().empty()) { @@ -737,15 +738,8 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, SDFPtr _sdf, } else { - if (!sdfNode) - { - sdfdbg << "No element in file[" << _source << "]\n"; - } - else if (!sdfNode->Attribute("version")) - { - sdfdbg << "SDF element has no version in file[" - << _source << "]\n"; - } + sdfdbg << "SDF element has no version in file[" + << _source << "]\n"; return false; } @@ -767,6 +761,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, ElementPtr _sdf, tinyxml2::XMLElement *sdfNode = _xmlDoc->FirstChildElement("sdf"); if (!sdfNode) { + sdfdbg << "SDF has no element\n"; return false; } @@ -775,7 +770,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, ElementPtr _sdf, _sdf->SetFilePath(_source); } - if (sdfNode && sdfNode->Attribute("version")) + if (sdfNode->Attribute("version")) { if (_sdf->OriginalVersion().empty()) { @@ -838,14 +833,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, ElementPtr _sdf, } else { - if (!sdfNode) - { - sdfdbg << "SDF has no element\n"; - } - else if (!sdfNode->Attribute("version")) - { - sdfdbg << " element has no version\n"; - } + sdfdbg << " element has no version\n"; return false; } @@ -1149,7 +1137,7 @@ static bool readAttributes(tinyxml2::XMLElement *_xml, ElementPtr _sdf, /// \param[out] _errors Captures errors found during parsing. /// \return True if the file name is successfully resolved, false on error. static bool resolveFileNameFromUri(tinyxml2::XMLElement *_includeXml, - const sdf::ParserConfig &_config, const std::string _includeXmlPath, + const sdf::ParserConfig &_config, const std::string &_includeXmlPath, const std::string &_errorSourcePath, std::string &_fileName, Errors &_errors) { diff --git a/src/parser_TEST.cc b/src/parser_TEST.cc index 29beaee98..017c9cd9e 100644 --- a/src/parser_TEST.cc +++ b/src/parser_TEST.cc @@ -581,7 +581,7 @@ TEST_F(ValueConstraintsFixture, ElementMinMaxValues) auto sdf = InitSDF(); sdf->Root()->AddElementDescription(sdfTest->Root()); - auto wrapInSdf = [](std::string _xml) -> std::string + auto wrapInSdf = [](const std::string &_xml) -> std::string { std::stringstream ss; ss << "" << _xml diff --git a/test/integration/interface_api.cc b/test/integration/interface_api.cc index 6d7bdde83..77180114c 100644 --- a/test/integration/interface_api.cc +++ b/test/integration/interface_api.cc @@ -392,7 +392,7 @@ TEST_F(InterfaceAPI, FrameSemantics) EXPECT_EQ(1u, world->InterfaceModelCount()); auto resolvePoseNoErrors = - [](const sdf::SemanticPose &_semPose, const std::string _relativeTo = "") + [](const sdf::SemanticPose &_semPose, const std::string &_relativeTo = "") { Pose3d pose; sdf::Errors resolveErrors = _semPose.Resolve(pose, _relativeTo); diff --git a/test/integration/nested_model.cc b/test/integration/nested_model.cc index 904115114..d6056274d 100644 --- a/test/integration/nested_model.cc +++ b/test/integration/nested_model.cc @@ -993,7 +993,7 @@ class PlacementFrame: public ::testing::Test } public: sdf::SemanticPose GetChildEntitySemanticPose( - const sdf::World *_world, const std::string _entityName) + const sdf::World *_world, const std::string &_entityName) { return _world->ModelByName(_entityName)->SemanticPose(); } diff --git a/test/integration/unknown.cc b/test/integration/unknown.cc index 35ade31b6..7e9b2ed5a 100644 --- a/test/integration/unknown.cc +++ b/test/integration/unknown.cc @@ -142,7 +142,7 @@ TEST(UnrecognizedElements, OldElementsInNewSchemas) { // This should be valid in 1.6, but not in 1.8 (do to usage of // `use_parent_model_frame`). - auto make_model_xml_string = [](std::string version) + auto make_model_xml_string = [](const std::string &version) { return R"(