Check if node belongs to black list. E.g: - Built-in function - Test function, test class - Constructor
(node_name: str, exclude_list: List = None)
| 365 | # =================== Check code ====================== |
| 366 | |
| 367 | def check_is_black_node(node_name: str, exclude_list: List = None): |
| 368 | """ |
| 369 | Check if node belongs to black list. E.g: |
| 370 | - Built-in function |
| 371 | - Test function, test class |
| 372 | - Constructor |
| 373 | """ |
| 374 | black_keywords = ['test_', 'Test_', '_test', 'toString', 'constructor', 'Constructor'] |
| 375 | black_keywords.extend(exclude_list) |
| 376 | |
| 377 | if not isinstance(node_name, str): |
| 378 | raise ValueError(f'Expect str, get {type(node_name)}') |
| 379 | if node_name.startswith('__') and node_name.endswith('__'): |
| 380 | return True |
| 381 | if node_name.startswith('set') or node_name.startswith('get'): |
| 382 | return True |
| 383 | if any(keyword in node_name for keyword in black_keywords): |
| 384 | return True |
| 385 | |
| 386 | return False |
| 387 | |
| 388 | |
| 389 | def check_is_empty_function(node): |