Skip to content

Commit

Permalink
Use .clang-tidy from yscope-dev-utils and add instructions for runnin…
Browse files Browse the repository at this point in the history
…g clang-tidy. (#22)
  • Loading branch information
SharafMohamed authored Aug 16, 2024
1 parent d9a686e commit c545db9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 43 deletions.
41 changes: 0 additions & 41 deletions .clang-tidy

This file was deleted.

2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ endif()
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type "Release")
message(STATUS "No build type specified. Setting to '${default_build_type}'.")
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,29 @@ locally, you can enable and run the [lint] workflow in your fork.
To run the linting tools, besides commonly installed tools like `tar`, you'll need:

* [clang-tidy]
* `md5sum`
* Python 3.8 or newer
* python3-venv
* [Task]

### Setup

```shell
./tools/init.sh
```

### Running the linters

Currently, `clang-tidy` has to be run manually:
```shell
find src tests \
-type f \
\( -iname "*.cpp" -o -iname "*.hpp" \) \
-print0 | \
xargs -0 clang-tidy --config-file .clang-tidy -p build
```

To report all errors run:

```shell
Expand Down Expand Up @@ -178,6 +194,7 @@ The following are issues we're aware of and working on:
* Support for submatch extraction will be coming in a future release.
[Catch2]: https://github.com/catchorg/Catch2/tree/devel
[clang-tidy]: https://clang.llvm.org/extra/clang-tidy/
[feature-req]: https://github.com/y-scope/log-surgeon/issues/new?assignees=&labels=enhancement&template=feature-request.yml
[lint]: https://github.com/y-scope/log-surgeon/blob/main/.github/workflows/lint.yml
[Task]: https://taskfile.dev/
1 change: 0 additions & 1 deletion lint-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ tasks:
--strict \
.github \
.clang-format \
.clang-tidy \
lint-tasks.yml \
Taskfile.yml
Expand Down
21 changes: 21 additions & 0 deletions tools/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# Exit on any error
set -e

# Error on undefined variable
set -u

repo_dir="$(git rev-parse --show-toplevel)"
clang_tidy_config_src_relative_to_repo="tools/yscope-dev-utils/lint-configs/.clang-tidy"

clang_tidy_config_src="${repo_dir}/${clang_tidy_config_src_relative_to_repo}"
clang_tidy_config_dst="${repo_dir}/.clang-tidy"
if [ ! -e "$clang_tidy_config_dst" ]; then
ln -s "$clang_tidy_config_src_relative_to_repo" "$clang_tidy_config_dst"
else
if [ "$(readlink -f "$clang_tidy_config_dst")" != "$(readlink -f "$clang_tidy_config_src")" ];
then
echo "Unexpected clang-tidy config at $clang_tidy_config_dst"
fi
fi
2 changes: 1 addition & 1 deletion tools/yscope-dev-utils

0 comments on commit c545db9

Please sign in to comment.