Skip to content

Commit

Permalink
Change function naming, add documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcarroll committed Jan 15, 2019
1 parent 804e9cd commit e494d26
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 121 deletions.
3 changes: 2 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Checks: '-*,bugprone-*,modernize-*,performance-*,-modernize-use-equals-delete,-m
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.GlobalFunctionCase, value: camelBack }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
- { key: readability-identifier-naming.ParameterPrefix, value: _ }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
Expand Down
28 changes: 27 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,34 @@ get aquainted with this development process.

The tool does not catch all style errors. See the [code style](#markdown-header-style-guides) section below for more information.

1. **(optional) Use clang-tidy for additional checks.**

clang-tidy should return no errors when run against the code base.

Ubuntu users can install via:

sudo apt-get install clang-tidy-6.0 # or clang-tidy-7 with LLVM PPAs

In order to run clang-tidy, CMake must be used to generate a `compliation_commands.json`, also referred to as a compilation command database. In order to generate this file, add a flag to your `cmake` invokation (or to the `--cmake-args` flag if using `colcon`)

# For CMake
mkdir build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1

# For colcon
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1

Once the database is generated, execute from the `ign-gazebo` source directory:

run-clang-tidy-6.0.py -p=./build/ -header-filter=`pwd`/include/* -j6 -quiet

Address issues that are found.

If you are feeling adventurous, you can experiment with adding additional checks to the `.clang-tidy` file by referencing the full list of options in the [clang-tidy documentation](http://clang.llvm.org/extra/clang-tidy/checks/list.html)

1. **Tests must pass.** You can check by running `make test` in
your build directory. Running tests may take a bit of time, be patient.
your build directory. Running tests may take a bit of time, be patient.

1. **Write documentation.** Document all your code. Every class, function, member variable must have doxygen comments. All code in source files must have documentation that describes the functionality. This will help reviewers and future developers.

Expand Down
16 changes: 8 additions & 8 deletions include/ignition/gazebo/Conversions.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace ignition
/// \return Conversion result.
/// \tparam OUT Output type.
template<class OUT>
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Geometry &_in)
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Geometry &_in)
{
OUT::ConversionNotImplemented;
}
Expand All @@ -52,14 +52,14 @@ namespace ignition
/// \param[in] _in SDF geometry.
/// \return Geometry message.
template<>
msgs::Geometry IGNITION_GAZEBO_VISIBLE Convert(const sdf::Geometry &_in);
msgs::Geometry IGNITION_GAZEBO_VISIBLE convert(const sdf::Geometry &_in);

/// \brief Generic conversion from an SDF material to another type.
/// \param[in] _in SDF material.
/// \return Conversion result.
/// \tparam OUT Output type.
template<class OUT>
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Material &_in)
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Material &_in)
{
OUT::ConversionNotImplemented;
}
Expand All @@ -69,14 +69,14 @@ namespace ignition
/// \param[in] _in SDF material.
/// \return Material message.
template<>
msgs::Material IGNITION_GAZEBO_VISIBLE Convert(const sdf::Material &_in);
msgs::Material IGNITION_GAZEBO_VISIBLE convert(const sdf::Material &_in);

/// \brief Generic conversion from an SDF light to another type.
/// \param[in] _in SDF light.
/// \return Conversion result.
/// \tparam OUT Output type.
template<class OUT>
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Light &_in)
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Light &_in)
{
OUT::ConversionNotImplemented;
}
Expand All @@ -86,14 +86,14 @@ namespace ignition
/// \param[in] _in SDF light.
/// \return Light message.
template<>
msgs::Light IGNITION_GAZEBO_VISIBLE Convert(const sdf::Light &_in);
msgs::Light IGNITION_GAZEBO_VISIBLE convert(const sdf::Light &_in);

/// \brief Generic conversion from an SDF gui to another type.
/// \param[in] _in SDF gui.
/// \return Conversion result.
/// \tparam OUT Output type.
template<class OUT>
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Gui &_in)
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Gui &_in)
{
OUT::ConversionNotImplemented;
}
Expand All @@ -102,7 +102,7 @@ namespace ignition
/// \param[in] _in SDF gui.
/// \return Gui message.
template<>
msgs::GUI IGNITION_GAZEBO_VISIBLE Convert(const sdf::Gui &_in);
msgs::GUI IGNITION_GAZEBO_VISIBLE convert(const sdf::Gui &_in);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using namespace gazebo;

//////////////////////////////////////////////////
template<>
msgs::Geometry ignition::gazebo::Convert(const sdf::Geometry &_in)
msgs::Geometry ignition::gazebo::convert(const sdf::Geometry &_in)
{
msgs::Geometry out;
if (_in.Type() == sdf::GeometryType::BOX && _in.BoxShape())
Expand Down Expand Up @@ -96,7 +96,7 @@ msgs::Geometry ignition::gazebo::Convert(const sdf::Geometry &_in)

//////////////////////////////////////////////////
template<>
msgs::Material ignition::gazebo::Convert(const sdf::Material &_in)
msgs::Material ignition::gazebo::convert(const sdf::Material &_in)
{
msgs::Material out;
msgs::Set(out.mutable_ambient(), _in.Ambient());
Expand All @@ -107,7 +107,7 @@ msgs::Material ignition::gazebo::Convert(const sdf::Material &_in)

//////////////////////////////////////////////////
template<>
msgs::Light ignition::gazebo::Convert(const sdf::Light &_in)
msgs::Light ignition::gazebo::convert(const sdf::Light &_in)
{
msgs::Light out;
out.set_name(_in.Name());
Expand All @@ -134,7 +134,7 @@ msgs::Light ignition::gazebo::Convert(const sdf::Light &_in)

//////////////////////////////////////////////////
template<>
msgs::GUI ignition::gazebo::Convert(const sdf::Gui &_in)
msgs::GUI ignition::gazebo::convert(const sdf::Gui &_in)
{
msgs::GUI out;

Expand Down
4 changes: 2 additions & 2 deletions src/Conversions_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST(Conversions, Light)
light.SetSpotFalloff(0.9);

msgs::Light lightMsg;
lightMsg = Convert<msgs::Light>(light);
lightMsg = convert<msgs::Light>(light);
EXPECT_EQ("test_convert_light", lightMsg.name());
EXPECT_EQ(msgs::Light_LightType_DIRECTIONAL, lightMsg.type());
EXPECT_EQ(math::Pose3d(3, 2, 1, 0, IGN_PI, 0),
Expand Down Expand Up @@ -95,7 +95,7 @@ TEST(Conversions, Gui)
auto gui = world->Gui();
ASSERT_NE(nullptr, gui);

auto guiMsg = Convert<msgs::GUI>(*gui);
auto guiMsg = convert<msgs::GUI>(*gui);
EXPECT_TRUE(guiMsg.fullscreen());
ASSERT_EQ(2, guiMsg.plugin_size());

Expand Down
Loading

0 comments on commit e494d26

Please sign in to comment.