Skip to content

Commit

Permalink
feat: add autoware_lint_common (autowarefoundation#2)
Browse files Browse the repository at this point in the history
Signed-off-by: Kenji Miyake <[email protected]>
Signed-off-by: 1222-takeshi <[email protected]>
  • Loading branch information
1222-takeshi authored and youtalk committed May 1, 2024
1 parent d12e1e6 commit b1ad864
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.5)

project(autoware_lint_common NONE)

find_package(ament_cmake_core REQUIRED)
find_package(ament_cmake_export_dependencies REQUIRED)
find_package(ament_cmake_test REQUIRED)

ament_package_xml()
ament_export_dependencies(${${PROJECT_NAME}_EXEC_DEPENDS})
ament_package()
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# autoware_lint_common

A custom version of [ament_lint_common](https://github.com/ament/ament_lint/tree/master/ament_lint_common) for [Autoware](https://www.autoware.org/).

## Usage

Add dependencies of `ament_lint_auto` and `autoware_lint_common` to your package as below.

`package.xml`:

```xml
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>
```

`CMakeLists.txt`:

```cmake
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
```

Then, the following linters will run during `colcon test`.

- [ament_cmake_copyright](https://github.com/ament/ament_lint/blob/master/ament_cmake_copyright/doc/index.rst)
- [ament_cmake_cppcheck](https://github.com/ament/ament_lint/blob/master/ament_cmake_cppcheck/doc/index.rst)
- [ament_cmake_lint_cmake](https://github.com/ament/ament_lint/blob/master/ament_cmake_lint_cmake/doc/index.rst)
- [ament_cmake_xmllint](https://github.com/ament/ament_lint/blob/master/ament_cmake_xmllint/doc/index.rst)

## Design

The original `ament_lint_common` contains other formatters/linters like `ament_cmake_uncrustify`, `ament_cmake_cpplint` and `ament_cmake_flake8`.
However, we don't include them because it's more useful to run them with `pre-commit` as [MoveIt](https://github.com/ros-planning/moveit2) does.

For example, the benefits are:

- We can use any version of tools independent of ament's version.
- We can easily integrate into IDE.
- We can easily check all the files in the repository without writing `test_depend` in each package.
- We can run formatters/linters without building, which makes error detection faster.

Ideally, we think other linters should be moved to `pre-commit` as well, so we'll try to support them in the future.
25 changes: 25 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>autoware_lint_common</name>
<version>0.1.0</version>
<description>The list of commonly used linters in Autoware</description>
<maintainer email="[email protected]">Kenji Miyake</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_core</buildtool_depend>
<buildtool_depend>ament_cmake_export_dependencies</buildtool_depend>
<buildtool_depend>ament_cmake_test</buildtool_depend>

<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
<buildtool_export_depend>ament_cmake_test</buildtool_export_depend>

<exec_depend>ament_cmake_copyright</exec_depend>
<exec_depend>ament_cmake_cppcheck</exec_depend>
<exec_depend>ament_cmake_lint_cmake</exec_depend>
<exec_depend>ament_cmake_xmllint</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>

0 comments on commit b1ad864

Please sign in to comment.