Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codecheck fixes #730

Merged
merged 3 commits into from
Oct 14, 2021
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
2 changes: 1 addition & 1 deletion src/Converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/FrameSemantics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ inline namespace SDF_VERSION_NAMESPACE {
// Helpful functions when debugging in gdb
void printGraph(const ScopedGraph<PoseRelativeToGraph> &_graph)
{
std::stringstream ss;
std::cout << _graph.Graph() << std::endl;
}
void printGraph(const ScopedGraph<FrameAttachedToGraph> &_graph)
Expand Down Expand Up @@ -258,7 +257,7 @@ std::pair<const Link *, std::string>
/// be modified.
static Errors resolveModelPoseWithPlacementFrame(
const ignition::math::Pose3d &_rawPose,
const std::string _placementFrame,
const std::string &_placementFrame,
const sdf::ScopedGraph<PoseRelativeToGraph> &_graph,
ignition::math::Pose3d &_resolvedPose)
{
Expand Down
28 changes: 8 additions & 20 deletions src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, SDFPtr _sdf,
tinyxml2::XMLElement *sdfNode = _xmlDoc->FirstChildElement("sdf");
if (!sdfNode)
{
sdfdbg << "No <sdf> element in file[" << _source << "]\n";
return false;
}

Expand All @@ -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())
{
Expand Down Expand Up @@ -737,15 +738,8 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, SDFPtr _sdf,
}
else
{
if (!sdfNode)
{
sdfdbg << "No <sdf> element in file[" << _source << "]\n";
}
else if (!sdfNode->Attribute("version"))
{
sdfdbg << "SDF <sdf> element has no version in file["
<< _source << "]\n";
}
sdfdbg << "SDF <sdf> element has no version in file["
<< _source << "]\n";
return false;
}

Expand All @@ -767,6 +761,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, ElementPtr _sdf,
tinyxml2::XMLElement *sdfNode = _xmlDoc->FirstChildElement("sdf");
if (!sdfNode)
{
sdfdbg << "SDF has no <sdf> element\n";
return false;
}

Expand All @@ -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())
{
Expand Down Expand Up @@ -838,14 +833,7 @@ bool readDoc(tinyxml2::XMLDocument *_xmlDoc, ElementPtr _sdf,
}
else
{
if (!sdfNode)
{
sdfdbg << "SDF has no <sdf> element\n";
}
else if (!sdfNode->Attribute("version"))
{
sdfdbg << "<sdf> element has no version\n";
}
sdfdbg << "<sdf> element has no version\n";
return false;
}

Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/parser_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 << "<sdf version=\"" << SDF_PROTOCOL_VERSION << "\"><test>" << _xml
Expand Down
2 changes: 1 addition & 1 deletion test/integration/interface_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/nested_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/unknown.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"(
<?xml version="1.0" ?>
Expand Down