Skip to content

Commit 46f6123

Browse files
Move linters to pre-commit (#298)
1 parent 0a0f261 commit 46f6123

File tree

32 files changed

+275
-241
lines changed

32 files changed

+275
-241
lines changed

.clang-format

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
---
22
BasedOnStyle: Google
33
DerivePointerAlignment: false
4-
IncludeBlocks: Regroup
5-
IncludeCategories:
6-
# Headers in "" with extension.
7-
- Regex: '"([A-Za-z0-9.\Q/-_\E])+"'
8-
Priority: 1
9-
# Headers in <> without extension.
10-
- Regex: '<([A-Za-z0-9\Q/-_\E])+>'
11-
Priority: 2
12-
# Headers in <> from specific external libraries.
13-
- Regex: '<(catch2|boost|rclcpp.*)\/'
14-
Priority: 3
15-
# Headers in <> with extension.
16-
- Regex: '<([A-Za-z0-9.\Q/-_\E])+>'
17-
Priority: 4
4+
IncludeBlocks: Preserve
5+
InsertBraces: true
6+
---

.github/workflows/format.yaml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This is a format job. Pre-commit has a first-party GitHub action, so we use
2-
# that: https://github.com/pre-commit/action
3-
41
name: Format
52

63
on:
@@ -12,17 +9,6 @@ on:
129

1310
jobs:
1411
pre-commit:
15-
name: pre-commit
16-
runs-on: ubuntu-latest
17-
steps:
18-
- uses: actions/checkout@v6
19-
- uses: actions/setup-python@v6
20-
- name: Install clang-format
21-
run: sudo apt-get install clang-format
22-
- uses: pre-commit/[email protected]
23-
id: precommit
24-
- name: Upload pre-commit changes
25-
if: failure() && steps.precommit.outcome == 'failure'
26-
uses: rhaschke/upload-git-patch-action@main
27-
with:
28-
name: pre-commit
12+
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-pre-commit.yml@master
13+
with:
14+
ros_distro: rolling

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ repos:
3434
- id: check-vcs-permalinks
3535
- id: check-yaml
3636
exclude: generate_parameter_library_py/generate_parameter_library_py/test
37+
args: ["--allow-multiple-documents"]
3738
- id: debug-statements
3839
- id: destroyed-symlinks
3940
- id: detect-private-key
@@ -75,3 +76,31 @@ repos:
7576
rev: v3.21.2
7677
hooks:
7778
- id: pyupgrade
79+
80+
- repo: local
81+
hooks:
82+
- id: ament_cppcheck
83+
name: ament_cppcheck
84+
description: Static code analysis of C/C++ files.
85+
entry: env AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1 ament_cppcheck
86+
language: system
87+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
88+
- id: ament_cpplint
89+
name: ament_cpplint
90+
description: Static code analysis of C/C++ files.
91+
entry: ament_cpplint
92+
language: system
93+
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
94+
args: ["--linelength=100", "--filter=-whitespace/newline"]
95+
- id: ament_lint_cmake
96+
name: ament_lint_cmake
97+
description: Check format of CMakeLists.txt files.
98+
entry: ament_lint_cmake
99+
language: system
100+
files: CMakeLists\.txt$
101+
- id: ament_copyright
102+
name: ament_copyright
103+
description: Check if copyright notice is available in all files.
104+
entry: ament_copyright
105+
language: system
106+
exclude: .*/conf\.py$

example/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ rclcpp_components_register_node(minimal_publisher
3636
)
3737

3838
if(BUILD_TESTING)
39-
find_package(ament_lint_auto REQUIRED)
40-
set(ament_cmake_cpplint_FOUND TRUE) # Conflicts with clang-foramt
41-
set(ament_cmake_flake8_FOUND TRUE) # Conflicts with black
42-
set(ament_cmake_uncrustify_FOUND TRUE) # Conflicts with clang-format
43-
ament_lint_auto_find_test_dependencies()
44-
4539
find_package(ament_cmake_gtest REQUIRED)
4640
# example_test_gtest
4741
add_rostest_with_parameters_gtest(test_example_gtest test/example_test_gtest.cpp

example/include/generate_parameter_library_example/example_validators.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828

2929
#pragma once
3030

31+
#include <fmt/core.h>
32+
3133
#include <string>
3234

3335
#include <rclcpp/rclcpp.hpp>
34-
35-
#include <fmt/core.h>
3636
#include <tl_expected/expected.hpp>
3737

3838
namespace custom_validators {

example/include/generate_parameter_library_example/minimal_publisher.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#pragma once
3030

31+
#include <memory>
32+
3133
#include <rclcpp/rclcpp.hpp>
3234
#include <rclcpp_components/register_node_macro.hpp>
3335

@@ -37,7 +39,8 @@ namespace admittance_controller {
3739

3840
class MinimalPublisher : public rclcpp::Node {
3941
public:
40-
MinimalPublisher(const rclcpp::NodeOptions& options = rclcpp::NodeOptions());
42+
explicit MinimalPublisher(
43+
const rclcpp::NodeOptions& options = rclcpp::NodeOptions());
4144

4245
private:
4346
void timer_callback();

example/package.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020

2121
<buildtool_export_depend>ament_cmake_core</buildtool_export_depend>
2222

23-
<test_depend>ament_lint_auto</test_depend>
24-
<test_depend>ament_lint_common</test_depend>
25-
2623
<export>
2724
<build_type>ament_cmake</build_type>
2825
</export>

example/test/descriptor_test_gtest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
// Author: Chance Cardona
3030
//
3131

32+
#include <limits>
33+
#include <memory>
34+
3235
#include "generate_parameter_library_example/admittance_controller_parameters.hpp"
3336
#include "gtest/gtest.h"
3437
#include "rclcpp/rclcpp.hpp"
3538

36-
#include <limits>
37-
#include <memory>
38-
3939
class DescriptorTest : public ::testing::Test {
4040
public:
4141
void SetUp() {

example/test/example_test_gmock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
// Author: Denis Štogl
3030
//
3131

32+
#include <memory>
33+
3234
#include "generate_parameter_library_example/admittance_controller_parameters.hpp"
3335
#include "gmock/gmock.h"
3436
#include "rclcpp/rclcpp.hpp"
3537

36-
#include <memory>
37-
3838
class ExampleTest : public ::testing::Test {
3939
public:
4040
void SetUp() {

example/test/example_test_gtest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
// Author: Denis Štogl
3030
//
3131

32+
#include <memory>
33+
3234
#include "generate_parameter_library_example/admittance_controller_parameters.hpp"
3335
#include "gtest/gtest.h"
3436
#include "rclcpp/rclcpp.hpp"
3537

36-
#include <memory>
37-
3838
class ExampleTest : public ::testing::Test {
3939
public:
4040
void SetUp() {

0 commit comments

Comments
 (0)