Skip to content

Commit

Permalink
Update flake8 and clang-tidy linters (#179)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
patrick-5546 and hhenry01 authored Oct 18, 2023
1 parent 3574523 commit b2226ec
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 14 deletions.
7 changes: 2 additions & 5 deletions .devcontainer/config/sailbot_workspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@
// copy from https://github.com/ament/ament_lint/blob/humble/ament_flake8/ament_flake8/configuration/ament_flake8.ini
// except for import order style = google: use isort with black profile instead
"flake8.args": [
"--extend-ignore=B902,C816,D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404,I202",
"--max-line-length=99",
"--show-source",
"--statistics",
"--config=${workspaceFolder:sailbot_workspace}/.flake8",
],
"flake8.interpreter": ["/usr/bin/python3"],
// formatter: black and isort extensions
Expand Down Expand Up @@ -372,7 +369,7 @@
"label": "clang-tidy",
"detail": "Run clang-tidy static analysis",
"type": "shell",
"command": "./run_clang-tidy.sh",
"command": "LOCAL_RUN=true .github/actions/clang-tidy/run.sh",
"problemMatcher": [],
"presentation": {
"panel": "dedicated",
Expand Down
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
extend-ignore = B902,C816,D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404,I202,E203
import-order-style = google
max-line-length = 99
show-source = true
statistics = true
7 changes: 6 additions & 1 deletion .github/actions/ament-lint/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ function lint {
LINTED_FILES=`eval ${FILE_SEARCH_CMD}`

if [[ ! -z ${LINTED_FILES} ]]; then
ament_${LINTER} ${LINTED_FILES}
if [[ ${LINTER} = "flake8" ]]; then
# use custom configuration file that is compatible with black formatter
ament_${LINTER} --config .flake8 ${LINTED_FILES}
else
ament_${LINTER} ${LINTED_FILES}
fi
else
warn "WARNING: No files found for ${LINTER}. Skipping ament_${LINTER}..."
fi
Expand Down
Loading

0 comments on commit b2226ec

Please sign in to comment.