common_fs.file_filter

class cpp_linter.common_fs.file_filter.FileFilter(ignore_value: str = '', extensions: list[str] | None = None, not_ignored: list[str] | None = None, tool_specific_name: str | None = None)[source]

A reusable mechanism for parsing and validating file filters.

Parameters:
extensions: list[str] | None = None

A list of file extensions in which to focus.

ignore_value: str = ''

The user input specified via --ignore CLI argument.

not_ignored: list[str] | None = None

A list of files or paths that will be explicitly not ignored.

tool_specific_name: str | None = None

A clang tool name for which the file filter is specifically applied. This only gets used in debug statements.

extensions : Set[str]

A set of file extensions that are considered C/C++ sources.

ignored : Set[str]

A set of ignore patterns.

not_ignored : Set[str]

A set of not-ignore patterns.

parse_submodules(path: str = '.gitmodules')[source]

Automatically detect submodules from the given relative path. This will add each submodule to the ignored list unless already specified as not_ignored.

is_file_in_list(ignored: bool, file_name: PurePath) bool[source]

Determine if a file is specified in a list of paths and/or filenames.

Parameters:
ignored: bool

A flag that specifies which set of list to compare with. True for ignored or False for not_ignored.

file_name: PurePath

The file’s path & name being sought in the path_list.

Returns:

  • True if file_name is in the path_list.

  • False if file_name is not in the path_list.

is_source_or_ignored(file_name: str) bool[source]

Exclude undesired files (specified by user input --extensions and --ignore options).

Parameters:
file_name: str

The name of file in question.

Returns:

True if (in order of precedence)

Otherwise False.

list_source_files() list[FileObj][source]

Make a list of source files to be checked. This will recursively walk the file tree collecting matches to anything that would return True from is_source_or_ignored().

Returns:

A list of FileObj objects without diff information.

class cpp_linter.common_fs.file_filter.TidyFileFilter(ignore_value: str = '', extensions: list[str] | None = None, not_ignored: list[str] | None = None)[source]

A specialized FileFilter whose debug prompts indicate clang-tidy preparation.

class cpp_linter.common_fs.file_filter.FormatFileFilter(ignore_value: str = '', extensions: list[str] | None = None, not_ignored: list[str] | None = None)[source]

A specialized FileFilter whose debug prompts indicate clang-format preparation.