3

I'm working on a PR for rclcpp, and when I run the tests, I get formatting errors about white space from cpplint. Is there any automated way to fix these? Here is an example:

- rclcpp.cpplint whitespace/comments [2] (/home/tyler/code/ws_ros2/src/rclcpp/rclcpp/include/rclcpp/subscription_options.hpp:188)
  <<< failure message
    At least two spaces is best between code and comments
  >>>
Rufus
  • 466
  • 1
  • 5
  • 9
  • what does this have to do with robotics? ... ensure that you format your code properly ... comments are not part of the code ... separate them by a wide margin – jsotola Nov 12 '22 at 20:45
  • 3
    I'm not asking what the rule is but if there is automated tooling for this.

    On if this is relevant to robotics I had that same thought so I posted here and was told yes, this is the right place for this question: https://discourse.ros.org/t/planned-migration-of-ros-answers-and-gazebo-answers-to-robotics-stack-exchange/28068/23

    – Tyler Weaver Nov 12 '22 at 22:18

1 Answers1

3

Recently, I've had some success running ament_uncrustify --reformat for fixing issues found by ament_cpplint, since these tools (largely) agree.

Not the answer I like, but ament_cpplint has no similar option unfortunately.

Loy
  • 105
  • 2
  • These errors showed up after running uncrustify. For me to use a formatting tool on my project table-stakes is that it can format the files itself according to its rule set. I was hoping that cpplint had some hidden auto-format feature I couldn't find. – Tyler Weaver Nov 14 '22 at 18:25
  • Hmm, too bad. I also hoped for the same. – Loy Nov 15 '22 at 09:26
  • There's no auto-support for Cpplint, I do the same thing @loy suggested. I run uncrustify to resolve the bulk and then cpplint for the rest. Though after a couple of months using these linters you should get to a point where you know the rules and rarely need to fix anything. – Steve Macenski Nov 17 '22 at 01:08
  • This is a sad state of affairs when clang-format is right there. – Tyler Weaver Dec 22 '22 at 21:51