Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clang-tidy warnings #2843

Closed
fuzhe1989 opened this issue Sep 3, 2021 · 6 comments
Closed

Fix clang-tidy warnings #2843

fuzhe1989 opened this issue Sep 3, 2021 · 6 comments
Assignees
Labels
type/code-quality-improvement PR that can improve the code quality

Comments

@fuzhe1989
Copy link
Contributor

fuzhe1989 commented Sep 3, 2021

Files under dbms/src/Common Core Columns and libs/libcommon

Link: https://drive.google.com/drive/folders/1D1R5JlptJE_cjwzcgaXKlNW2HsQW8ka9?usp=sharing

Please take away yourself.

NOTE: dbms_src_Common_Config_cpptoml_h.txt is very large.

List:

@fuzhe1989 fuzhe1989 added the type/code-quality-improvement PR that can improve the code quality label Sep 3, 2021
@fuzhe1989 fuzhe1989 self-assigned this Sep 3, 2021
@JaySon-Huang

This comment has been minimized.

@JaySon-Huang
Copy link
Contributor

How can I run clang-tidy checks on some files/directories locally?

@fuzhe1989
Copy link
Contributor Author

@JaySon-Huang for-each clang-tidy-12 -p build/compile_commands.json ${f}

@XuHuaiyu
Copy link
Contributor

install clang-tidy on Mac:

brew install llvm
ln -s "/usr/local/opt/llvm/bin/clang-format" "/usr/local/bin/clang-format"
ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy"

@JaySon-Huang
Copy link
Contributor

A simple script for local check:

>  cat static_check.sh

## env settings
WORKSPACE=$(cd `dirname $0`; pwd)
BUILD_DIR="cmake-build-debug"
TIDY_BIN="/path/to/llvm/bin/clang-tidy"
TIDY_SCRIPT="/path/to/llvm/share/clang/run-clang-tidy.py"

DIR_TO_CHECK="${1}"

command -v "${TIDY_SCRIPT}" > /dev/null 2>&1
if [[ $? == 0 ]]; then
  # Check files by script, with parallel
  python3 "${TIDY_SCRIPT}" -p "${WORKSPACE}/${BUILD_DIR}/" -j 4 "${DIR_TO_CHECK}/*"
else
  # Check each file by clang-tidy
  for f in $(find "${DIR_TO_CHECK}" -name '*.cpp' -o -name "*.h"); do
    echo "Checking $f"
      "${TIDY_BIN}" -p "${WORKSPACE}/${BUILD_DIR}/compile_commands.json" "$f"
  done
fi

@dragonly
Copy link
Contributor

We can use plugin clangd in vscode and clion, which is very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/code-quality-improvement PR that can improve the code quality
Projects
None yet
Development

No branches or pull requests

4 participants