From 2c20c9463a87701697790c8801a9481c8b8b5f37 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Sun, 22 Dec 2024 00:43:23 +0100 Subject: [PATCH] feat(CI/Codestyle): Check for tabs (#20998) --- apps/codestyle/codestyle.py | 6 ++++++ src/cmake/macros/FindMySQL.cmake | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/codestyle/codestyle.py b/apps/codestyle/codestyle.py index 27f273799df8b4..77ff3f37645c98 100644 --- a/apps/codestyle/codestyle.py +++ b/apps/codestyle/codestyle.py @@ -224,6 +224,8 @@ def misc_codestyle_check(file: io, file_path: str) -> None: ifelse_curlyregex = r"^[^#define].*\s+(if|else)(\s*\(.*\))?\s*{[^}]*$|}\s*else(\s*{[^}]*$)" # used to catch double semicolons ";;" ignores "(;;)" double_semiregex = r"[^(];;[^)]" + # used to catch tabs + tab_regex = r"\t" # Parse all the file for line_number, line in enumerate(file, start = 1): @@ -247,6 +249,10 @@ def misc_codestyle_check(file: io, file_path: str) -> None: print( f"Double semicolon (;;) found in {file_path} at line {line_number}") check_failed = True + if re.match(tab_regex, line): + print( + f"Tab found! Replace it to 4 spaces: {file_path} at line {line_number}") + check_failed = True # Handle the script error and update the result output if check_failed: diff --git a/src/cmake/macros/FindMySQL.cmake b/src/cmake/macros/FindMySQL.cmake index b78dfc2d87fdc2..2a8de7e7a8c8d5 100644 --- a/src/cmake/macros/FindMySQL.cmake +++ b/src/cmake/macros/FindMySQL.cmake @@ -161,7 +161,7 @@ if(WIN32) set(_MYSQL_ROOT_PATHS ${_MYSQL_ROOT_PATHS} - ${_MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES} + ${_MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES} "${PROGRAM_FILES_64}/MySQL" "${PROGRAM_FILES_32}/MySQL" "$ENV{SystemDrive}/MySQL" @@ -180,7 +180,7 @@ find_path(MYSQL_INCLUDE_DIR /usr/local/include /usr/local/include/mysql /usr/local/mysql/include - ${_MYSQL_ROOT_PATHS} + ${_MYSQL_ROOT_PATHS} PATH_SUFFIXES include include/mysql @@ -270,10 +270,10 @@ set(MYSQL_REQUIRED_VARS "") foreach(_comp IN LISTS MySQL_FIND_COMPONENTS) if(_comp STREQUAL "lib") set(MySQL_${_comp}_WANTED TRUE) - if(MySQL_FIND_REQUIRED_${_comp}) - list(APPEND MYSQL_REQUIRED_VARS "MYSQL_LIBRARY") - list(APPEND MYSQL_REQUIRED_VARS "MYSQL_INCLUDE_DIR") - endif() + if(MySQL_FIND_REQUIRED_${_comp}) + list(APPEND MYSQL_REQUIRED_VARS "MYSQL_LIBRARY") + list(APPEND MYSQL_REQUIRED_VARS "MYSQL_INCLUDE_DIR") + endif() if(EXISTS "${MYSQL_LIBRARY}" AND EXISTS "${MYSQL_INCLUDE_DIR}") set(MySQL_${_comp}_FOUND TRUE) else() @@ -281,9 +281,9 @@ foreach(_comp IN LISTS MySQL_FIND_COMPONENTS) endif() elseif(_comp STREQUAL "binary") set(MySQL_${_comp}_WANTED TRUE) - if(MySQL_FIND_REQUIRED_${_comp}) - list(APPEND MYSQL_REQUIRED_VARS "MYSQL_EXECUTABLE") - endif() + if(MySQL_FIND_REQUIRED_${_comp}) + list(APPEND MYSQL_REQUIRED_VARS "MYSQL_EXECUTABLE") + endif() if(EXISTS "${MYSQL_EXECUTABLE}" ) set(MySQL_${_comp}_FOUND TRUE) else()