Add linting via pre-commit and docker

Please see .pre-commit-config.yaml for details

- Add clang-format
- Add cpplint
- Add config for clang-tidy but don't enforce with pre-commit

Change-Id: Ica447c78e6fde94b43bfdc00f5b4efc338363e24
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
This commit is contained in:
Galantsev, Dmitrii
2023-10-31 18:00:37 -05:00
committed by Dmitrii Galantsev
orang tua e1c972a193
melakukan 142fbac7ac
8 mengubah file dengan 141 tambahan dan 0 penghapusan
+4
Melihat File
@@ -0,0 +1,4 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 100
+25
Melihat File
@@ -0,0 +1,25 @@
# THIS FILE IS GENERATED FROM .clangd!
# Run .update-clang-tidy.sh to regenerate.
Checks:
bugprone*,
clang-analyzer*,
google*,
misc*,
modernize*,
-abseil*,
-bugprone-easily-swappable-parameters,
-bugprone-reserved-identifier,
-clang-analyzer-security.insecureAPI.strcpy,
-cppcoreguidelines*,
-cppcoreguidelines-pro*,
-misc-non-copyable-objects,
-misc-use-anonymous-namespace,
-modernize-avoid-c-arrays,
-modernize-redundant-void-arg,
-modernize-use-auto,
-modernize-use-nodiscard,
-modernize-use-noexcept,
-modernize-use-trailing-return-type,
-modernize-use-using,
-performance*,
-readability*,
+37
Melihat File
@@ -0,0 +1,37 @@
CompileFlags:
Remove: -W*
Add: [-Wall, -pedantic, -I/opt/rocm/include, -I/opt/rocm/include/hsa, -I/opt/rocm/include/rocprofiler]
Compiler: clang++
# list here: https://clang.llvm.org/extra/clang-tidy/checks/list.html
Diagnostics:
UnusedIncludes: Strict
# rules below are copied into .clang-tidy using ./.update-clang-tidy.sh
# please keep the rules sorted alphabetically
ClangTidy:
Add: [
bugprone*,
clang-analyzer*,
google*,
misc*,
modernize*,
]
Remove: [
abseil*,
bugprone-easily-swappable-parameters,
bugprone-reserved-identifier,
clang-analyzer-security.insecureAPI.strcpy,
cppcoreguidelines*,
cppcoreguidelines-pro*,
misc-non-copyable-objects,
misc-use-anonymous-namespace,
modernize-avoid-c-arrays,
modernize-redundant-void-arg,
modernize-use-auto,
modernize-use-nodiscard,
modernize-use-noexcept,
modernize-use-trailing-return-type,
modernize-use-using,
performance*,
readability*,
]
+1
Melihat File
@@ -10,3 +10,4 @@ root = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 100
+5
Melihat File
@@ -23,3 +23,8 @@ device/
__pycache__
README
README.html
# do NOT ignore these files
!.clang-format
!.clang-tidy
!.clangd
+30
Melihat File
@@ -0,0 +1,30 @@
# - How to use:
# python3 -m pip install pre-commit
# pre-commit install --install hooks
# Upon a new commit - the hooks should automagically run
#
# - How to skip:
# git commit --no-verify
# or
# SKIP=clang-format-docker git commit
# SKIP=cpplint-docker git commit
fail_fast: false
repos:
# For portability I decided to use Docker containers
- repo: https://github.com/dmitrii-galantsev/pre-commit-docker-cpplint
rev: 0.0.3
hooks:
- id: clang-format-docker
- id: cpplint-docker
# Below is a local way of running formatters and linters
# NOTE: clang-tidy is not used in the above tests
# - repo: https://github.com/pocc/pre-commit-hooks
# rev: v1.3.5
# hooks:
# - id: clang-format
# args: [--no-diff, -i]
# - id: clang-tidy
# args: [-p=build, --quiet]
# - id: cpplint
# args: [--verbose=5]
+36
Melihat File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -x # trace
set -e # exit immediately if command fails
set -u # exit if an undefined variable is found
awk '
BEGIN {
print "# THIS FILE IS GENERATED FROM .clangd!"
print "# Run ./.update-clang-tidy.sh to regenerate."
print "Checks:"
}
/Add: \[$/{
a=1
next
}
/]/{
a=0
}
a{
gsub(/^\s+/," ")
print
}
/Remove: \[$/{
r=1
next
}
/]/{
r=0
}
r{
gsub(/^\s+/," -")
print
}
' .clangd | tee .clang-tidy
+3
Melihat File
@@ -0,0 +1,3 @@
set noparent
linelength=100
filter=-build/include_subdir,-legal/copyright,-runtime/printf,-build/c++11,-runtime/int,-build/header_guard