From b47ec3b5c8a412ef4be24a670825ace95b0635c2 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Sat, 25 Jan 2025 19:58:01 +0100 Subject: [PATCH] fix(Apps/Codestyle): ignore comments for some checks (#21268) --- apps/codestyle/codestyle-sql.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/codestyle/codestyle-sql.py b/apps/codestyle/codestyle-sql.py index f15dceed6..0df5dec05 100644 --- a/apps/codestyle/codestyle-sql.py +++ b/apps/codestyle/codestyle-sql.py @@ -112,7 +112,7 @@ def sql_check(file: io, file_path: str) -> None: check_failed = True if "EntryOrGuid" in line: print( - f"Please use entryorguid syntax instead of EntryOrgGuid in {file_path} at line {line_number}\nWe recommend to use keira to have the right syntax in auto-query generation") + f"Please use entryorguid syntax instead of EntryOrGuid in {file_path} at line {line_number}\nWe recommend to use keira to have the right syntax in auto-query generation") check_failed = True if [match for match in [';;'] if match in line]: print( @@ -142,6 +142,8 @@ def insert_safety_check(file: io, file_path: str) -> None: # Parse all the file for line_number, line in enumerate(file, start = 1): + if line.startswith("--"): + continue if "INSERT" in line and "DELETE" not in previous_line: print(f"No DELETE keyword found after the INSERT in {file_path} at line {line_number}\nIf this error is intended, please advert a maintainer") check_failed = True @@ -163,7 +165,11 @@ def semicolon_check(file: io, file_path: str) -> None: total_lines = len(lines) for line_number, line in enumerate(lines, start=1): - stripped_line = line.rstrip() # Remove trailing whitespace including newline + if line.startswith('--'): + continue + # Remove trailing whitespace including newline + # Remove comments from the line + stripped_line = line.split('--', 1)[0].strip() # Check if one keyword is in the line if not query_open and any(keyword in stripped_line for keyword in sql_keywords):