Skip to content

Commit 94de088

Browse files
authored
Align clang-format include ordering with cpplint rules (#1428)
Previously, clang-format's default Google style IncludeCategories assigned the same priority to C++ standard library headers (e.g., <string>) and third-party headers (e.g., <rcpputils/scope_exit.hpp>), causing them to be sorted alphabetically within the same group. This violated cpplint's expected include order (C system → C++ system → other), requiring `// NOLINTNEXTLINE` comments as workarounds. Changes: - .clang-format: Add explicit IncludeCategories to separate C++ standard library headers (no slash, no extension) from third-party angle-bracket headers, and set IncludeBlocks to Regroup so clang-format enforces proper grouping - .clang-format: Upgrade Standard from Cpp11 to c++17 to match binding.gyp - Remove `// NOLINTNEXTLINE` from 4 source files: src/rcl_context_bindings.cpp, src/rcl_graph_bindings.cpp, src/rcl_subscription_bindings.cpp, src/rcl_utilities.cpp Verified with `npm run format` and `npm run lint` (cpplint: 0 errors). Fix: #1427
1 parent 00d3a5e commit 94de088

5 files changed

Lines changed: 21 additions & 9 deletions

File tree

.clang-format

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
BasedOnStyle: Google
2-
Standard: Cpp11
2+
Standard: c++17
3+
IncludeBlocks: Regroup
4+
IncludeCategories:
5+
- Regex: '^<ext/.*\.h>'
6+
Priority: 2
7+
- Regex: '^<.*\.h>'
8+
Priority: 1
9+
- Regex: '^<[^./]+>'
10+
Priority: 2
11+
- Regex: '^<.*'
12+
Priority: 3
13+
- Regex: '.*'
14+
Priority: 4

src/rcl_context_bindings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#include <rcl/logging.h>
1818
#include <rcl/rcl.h>
1919

20-
#include <rcpputils/scope_exit.hpp>
21-
// NOLINTNEXTLINE
2220
#include <string>
2321

22+
#include <rcpputils/scope_exit.hpp>
23+
2424
#include "macros.h"
2525
#include "rcl_handle.h"
2626
#include "rcl_utilities.h"

src/rcl_graph_bindings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#include <rcl/graph.h>
1919
#include <rcl/rcl.h>
2020

21-
#include <rcpputils/scope_exit.hpp>
22-
// NOLINTNEXTLINE
2321
#include <string>
2422

23+
#include <rcpputils/scope_exit.hpp>
24+
2525
#include "macros.h"
2626
#include "rcl_handle.h"
2727
#include "rcl_utilities.h"

src/rcl_subscription_bindings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
#include <cstdio>
2121
#include <memory>
22-
#include <rcpputils/scope_exit.hpp>
23-
// NOLINTNEXTLINE
2422
#include <string>
2523

24+
#include <rcpputils/scope_exit.hpp>
25+
2626
#include "macros.h"
2727
#include "rcl_handle.h"
2828
#include "rcl_utilities.h"

src/rcl_utilities.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
#include <cstdio>
2323
#include <memory>
24-
#include <rcpputils/scope_exit.hpp>
25-
// NOLINTNEXTLINE
2624
#include <string>
2725

26+
#include <rcpputils/scope_exit.hpp>
27+
2828
namespace {
2929

3030
const rmw_qos_profile_t* GetQoSProfileFromString(const std::string& profile) {

0 commit comments

Comments
 (0)