mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-07 12:51:08 +00:00
Merge branch 'master' into Playerbot
This commit is contained in:
@@ -223,7 +223,7 @@ def misc_codestyle_check(file: io, file_path: str) -> None:
|
||||
# used to check for "if/else (...) {" "} else" ignores "if/else (...) {...}" "#define ... if/else (...) {"
|
||||
ifelse_curlyregex = r"^[^#define].*\s+(if|else)(\s*\(.*\))?\s*{[^}]*$|}\s*else(\s*{[^}]*$)"
|
||||
# used to catch double semicolons ";;" ignores "(;;)"
|
||||
double_semiregex = r"[^(];;[^)]"
|
||||
double_semiregex = r"(?<!\()\s*;;(?!\))"
|
||||
# used to catch tabs
|
||||
tab_regex = r"\t"
|
||||
|
||||
@@ -245,7 +245,7 @@ def misc_codestyle_check(file: io, file_path: str) -> None:
|
||||
print(
|
||||
f"Curly brackets are not allowed to be leading or trailing if/else statements. Place it on a new line: {file_path} at line {line_number}")
|
||||
check_failed = True
|
||||
if re.match(double_semiregex, line):
|
||||
if re.search(double_semiregex, line):
|
||||
print(
|
||||
f"Double semicolon (;;) found in {file_path} at line {line_number}")
|
||||
check_failed = True
|
||||
|
||||
@@ -206,18 +206,38 @@ def backtick_check(file: io, file_path: str) -> None:
|
||||
global error_handler, results
|
||||
file.seek(0)
|
||||
check_failed = False
|
||||
|
||||
# Find SQL clauses
|
||||
pattern = re.compile(
|
||||
r'\b(SELECT|FROM|JOIN|WHERE|GROUP BY|ORDER BY|DELETE FROM|UPDATE|INSERT INTO|SET)\s+([^;]+)',
|
||||
re.IGNORECASE)
|
||||
r'\b(SELECT|FROM|JOIN|WHERE|GROUP BY|ORDER BY|DELETE FROM|UPDATE|INSERT INTO|SET|REPLACE|REPLACE INTO)\s+(.*?)(?=;$|(?=\b(?:WHERE|SET|VALUES)\b)|$)',
|
||||
re.IGNORECASE | re.DOTALL
|
||||
)
|
||||
|
||||
|
||||
# Make sure to ignore values enclosed in single- and doublequotes
|
||||
quote_pattern = re.compile(r"'(?:\\'|[^'])*'|\"(?:\\\"|[^\"])*\"")
|
||||
|
||||
for line_number, line in enumerate(file, start=1):
|
||||
matches = pattern.findall(line)
|
||||
# Ignore comments
|
||||
if line.startswith('--'):
|
||||
continue
|
||||
|
||||
# Sanitize single- and doublequotes to prevent false positives
|
||||
sanitized_line = quote_pattern.sub('', line)
|
||||
matches = pattern.findall(sanitized_line)
|
||||
|
||||
for clause, content in matches:
|
||||
words = re.findall(r'\b[a-zA-Z_][a-zA-Z0-9_]*\b', content)
|
||||
# Find all words and exclude @variables
|
||||
words = re.findall(r'\b(?<!@)([a-zA-Z_][a-zA-Z0-9_]*)\b', content)
|
||||
|
||||
for word in words:
|
||||
# Skip SQL keywords
|
||||
if word.upper() in {"SELECT", "FROM", "JOIN", "WHERE", "GROUP", "BY", "ORDER",
|
||||
"DELETE", "UPDATE", "INSERT", "INTO", "SET", "VALUES"}:
|
||||
"DELETE", "UPDATE", "INSERT", "INTO", "SET", "VALUES", "AND",
|
||||
"IN", "OR", "REPLACE"}:
|
||||
continue
|
||||
|
||||
# Make sure the word is enclosed in backticks
|
||||
if not re.search(rf'`{re.escape(word)}`', content):
|
||||
print(f"Missing backticks around ({word}). {file_path} at line {line_number}")
|
||||
check_failed = True
|
||||
|
||||
Reference in New Issue
Block a user