uwreact / frc_control

ROS metapackage enabling FRC teams to use ROS on their robots
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Add clang-tidy #42

Closed matthew-reynolds closed 5 years ago

matthew-reynolds commented 5 years ago

Pull Request

Closes #37. Adds a clang-tidy config file, as well as a wrapper to easily use clang-tidy in a catkin workspace. Default behaviour is to generate a file for each package of the requested changes in workspace/clang-tidy-fixes. For example, workspace/clang-tidy-fixes/package1_fixes. If the -f option is specified, the tool will automatically attempt to fix the issues it encounters. This behaviour is not the default since although clang-tidy is great at finding and describing errors, it can often do a poor job of fixing issues itself.

~TODO: Still need to add ability to blacklist/whitelist packages, since currently all packages in the workspace will be tidied.~ Added in d85d37b. Syntax: run_clang_tidy.py [packages...]. If no packages are specified, all packages in the workspace are tidied. Is able to handle metapackages.

~TODO: Need to add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON and maybe -DCMAKE_CXX_CLANG_TIDY=clang-tidy-7 to catkin config~ Added in b8144ad

Full help text:

usage: run_clang_tidy.py [-h] [-f] [-j JOBS] [-q] [-v]
                         [packages [packages ...]]

Wrapper for running clang-tidy on a catkin workspace.

positional arguments:
  packages              List of packages to tidy

optional arguments:
  -h, --help            show this help message and exit
  -f, --fix             Attempt to automatically fix issues
  -j JOBS, --jobs JOBS  Number of packages to tidy concurrently (default=4)
  -q, --quiet           Do not produce any stdout output
  -v, --verbose         Output generated changefiles to stdout

Note: In order for clang-tidy to understand which files to tidy, the workspace
must be built with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON.

Contribution Checklist

Change Checklist

matthew-reynolds commented 5 years ago

Added ability to specify packages, updated description

matthew-reynolds commented 5 years ago

Improved tool description, added compiler options to default catkin configs

matthew-reynolds commented 5 years ago

@michaelwm @wmmc88 Ready for review