Skip to content

Commit e494d26

Browse files
committed
Change function naming, add documentation.
1 parent 804e9cd commit e494d26

16 files changed

+135
-121
lines changed

.clang-tidy

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Checks: '-*,bugprone-*,modernize-*,performance-*,-modernize-use-equals-delete,-m
22
CheckOptions:
33
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
44
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
5-
- { key: readability-identifier-naming.StructCase, value: CamelCase }
5+
- { key: readability-identifier-naming.GlobalFunctionCase, value: camelBack }
6+
- { key: readability-identifier-naming.StructCase, value: CamelCase }
67
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
78
- { key: readability-identifier-naming.ParameterPrefix, value: _ }
89
- { key: readability-identifier-naming.VariableCase, value: camelBack }

CONTRIBUTING.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,34 @@ get aquainted with this development process.
202202

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

205+
1. **(optional) Use clang-tidy for additional checks.**
206+
207+
clang-tidy should return no errors when run against the code base.
208+
209+
Ubuntu users can install via:
210+
211+
sudo apt-get install clang-tidy-6.0 # or clang-tidy-7 with LLVM PPAs
212+
213+
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`)
214+
215+
# For CMake
216+
mkdir build
217+
cd build
218+
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1
219+
220+
# For colcon
221+
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1
222+
223+
Once the database is generated, execute from the `ign-gazebo` source directory:
224+
225+
run-clang-tidy-6.0.py -p=./build/ -header-filter=`pwd`/include/* -j6 -quiet
226+
227+
Address issues that are found.
228+
229+
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)
230+
205231
1. **Tests must pass.** You can check by running `make test` in
206-
your build directory. Running tests may take a bit of time, be patient.
232+
your build directory. Running tests may take a bit of time, be patient.
207233

208234
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.
209235

include/ignition/gazebo/Conversions.hh

+8-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace ignition
4242
/// \return Conversion result.
4343
/// \tparam OUT Output type.
4444
template<class OUT>
45-
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Geometry &_in)
45+
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Geometry &_in)
4646
{
4747
OUT::ConversionNotImplemented;
4848
}
@@ -52,14 +52,14 @@ namespace ignition
5252
/// \param[in] _in SDF geometry.
5353
/// \return Geometry message.
5454
template<>
55-
msgs::Geometry IGNITION_GAZEBO_VISIBLE Convert(const sdf::Geometry &_in);
55+
msgs::Geometry IGNITION_GAZEBO_VISIBLE convert(const sdf::Geometry &_in);
5656

5757
/// \brief Generic conversion from an SDF material to another type.
5858
/// \param[in] _in SDF material.
5959
/// \return Conversion result.
6060
/// \tparam OUT Output type.
6161
template<class OUT>
62-
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Material &_in)
62+
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Material &_in)
6363
{
6464
OUT::ConversionNotImplemented;
6565
}
@@ -69,14 +69,14 @@ namespace ignition
6969
/// \param[in] _in SDF material.
7070
/// \return Material message.
7171
template<>
72-
msgs::Material IGNITION_GAZEBO_VISIBLE Convert(const sdf::Material &_in);
72+
msgs::Material IGNITION_GAZEBO_VISIBLE convert(const sdf::Material &_in);
7373

7474
/// \brief Generic conversion from an SDF light to another type.
7575
/// \param[in] _in SDF light.
7676
/// \return Conversion result.
7777
/// \tparam OUT Output type.
7878
template<class OUT>
79-
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Light &_in)
79+
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Light &_in)
8080
{
8181
OUT::ConversionNotImplemented;
8282
}
@@ -86,14 +86,14 @@ namespace ignition
8686
/// \param[in] _in SDF light.
8787
/// \return Light message.
8888
template<>
89-
msgs::Light IGNITION_GAZEBO_VISIBLE Convert(const sdf::Light &_in);
89+
msgs::Light IGNITION_GAZEBO_VISIBLE convert(const sdf::Light &_in);
9090

9191
/// \brief Generic conversion from an SDF gui to another type.
9292
/// \param[in] _in SDF gui.
9393
/// \return Conversion result.
9494
/// \tparam OUT Output type.
9595
template<class OUT>
96-
OUT IGNITION_GAZEBO_VISIBLE Convert(const sdf::Gui &_in)
96+
OUT IGNITION_GAZEBO_VISIBLE convert(const sdf::Gui &_in)
9797
{
9898
OUT::ConversionNotImplemented;
9999
}
@@ -102,7 +102,7 @@ namespace ignition
102102
/// \param[in] _in SDF gui.
103103
/// \return Gui message.
104104
template<>
105-
msgs::GUI IGNITION_GAZEBO_VISIBLE Convert(const sdf::Gui &_in);
105+
msgs::GUI IGNITION_GAZEBO_VISIBLE convert(const sdf::Gui &_in);
106106
}
107107
}
108108
}

src/Conversions.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ using namespace gazebo;
4747

4848
//////////////////////////////////////////////////
4949
template<>
50-
msgs::Geometry ignition::gazebo::Convert(const sdf::Geometry &_in)
50+
msgs::Geometry ignition::gazebo::convert(const sdf::Geometry &_in)
5151
{
5252
msgs::Geometry out;
5353
if (_in.Type() == sdf::GeometryType::BOX && _in.BoxShape())
@@ -96,7 +96,7 @@ msgs::Geometry ignition::gazebo::Convert(const sdf::Geometry &_in)
9696

9797
//////////////////////////////////////////////////
9898
template<>
99-
msgs::Material ignition::gazebo::Convert(const sdf::Material &_in)
99+
msgs::Material ignition::gazebo::convert(const sdf::Material &_in)
100100
{
101101
msgs::Material out;
102102
msgs::Set(out.mutable_ambient(), _in.Ambient());
@@ -107,7 +107,7 @@ msgs::Material ignition::gazebo::Convert(const sdf::Material &_in)
107107

108108
//////////////////////////////////////////////////
109109
template<>
110-
msgs::Light ignition::gazebo::Convert(const sdf::Light &_in)
110+
msgs::Light ignition::gazebo::convert(const sdf::Light &_in)
111111
{
112112
msgs::Light out;
113113
out.set_name(_in.Name());
@@ -134,7 +134,7 @@ msgs::Light ignition::gazebo::Convert(const sdf::Light &_in)
134134

135135
//////////////////////////////////////////////////
136136
template<>
137-
msgs::GUI ignition::gazebo::Convert(const sdf::Gui &_in)
137+
msgs::GUI ignition::gazebo::convert(const sdf::Gui &_in)
138138
{
139139
msgs::GUI out;
140140

src/Conversions_TEST.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ TEST(Conversions, Light)
5151
light.SetSpotFalloff(0.9);
5252

5353
msgs::Light lightMsg;
54-
lightMsg = Convert<msgs::Light>(light);
54+
lightMsg = convert<msgs::Light>(light);
5555
EXPECT_EQ("test_convert_light", lightMsg.name());
5656
EXPECT_EQ(msgs::Light_LightType_DIRECTIONAL, lightMsg.type());
5757
EXPECT_EQ(math::Pose3d(3, 2, 1, 0, IGN_PI, 0),
@@ -95,7 +95,7 @@ TEST(Conversions, Gui)
9595
auto gui = world->Gui();
9696
ASSERT_NE(nullptr, gui);
9797

98-
auto guiMsg = Convert<msgs::GUI>(*gui);
98+
auto guiMsg = convert<msgs::GUI>(*gui);
9999
EXPECT_TRUE(guiMsg.fullscreen());
100100
ASSERT_EQ(2, guiMsg.plugin_size());
101101

0 commit comments

Comments
 (0)