MCPcopy Create free account
hub / github.com/alibaba/GraphScope / ProcessConfigOverrides

Function ProcessConfigOverrides

analytical_engine/misc/cpplint.py:6505–6591  ·  view source on GitHub ↗

Loads the configuration files and processes the config overrides. Args: filename: The name of the file being processed by the linter. Returns: False if the current |filename| should not be processed further.

(filename)

Source from the content-addressed store, hash-verified

6503 CheckForNewlineAtEOF(filename, lines, error)
6504
6505def ProcessConfigOverrides(filename):
6506 """ Loads the configuration files and processes the config overrides.
6507
6508 Args:
6509 filename: The name of the file being processed by the linter.
6510
6511 Returns:
6512 False if the current |filename| should not be processed further.
6513 """
6514
6515 abs_filename = os.path.abspath(filename)
6516 cfg_filters = []
6517 keep_looking = True
6518 while keep_looking:
6519 abs_path, base_name = os.path.split(abs_filename)
6520 if not base_name:
6521 break # Reached the root directory.
6522
6523 cfg_file = os.path.join(abs_path, "CPPLINT.cfg")
6524 abs_filename = abs_path
6525 if not os.path.isfile(cfg_file):
6526 continue
6527
6528 try:
6529 with open(cfg_file) as file_handle:
6530 for line in file_handle:
6531 line, _, _ = line.partition('#') # Remove comments.
6532 if not line.strip():
6533 continue
6534
6535 name, _, val = line.partition('=')
6536 name = name.strip()
6537 val = val.strip()
6538 if name == 'set noparent':
6539 keep_looking = False
6540 elif name == 'filter':
6541 cfg_filters.append(val)
6542 elif name == 'exclude_files':
6543 # When matching exclude_files pattern, use the base_name of
6544 # the current file name or the directory name we are processing.
6545 # For example, if we are checking for lint errors in /foo/bar/baz.cc
6546 # and we found the .cfg file at /foo/CPPLINT.cfg, then the config
6547 # file's "exclude_files" filter is meant to be checked against "bar"
6548 # and not "baz" nor "bar/baz.cc".
6549 if base_name:
6550 pattern = re.compile(val)
6551 if pattern.match(base_name):
6552 if _cpplint_state.quiet:
6553 # Suppress "Ignoring file" warning when using --quiet.
6554 return False
6555 _cpplint_state.PrintInfo('Ignoring "%s": file excluded by "%s". '
6556 'File path component "%s" matches '
6557 'pattern "%s"\n' %
6558 (filename, cfg_file, base_name, val))
6559 return False
6560 elif name == 'linelength':
6561 global _line_length
6562 try:

Callers 1

ProcessFileFunction · 0.85

Calls 13

openFunction · 0.85
ProcessExtensionsOptionFunction · 0.85
ProcessHppHeadersOptionFunction · 0.85
_AddFiltersFunction · 0.85
splitMethod · 0.80
partitionMethod · 0.80
compileMethod · 0.80
PrintInfoMethod · 0.80
PrintErrorMethod · 0.80
appendMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected