MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeText-parser / check_is_black_node

Function check_is_black_node

src/codetext/clean/noise_removal.py:367–386  ·  view source on GitHub ↗

Check if node belongs to black list. E.g: - Built-in function - Test function, test class - Constructor

(node_name: str, exclude_list: List = None)

Source from the content-addressed store, hash-verified

365# =================== Check code ======================
366
367def 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
389def check_is_empty_function(node):

Callers 1

check_functionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected