Skip to content

Added new bugprone-* and readability-* clang-tidy checks#6363

Merged
larshg merged 9 commits intoPointCloudLibrary:masterfrom
gnawme:norm.evangelista/new-bugprone-readability-checks
Nov 16, 2025
Merged

Added new bugprone-* and readability-* clang-tidy checks#6363
larshg merged 9 commits intoPointCloudLibrary:masterfrom
gnawme:norm.evangelista/new-bugprone-readability-checks

Conversation

@gnawme
Copy link
Copy Markdown
Contributor

@gnawme gnawme commented Nov 5, 2025

Added new clang-tidy checks:

  1. bugprone-unhandled-self-assignment
  2. bugprone-unused-raii
  3. bugprone-use-after-move
  4. readability-make-member-function-const

Ran on Ubuntu 24.04 with this CMake configuration:

  cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
        -DCMAKE_CXX_COMPILER=clang-18 \
        -DCMAKE_C_COMPILER=clang-18 \
        -DBUILD_benchmarks=OFF \
        -DBUILD_examples=ON \
        -DBUILD_simulation=ON \
        -DBUILD_global_tests=ON ..

@gnawme gnawme force-pushed the norm.evangelista/new-bugprone-readability-checks branch from 5519e34 to 550239f Compare November 5, 2025 17:25
- 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)
@gnawme gnawme force-pushed the norm.evangelista/new-bugprone-readability-checks branch from 550239f to b40a7c3 Compare November 5, 2025 18:58
@larshg larshg added this to the pcl-1.16.0 milestone Nov 13, 2025
@larshg larshg added changelog: enhancement Meta-information for changelog generation module: ci labels Nov 13, 2025
@larshg larshg requested a review from Copilot November 13, 2025 06:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds four new clang-tidy checks to the project's configuration and applies the corresponding fixes throughout the codebase. The changes are systematic and address common code quality issues.

Key Changes

  • Added bugprone checks for unhandled self-assignment, unused RAII objects, and use-after-move scenarios
  • Added readability check to identify member functions that can be marked const
  • Applied fixes throughout the codebase including self-assignment guards in copy assignment operators, const qualifiers on getter/setter methods, and removal of an unused RAII object

Reviewed Changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
.clang-tidy Added four new clang-tidy checks: bugprone-unhandled-self-assignment, bugprone-unused-raii, bugprone-use-after-move, and readability-make-member-function-const
visualization/src/window.cpp Added self-assignment check to Window copy assignment operator
visualization/include/pcl/visualization/pcl_visualizer.h Reformatted and added self-assignment check to FPSCallback assignment operator
tools/ply2raw.cpp Added self-assignment check to ply_to_raw_converter assignment operator
simulation/src/glsl_shader.cpp Added const qualifier to multiple setUniform overloads and addShaderFile method
simulation/include/pcl/simulation/glsl_shader.h Added const qualifier to method declarations matching implementation changes
segmentation/include/pcl/segmentation/grabcut_segmentation.h Made getEpsilon() const
registration/include/pcl/registration/transformation_estimation_point_to_plane_weighted.h Added self-assignment checks to three assignment operators
registration/include/pcl/registration/transformation_estimation_lm.h Added self-assignment checks to three assignment operators
registration/include/pcl/registration/joint_icp.h Fixed unused RAII by removing unnecessary base class constructor call
recognition/include/pcl/recognition/ransac_based/rigid_transform_space.h Added self-assignment check to Entry assignment operator
outofcore/include/pcl/outofcore/outofcore_iterator_base.h Added self-assignment check and missing return statement to assignment operator
octree/include/pcl/octree/octree_pointcloud_density.h Made getPointCounter() const
octree/include/pcl/octree/octree_base.h Added self-assignment check to OctreeBase assignment operator
octree/include/pcl/octree/octree2buf_base.h Added self-assignment check to Octree2BufBase assignment operator
keypoints/include/pcl/keypoints/agast_2d.h Made getThreshold() and getMaxKeypoints() const
kdtree/include/pcl/kdtree/kdtree_flann.h Added self-assignment check to KdTreeFLANN assignment operator
io/src/openni2/openni2_device.cpp Added const qualifier to multiple getter methods
io/src/hdl_grabber.cpp Made distance threshold getters const
io/src/ensenso_grabber.cpp Removed trailing whitespace and made several methods const
io/include/pcl/io/ply_io.h Added self-assignment check to PLYReader assignment operator
io/include/pcl/io/openni2/openni2_device.h Updated method declarations to match const implementation
io/include/pcl/io/hdl_grabber.h Updated getter method declarations to const
io/include/pcl/io/ensenso_grabber.h Removed trailing whitespace and updated method declarations to const
filters/include/pcl/filters/statistical_outlier_removal.h Made getter methods const and removed trailing whitespace
filters/include/pcl/filters/random_sample.h Made getSample() and getSeed() const in both filter variants
filters/include/pcl/filters/radius_outlier_removal.h Made getter methods const in both filter variants
filters/include/pcl/filters/conditional_removal.h Added self-assignment check to FieldComparison assignment operator
filters/include/pcl/filters/approximate_voxel_grid.h Added self-assignment check to ApproximateVoxelGrid assignment operator
features/src/narf.cpp Added self-assignment check to Narf assignment operator
common/include/pcl/common/bivariate_polynomial.h Reformatted and added self-assignment check to BivariatePolynomialT assignment operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gnawme
Copy link
Copy Markdown
Contributor Author

gnawme commented Nov 14, 2025

The major C++ style guides are unanimous in preferring

if (this == &src)
  return (*this);

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Nov 15, 2025

The major C++ style guides are unanimous in preferring

if (this == &src)
  return (*this);

Why didn't you add parentheses then? I think PCL alao does this mostly?

@gnawme
Copy link
Copy Markdown
Contributor Author

gnawme commented Nov 15, 2025

The major C++ style guides are unanimous in preferring

if (this == &src)
  return (*this);

Why didn't you add parentheses then? I think PCL alao does this mostly?

Crap, I meant exactly the opposite:

if (this == &src)
  return *this;

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Nov 15, 2025

The major C++ style guides are unanimous in preferring

if (this == &src)
  return (*this);

Why didn't you add parentheses then? I think PCL alao does this mostly?

Crap, I meant exactly the opposite:

if (this == &src)
  return *this;

Heh okay. Yeah, from what I could find I agree. Do you have some good links?

@gnawme
Copy link
Copy Markdown
Contributor Author

gnawme commented Nov 15, 2025

The major C++ style guides are unanimous in preferring

if (this == &src)
  return (*this);

Why didn't you add parentheses then? I think PCL alao does this mostly?

Crap, I meant exactly the opposite:

if (this == &src)
  return *this;

Heh okay. Yeah, from what I could find I agree. Do you have some good links?

Style Guides:

return *this; is what you'll find in ~90% of modern C++ codebases and all standard library implementations.

Copy link
Copy Markdown
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@larshg larshg merged commit 3f9ab3a into PointCloudLibrary:master Nov 16, 2025
11 of 13 checks passed
@gnawme gnawme deleted the norm.evangelista/new-bugprone-readability-checks branch November 17, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Meta-information for changelog generation module: ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants