Skip to content

Commit b2226ec

Browse files
Update flake8 and clang-tidy linters (#179)
* Copy ament clang tidy source code * Add flake8 file * Make compatible with black * Use flake8 config file * Format clang-tidy * Move to clang-tidy directory * Use it * Specify compile.json * Exclude files * Update print statement * Try reducing number of parallel jobs * Settle on 8 parallel jobs * Properly exclude protobuf source files * Only check end of file * Test clang-tidy error * Disable clang tidy during build * Update comment * Revert test clang-tidy error --------- Co-authored-by: hhenry01 <[email protected]>
1 parent 3574523 commit b2226ec

File tree

7 files changed

+433
-14
lines changed

7 files changed

+433
-14
lines changed

.devcontainer/config/sailbot_workspace.code-workspace

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@
154154
// copy from https://github.com/ament/ament_lint/blob/humble/ament_flake8/ament_flake8/configuration/ament_flake8.ini
155155
// except for import order style = google: use isort with black profile instead
156156
"flake8.args": [
157-
"--extend-ignore=B902,C816,D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404,I202",
158-
"--max-line-length=99",
159-
"--show-source",
160-
"--statistics",
157+
"--config=${workspaceFolder:sailbot_workspace}/.flake8",
161158
],
162159
"flake8.interpreter": ["/usr/bin/python3"],
163160
// formatter: black and isort extensions
@@ -372,7 +369,7 @@
372369
"label": "clang-tidy",
373370
"detail": "Run clang-tidy static analysis",
374371
"type": "shell",
375-
"command": "./run_clang-tidy.sh",
372+
"command": "LOCAL_RUN=true .github/actions/clang-tidy/run.sh",
376373
"problemMatcher": [],
377374
"presentation": {
378375
"panel": "dedicated",

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
extend-ignore = B902,C816,D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404,I202,E203
3+
import-order-style = google
4+
max-line-length = 99
5+
show-source = true
6+
statistics = true

.github/actions/ament-lint/run.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ function lint {
3737
LINTED_FILES=`eval ${FILE_SEARCH_CMD}`
3838

3939
if [[ ! -z ${LINTED_FILES} ]]; then
40-
ament_${LINTER} ${LINTED_FILES}
40+
if [[ ${LINTER} = "flake8" ]]; then
41+
# use custom configuration file that is compatible with black formatter
42+
ament_${LINTER} --config .flake8 ${LINTED_FILES}
43+
else
44+
ament_${LINTER} ${LINTED_FILES}
45+
fi
4146
else
4247
warn "WARNING: No files found for ${LINTER}. Skipping ament_${LINTER}..."
4348
fi

0 commit comments

Comments
 (0)