Skip to content

Commit

Permalink
fix(Apps/Codestyle): ignore comments for some checks (#21268)
Browse files Browse the repository at this point in the history
  • Loading branch information
sogladev authored Jan 25, 2025
1 parent f692ae9 commit b47ec3b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/codestyle/codestyle-sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit b47ec3b

Please sign in to comment.