Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改行時の演算子が後置であることをチェックできるようにする #545

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Script/CI/check_coding_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def main():
check_operator_space_,
check_preprocessor_,
check_include_guard_,
check_binary_operator_before_linebreak_,
]
check_funcs = []

Expand Down Expand Up @@ -678,6 +679,23 @@ def check_include_guard_(path: str, code_lines: list) -> bool:
return False


def check_binary_operator_before_linebreak_(path: str, code_lines: list) -> bool:
ptn = r'^\s*([+\-*/%]|<<|>>|<=|>=|==|!=|&{1,2}|\|{1,2}|\^)\s+'
reptn = re.compile(ptn)
for idx, line in enumerate(code_lines):
if is_in_comment_context_in_multiline_(path, code_lines, idx):
continue

matched = reptn.match(line)
if matched is None:
continue

print_err_(path, idx, f'LINE {idx} HAS STARTED WITH THE OPERATOR {matched.group(1)}.', line)
return False

return True


# True: target が含まれる, False: なし
def is_contained_pattern_(line: str, target: str) -> bool:
pos = 0
Expand Down