MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / ProcessConfigOverrides

Function ProcessConfigOverrides

steps/cpplint.py:6514–6600  ·  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

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

Callers 1

ProcessFileFunction · 0.85

Calls 7

ProcessExtensionsOptionFunction · 0.85
ProcessHppHeadersOptionFunction · 0.85
_AddFiltersFunction · 0.85
appendMethod · 0.80
PrintInfoMethod · 0.80
PrintErrorMethod · 0.80

Tested by

no test coverage detected