Skip to content

Commit 407ee41

Browse files
authored
Merge pull request #5584 from gnawme/norm.evangelisat/add-readability-checks
Added initial set of readability-* clang-tidy checks
2 parents aa7c679 + ad7a7a8 commit 407ee41

File tree

23 files changed

+93
-104
lines changed

23 files changed

+93
-104
lines changed

.clang-tidy

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
---
2-
Checks: '-*,modernize-use-auto,modernize-deprecated-headers,modernize-redundant-void-arg,modernize-replace-random-shuffle,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-nullptr,modernize-use-override,modernize-use-using,performance-faster-string-find,performance-for-range-copy,performance-implicit-conversion-in-loop,performance-inefficient-algorithm,performance-inefficient-vector-operation,performance-move-const-arg,performance-move-constructor-init,performance-no-automatic-move,performance-noexcept-move-constructor,performance-type-promotion-in-math-fn,cppcoreguidelines-pro-type-cstyle-cast,cppcoreguidelines-pro-type-static-cast-downcast,google-readability-casting'
3-
WarningsAsErrors: '-*,modernize-use-auto,modernize-deprecated-headers,modernize-redundant-void-arg,modernize-replace-random-shuffle,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-nullptr,modernize-use-override,modernize-use-using,performance-faster-string-find,performance-for-range-copy,performance-implicit-conversion-in-loop,performance-inefficient-algorithm,performance-inefficient-vector-operation,performance-move-const-arg,performance-move-constructor-init,performance-no-automatic-move,performance-noexcept-move-constructor,performance-type-promotion-in-math-fn,cppcoreguidelines-pro-type-cstyle-cast,cppcoreguidelines-pro-type-static-cast-downcast,google-readability-casting'
2+
Checks: >
3+
-*,
4+
cppcoreguidelines-pro-type-cstyle-cast,
5+
cppcoreguidelines-pro-type-static-cast-downcast,
6+
google-readability-casting,
7+
modernize-deprecated-headers,
8+
modernize-redundant-void-arg,
9+
modernize-replace-random-shuffle,
10+
modernize-use-auto,
11+
modernize-use-equals-default,
12+
modernize-use-equals-delete,
13+
modernize-use-nullptr,
14+
modernize-use-override,
15+
modernize-use-using,
16+
performance-faster-string-find,
17+
performance-for-range-copy,
18+
performance-implicit-conversion-in-loop,
19+
performance-inefficient-algorithm,
20+
performance-inefficient-vector-operation,
21+
performance-move-const-arg,
22+
performance-move-constructor-init,
23+
performance-no-automatic-move,
24+
performance-noexcept-move-constructor,
25+
performance-type-promotion-in-math-fn,
26+
readability-container-size-empty,
27+
readability-delete-null-pointer,
28+
readability-duplicate-include,
29+
readability-redundant-declaration,
30+
readability-redundant-smartptr-get,
31+
readability-redundant-string-cstr,
32+
readability-redundant-string-init,
33+
readability-simplify-boolean-expr,
34+
readability-simplify-subscript-expr,
35+
WarningsAsErrors: '*'
436
CheckOptions:
537
- {key: modernize-use-auto.MinTypeNameLength, value: 7}
38+
UseColor: true

common/include/pcl/PolygonMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace pcl
3232
const auto point_offset = mesh1.cloud.width * mesh1.cloud.height;
3333

3434
bool success = pcl::PCLPointCloud2::concatenate(mesh1.cloud, mesh2.cloud);
35-
if (success == false) {
35+
if (!success) {
3636
return false;
3737
}
3838
// Make the resultant polygon mesh take the newest stamp

common/src/io.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ pcl::concatenateFields (const pcl::PCLPointCloud2 &cloud1,
201201
point_offset += field_offset;
202202
}
203203

204-
if (!cloud1.is_dense || !cloud2.is_dense)
205-
cloud_out.is_dense = false;
206-
else
207-
cloud_out.is_dense = true;
204+
cloud_out.is_dense = cloud1.is_dense && cloud2.is_dense;
208205

209206
return (true);
210207
}

features/include/pcl/features/impl/brisk_2d.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ BRISK2DEstimation<PointInT, PointOutT, KeypointT, IntensityT>::compute (
564564
int* pvalues = values;
565565
const float& x = (kp.x);
566566
const float& y = (kp.y);
567+
// NOLINTNEXTLINE(readability-simplify-boolean-expr)
567568
if (true) // kp.angle==-1
568569
{
569570
if (!rotation_invariance_enabled_)

features/include/pcl/features/impl/range_image_border_extractor.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,7 @@ bool RangeImageBorderExtractor::calculateMainPrincipalCurvature(int x, int y, in
334334
bool& beam_valid = beams_valid[beam_idx++];
335335
if (step==1)
336336
{
337-
if (x2==x && y2==y)
338-
beam_valid = false;
339-
else
340-
beam_valid = true;
337+
beam_valid = !(x2==x && y2==y);
341338
}
342339
else
343340
if (!beam_valid)

filters/include/pcl/filters/impl/conditional_removal.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ pcl::ConditionalRemoval<PointT>::setCondition (ConditionBasePtr condition)
624624
template <typename PointT> void
625625
pcl::ConditionalRemoval<PointT>::applyFilter (PointCloud &output)
626626
{
627-
if (capable_ == false)
627+
if (!capable_)
628628
{
629629
PCL_WARN ("[pcl::%s::applyFilter] not capable!\n", getClassName ().c_str ());
630630
return;

filters/include/pcl/filters/impl/radius_outlier_removal.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ pcl::RadiusOutlierRemoval<PointT>::applyFilterIndices (Indices &indices)
109109
}
110110
else
111111
{
112-
if (negative_)
113-
chk_neighbors = true;
114-
else
115-
chk_neighbors = false;
112+
chk_neighbors = negative_;
116113
}
117114

118115
// Points having too few neighbors are outliers and are passed to removed indices

filters/include/pcl/filters/passthrough.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ namespace pcl
9797
*/
9898
PassThrough (bool extract_removed_indices = false) :
9999
FilterIndices<PointT> (extract_removed_indices),
100-
filter_field_name_ (""),
100+
101101
filter_limit_min_ (std::numeric_limits<float>::lowest()),
102102
filter_limit_max_ (std::numeric_limits<float>::max())
103103
{
@@ -212,8 +212,8 @@ namespace pcl
212212
public:
213213
/** \brief Constructor. */
214214
PassThrough (bool extract_removed_indices = false) :
215-
FilterIndices<pcl::PCLPointCloud2>::FilterIndices (extract_removed_indices), filter_field_name_("")
216-
, filter_limit_min_(std::numeric_limits<float>::lowest())
215+
FilterIndices<pcl::PCLPointCloud2>::FilterIndices (extract_removed_indices),
216+
filter_limit_min_(std::numeric_limits<float>::lowest())
217217
, filter_limit_max_(std::numeric_limits<float>::max())
218218
{
219219
filter_name_ = "PassThrough";

filters/include/pcl/filters/voxel_grid.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ namespace pcl
202202
max_b_ (Eigen::Vector4i::Zero ()),
203203
div_b_ (Eigen::Vector4i::Zero ()),
204204
divb_mul_ (Eigen::Vector4i::Zero ()),
205-
filter_field_name_ (""),
205+
206206
filter_limit_min_ (std::numeric_limits<float>::lowest()),
207207
filter_limit_max_ (std::numeric_limits<float>::max()),
208208
filter_limit_negative_ (false),
@@ -528,7 +528,7 @@ namespace pcl
528528
max_b_ (Eigen::Vector4i::Zero ()),
529529
div_b_ (Eigen::Vector4i::Zero ()),
530530
divb_mul_ (Eigen::Vector4i::Zero ()),
531-
filter_field_name_ (""),
531+
532532
filter_limit_min_ (std::numeric_limits<float>::lowest()),
533533
filter_limit_max_ (std::numeric_limits<float>::max()),
534534
filter_limit_negative_ (false),

io/src/openni2/openni2_device.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pcl::io::openni2::OpenNI2Device::getStringID () const
163163
bool
164164
pcl::io::openni2::OpenNI2Device::isValid () const
165165
{
166-
return (openni_device_.get () != nullptr) && openni_device_->isValid ();
166+
return (openni_device_ != nullptr) && openni_device_->isValid ();
167167
}
168168

169169
float
@@ -332,7 +332,7 @@ pcl::io::openni2::OpenNI2Device::stopAllStreams ()
332332
void
333333
pcl::io::openni2::OpenNI2Device::stopIRStream ()
334334
{
335-
if (ir_video_stream_.get () != nullptr)
335+
if (ir_video_stream_ != nullptr)
336336
{
337337
ir_video_stream_->stop ();
338338
ir_video_started_ = false;
@@ -341,7 +341,7 @@ pcl::io::openni2::OpenNI2Device::stopIRStream ()
341341
void
342342
pcl::io::openni2::OpenNI2Device::stopColorStream ()
343343
{
344-
if (color_video_stream_.get () != nullptr)
344+
if (color_video_stream_ != nullptr)
345345
{
346346
color_video_stream_->stop ();
347347
color_video_started_ = false;
@@ -350,7 +350,7 @@ pcl::io::openni2::OpenNI2Device::stopColorStream ()
350350
void
351351
pcl::io::openni2::OpenNI2Device::stopDepthStream ()
352352
{
353-
if (depth_video_stream_.get () != nullptr)
353+
if (depth_video_stream_ != nullptr)
354354
{
355355
depth_video_stream_->stop ();
356356
depth_video_started_ = false;
@@ -360,13 +360,13 @@ pcl::io::openni2::OpenNI2Device::stopDepthStream ()
360360
void
361361
pcl::io::openni2::OpenNI2Device::shutdown ()
362362
{
363-
if (ir_video_stream_.get () != nullptr)
363+
if (ir_video_stream_ != nullptr)
364364
ir_video_stream_->destroy ();
365365

366-
if (color_video_stream_.get () != nullptr)
366+
if (color_video_stream_ != nullptr)
367367
color_video_stream_->destroy ();
368368

369-
if (depth_video_stream_.get () != nullptr)
369+
if (depth_video_stream_ != nullptr)
370370
depth_video_stream_->destroy ();
371371

372372
}
@@ -747,7 +747,7 @@ bool OpenNI2Device::setPlaybackSpeed (double speed)
747747
std::shared_ptr<openni::VideoStream>
748748
pcl::io::openni2::OpenNI2Device::getIRVideoStream () const
749749
{
750-
if (ir_video_stream_.get () == nullptr)
750+
if (ir_video_stream_ == nullptr)
751751
{
752752
if (hasIRSensor ())
753753
{
@@ -764,7 +764,7 @@ pcl::io::openni2::OpenNI2Device::getIRVideoStream () const
764764
std::shared_ptr<openni::VideoStream>
765765
pcl::io::openni2::OpenNI2Device::getColorVideoStream () const
766766
{
767-
if (color_video_stream_.get () == nullptr)
767+
if (color_video_stream_ == nullptr)
768768
{
769769
if (hasColorSensor ())
770770
{
@@ -781,7 +781,7 @@ pcl::io::openni2::OpenNI2Device::getColorVideoStream () const
781781
std::shared_ptr<openni::VideoStream>
782782
pcl::io::openni2::OpenNI2Device::getDepthVideoStream () const
783783
{
784-
if (depth_video_stream_.get () == nullptr)
784+
if (depth_video_stream_ == nullptr)
785785
{
786786
if (hasDepthSensor ())
787787
{

0 commit comments

Comments
 (0)