jsk-ros-pkg / jsk_aerial_robot

The platfrom for aerial robot (e.g. general multirotor, hydrus, di, dragon, etc)
http://www.jsk.t.u-tokyo.ac.jp/index-j.html
34 stars 34 forks source link

Add pre-commit fomatter #564

Closed Li-Jinjie closed 1 year ago

Li-Jinjie commented 1 year ago

What is this

This PR introduces a plugin, pre-commit, which can check coding styles and format the code automatically.

I have formatted aerial_robot_base folder as an example.

Details

To install, please read doc in ./docs folder. In general, there are only two commands needed to be executed.

    pip install pre-commit
    pre-commit install

Then this plugin will automatically triggered before each commit. I have included several check items inside the .pre-commit-config.yaml. Now I use black to format Python code and clang to format C++.

If the commit cannot pass the check, just run commit again. The plugin will format the code automatically and then the second commit will pass.

After discussion, change the code style back to Google style, except that line width = 120.

tongtybj commented 1 year ago

@Li-Jinjie

This PR involves so many changes in existing files. I am afraid that it will broke the backward compatiblity. Maybe we can correct format for all files when we decide to shift to 2.0.0.