MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / ProcessConfigOverrides

Function ProcessConfigOverrides

src/tests/coding/cpplint.py:6502–6588  ·  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

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

Callers 1

ProcessFileFunction · 0.85

Calls 8

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

Tested by

no test coverage detected