Skip to content

Commit 3f9ab3a

Browse files
authored
Added new bugprone-* and readability-* clang-tidy checks (#6363)
* Added readability-make-member-function-const fixes * Implemented flagged bugprone-unhandled-self-assignment fixes * Apply clang-tidy fixes for bugprone and readability checks - Add self-assignment checks to 13 operator= methods (bugprone-unhandled-self-assignment) - Add const qualifiers to 12 getter methods (readability-make-member-function-const) - Remove unused RAII temporary in JointIterativeClosestPoint constructor (bugprone-unused-raii) * Fixed clang-tidy escapes * Fixed yet more clang-tidy escapes * Reverted inadvertent reformatting * Harmonized clang-tidy changes between header and source * Standardized on most common return *this for self-assignment * Reverted *this to (*this) in places that needed parentheses
1 parent e5ce18f commit 3f9ab3a

File tree

63 files changed

+205
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+205
-154
lines changed

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Checks: >
33
-*,
44
bugprone-copy-constructor-init,
55
bugprone-macro-parentheses,
6+
bugprone-unhandled-self-assignment,
7+
bugprone-unused-raii,
8+
bugprone-use-after-move,
69
cppcoreguidelines-pro-type-cstyle-cast,
710
cppcoreguidelines-pro-type-static-cast-downcast,
811
google-readability-casting,
@@ -37,6 +40,7 @@ Checks: >
3740
readability-container-size-empty,
3841
readability-delete-null-pointer,
3942
readability-duplicate-include,
43+
readability-make-member-function-const,
4044
readability-redundant-declaration,
4145
readability-redundant-smartptr-get,
4246
readability-redundant-string-cstr,

apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/command.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ class Command {
8989
operator=(const Command&)
9090
{
9191
assert(false);
92-
return (*this);
92+
return *this;
9393
}
9494
};

apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/commandQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CommandQueue {
101101
operator=(const CommandQueue&)
102102
{
103103
assert(false);
104-
return (*this);
104+
return *this;
105105
}
106106

107107
/// @brief Enforces the depth limit of the command queue. If the depth is

apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/statistics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Statistics {
7070
operator=(const Statistics&)
7171
{
7272
assert(false);
73-
return (*this);
73+
return *this;
7474
}
7575

7676
/// @brief Returns the statistics in string.

apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/toolInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ class ToolInterface {
107107
operator=(const ToolInterface&)
108108
{
109109
assert(false);
110-
return (*this);
110+
return *this;
111111
}
112112
};

apps/point_cloud_editor/src/cloud.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Cloud::operator= (const Cloud &cloud)
137137
select_translate_x_ = cloud.select_translate_x_;
138138
select_translate_y_ = cloud.select_translate_y_;
139139
select_translate_z_ = cloud.select_translate_z_;
140-
return (*this);
140+
return *this;
141141
}
142142

143143
Point3D&

apps/point_cloud_editor/src/selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Selection::operator= (const Selection& selection)
4848
{
4949
cloud_ptr_ = selection.cloud_ptr_;
5050
selected_indices_ = selection.selected_indices_;
51-
return (*this);
51+
return *this;
5252
}
5353

5454
void

common/include/pcl/PolygonMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace pcl
7979
operator += (const PolygonMesh& rhs)
8080
{
8181
concatenate((*this), rhs);
82-
return (*this);
82+
return *this;
8383
}
8484

8585
/** \brief Add a polygon mesh to another mesh.

common/include/pcl/common/bivariate_polynomial.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ namespace pcl
6464
//-----OPERATORS-----
6565
/** = operator */
6666
BivariatePolynomialT&
67-
operator= (const BivariatePolynomialT& other) { deepCopy (other); return *this;}
67+
operator= (const BivariatePolynomialT& other)
68+
{
69+
if (this == &other)
70+
return *this;
71+
deepCopy (other);
72+
return *this;
73+
}
6874

6975
//-----METHODS-----
7076
/** Initialize members to default values */

common/include/pcl/common/pca.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace pcl
113113
coefficients_ = pca.coefficients_;
114114
eigenvalues_ = pca.eigenvalues_;
115115
mean_ = pca.mean_;
116-
return (*this);
116+
return *this;
117117
}
118118

119119
/** \brief Provide a pointer to the input dataset

0 commit comments

Comments
 (0)