diff options
author | Kitzunu <24550914+Kitzunu@users.noreply.github.com> | 2025-02-07 00:09:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-07 00:09:55 +0100 |
commit | 668864556bf772ef595b58da13067b4064dfdbda (patch) | |
tree | b9c8caa2ff60f77e86e852e091b8253cb9461523 /apps | |
parent | 703deaa3884505dc354529303ba2908763420854 (diff) |
fix(CI/Codestyle): Ignore comments for backtick check (#21343)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codestyle/codestyle-sql.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/apps/codestyle/codestyle-sql.py b/apps/codestyle/codestyle-sql.py index 1bb98e037b..703607c128 100644 --- a/apps/codestyle/codestyle-sql.py +++ b/apps/codestyle/codestyle-sql.py @@ -216,12 +216,18 @@ def backtick_check(file: io, file_path: str) -> None: quote_pattern = re.compile(r"'(?:\\'|[^'])*'|\"(?:\\\"|[^\"])*\"") for line_number, line in enumerate(file, start=1): + # 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) for word in words: + # Skip SQL keywords if word.upper() in {"SELECT", "FROM", "JOIN", "WHERE", "GROUP", "BY", "ORDER", "DELETE", "UPDATE", "INSERT", "INTO", "SET", "VALUES", "AND", "IN", "OR", "REPLACE"}: |