MCPcopy Index your code
hub / github.com/nodejs/node / ProcessConfigOverrides

Function ProcessConfigOverrides

tools/cpplint.py:7613–7703  ·  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

7611
7612
7613def ProcessConfigOverrides(filename):
7614 """Loads the configuration files and processes the config overrides.
7615
7616 Args:
7617 filename: The name of the file being processed by the linter.
7618
7619 Returns:
7620 False if the current |filename| should not be processed further.
7621 """
7622
7623 abs_filename = os.path.abspath(filename)
7624 cfg_filters = []
7625 keep_looking = True
7626 while keep_looking:
7627 abs_path, base_name = os.path.split(abs_filename)
7628 if not base_name:
7629 break # Reached the root directory.
7630
7631 cfg_file = os.path.join(abs_path, _config_filename)
7632 abs_filename = abs_path
7633 if not os.path.isfile(cfg_file):
7634 continue
7635
7636 try:
7637 with open(cfg_file, encoding="utf8", errors="replace") as file_handle:
7638 for line in file_handle:
7639 line, _, _ = line.partition("#") # Remove comments.
7640 if not line.strip():
7641 continue
7642
7643 name, _, val = line.partition("=")
7644 name = name.strip()
7645 val = val.strip()
7646 if name == "set noparent":
7647 keep_looking = False
7648 elif name == "filter":
7649 cfg_filters.append(val)
7650 elif name == "exclude_files":
7651 # When matching exclude_files pattern, use the base_name of
7652 # the current file name or the directory name we are processing.
7653 # For example, if we are checking for lint errors in /foo/bar/baz.cc
7654 # and we found the .cfg file at /foo/CPPLINT.cfg, then the config
7655 # file's "exclude_files" filter is meant to be checked against "bar"
7656 # and not "baz" nor "bar/baz.cc".
7657 if base_name:
7658 pattern = re.compile(val)
7659 if pattern.match(base_name):
7660 if _cpplint_state.quiet:
7661 # Suppress "Ignoring file" warning when using --quiet.
7662 return False
7663 _cpplint_state.PrintInfo(
7664 f'Ignoring "{filename}": file excluded by "{cfg_file}". '
7665 'File path component "%s" matches '
7666 'pattern "%s"\n' % (base_name, val)
7667 )
7668 return False
7669 elif name == "linelength":
7670 global _line_length

Callers 1

ProcessFileFunction · 0.85

Calls 15

intFunction · 0.85
ProcessExtensionsOptionFunction · 0.85
ProcessHppHeadersOptionFunction · 0.85
_AddFiltersFunction · 0.85
PrintInfoMethod · 0.80
PrintErrorMethod · 0.80
matchMethod · 0.65
openFunction · 0.50
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…