A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
check-style-clang-format Namespace Reference

Functions

Tuple[bool, str, List[str]] check_doxygen_tags_line (str line, str filename, int line_number)
 
Tuple[bool, str, List[str]] check_emacs_line (str line, str filename, int line_number)
 
Tuple[str, bool, List[str]] check_encoding_file (str filename, bool fix, bool verbose)
 
Tuple[str, bool, List[str]] check_formatting_file (str filename, bool fix, bool verbose, str clang_format_path)
 CHECK STYLE FUNCTIONS.
 
Tuple[bool, str, List[str]] check_include_prefixes_line (str line, str filename, int line_number)
 
Tuple[bool, str, List[str]] check_include_quotes_line (str line, str filename, int line_number)
 
Tuple[bool, str, List[str]] check_licenses_line (str line, str filename, int line_number)
 
Tuple[str, bool, List[str]] check_manually_file (str filename, bool fix, bool verbose, bool respect_clang_format_guards, Callable[[str, str, int], Tuple[bool, str, List[str]]] check_style_line_function)
 
bool check_style_clang_format (List[str] paths, Dict[str, bool] checks_enabled, bool fix, bool verbose, int n_jobs=1)
 CHECK STYLE MAIN FUNCTIONS.
 
bool check_style_files (str style_check_str, Callable[..., Tuple[str, bool, List[str]]] check_style_file_function, List[str] filenames, bool fix, bool verbose, int n_jobs, **kwargs)
 
Tuple[bool, str, List[str]] check_tabs_line (str line, str filename, int line_number)
 
Tuple[bool, str, List[str]] check_whitespace_line (str line, str filename, int line_number)
 
str find_clang_format_path ()
 
Dict[str, List[str]] find_files_to_check_style (List[str] paths)
 
bool should_analyze_directory (str dirpath)
 AUXILIARY FUNCTIONS.
 
bool should_analyze_file (str path, List[str] files_to_check, List[str] file_extensions_to_check)
 

Variables

 action
 
bool all_checks_successful
 
 args = parser.parse_args()
 
list CHECKS
 
int CLANG_FORMAT_MAX_VERSION = 17
 PARAMETERS.
 
int CLANG_FORMAT_MIN_VERSION = 15
 
 default
 
list DIRECTORIES_TO_SKIP
 
str FILE_ENCODING = "UTF-8"
 
dict FILE_EXTENSIONS_TO_CHECK = {c: [] for c in CHECKS}
 
dict FILES_TO_CHECK = {c: [] for c in CHECKS}
 
list FILES_TO_SKIP
 
list FORMAT_GUARD_OFF
 
list FORMAT_GUARD_ON
 
 help
 
 nargs
 
 parser
 
 sep
 
int TAB_SIZE = 4
 
 type
 

Function Documentation

◆ check_doxygen_tags_line()

Tuple[bool, str, List[str]] check-style-clang-format.check_doxygen_tags_line ( str line,
str filename,
int line_number )
Check / fix Doxygen tags using \\ rather than @ in a line.

@param line The line to check.
@param filename Name of the file to be checked.
@param line_number The number of the line checked.
@return Tuple [Whether the line is compliant with the style (before the check),
               Fixed line,
               Verbose information].

Definition at line 772 of file check-style-clang-format.py.

◆ check_emacs_line()

Tuple[bool, str, List[str]] check-style-clang-format.check_emacs_line ( str line,
str filename,
int line_number )
Check / fix emacs file style comment in a line.

@param line The line to check.
@param filename Name of the file to be checked.
@param line_number The number of the line checked.
@return Tuple [Whether the line is compliant with the style (before the check),
               Fixed line,
               Verbose information].

Definition at line 886 of file check-style-clang-format.py.

◆ check_encoding_file()

Tuple[str, bool, List[str]] check-style-clang-format.check_encoding_file ( str filename,
bool fix,
bool verbose )
Check / fix the encoding of a file.

@param filename Name of the file to be checked.
@param fix Whether to fix (True) or just check (False) the encoding of the file.
@param verbose Show the lines that are not compliant with the style.
@return Tuple [Filename,
               Whether the file is compliant with the style (before the check),
               Verbose information].

Definition at line 558 of file check-style-clang-format.py.

◆ check_formatting_file()

Tuple[str, bool, List[str]] check-style-clang-format.check_formatting_file ( str filename,
bool fix,
bool verbose,
str clang_format_path )

CHECK STYLE FUNCTIONS.

Check / fix the coding style of a file with clang-format.

@param filename Name of the file to be checked.
@param fix Whether to fix (True) or just check (False) the style of the file.
@param verbose Show the lines that are not compliant with the style.
@param clang_format_path Path to clang-format.
@return Tuple [Filename,
               Whether the file is compliant with the style (before the check),
               Verbose information].

Definition at line 500 of file check-style-clang-format.py.

◆ check_include_prefixes_line()

Tuple[bool, str, List[str]] check-style-clang-format.check_include_prefixes_line ( str line,
str filename,
int line_number )
Check / fix #include headers from the same module with the "ns3/" prefix in a line.

@param line The line to check.
@param filename Name of the file to be checked.
@param line_number The number of the line checked.
@return Tuple [Whether the line is compliant with the style (before the check),
               Fixed line,
               Verbose information].

Definition at line 683 of file check-style-clang-format.py.

◆ check_include_quotes_line()

Tuple[bool, str, List[str]] check-style-clang-format.check_include_quotes_line ( str line,
str filename,
int line_number )
Check / fix ns-3 #include headers using angle brackets <> rather than quotes "" in a line.

@param line The line to check.
@param filename Name of the file to be checked.
@param line_number The number of the line checked.
@return Tuple [Whether the line is compliant with the style (before the check),
               Fixed line,
               Verbose information].

Definition at line 734 of file check-style-clang-format.py.

◆ check_licenses_line()

Tuple[bool, str, List[str]] check-style-clang-format.check_licenses_line ( str line,
str filename,
int line_number )
Check / fix SPDX licenses rather than GPL text in a line.

@param line The line to check.
@param filename Name of the file to be checked.
@param line_number The number of the line checked.
@return Tuple [Whether the line is compliant with the style (before the check),
               Fixed line,
               Verbose information].

Definition at line 822 of file check-style-clang-format.py.

◆ check_manually_file()

Tuple[str, bool, List[str]] check-style-clang-format.check_manually_file ( str filename,
bool fix,
bool verbose,
bool respect_clang_format_guards,
Callable[[str, str, int], Tuple[bool, str, List[str]]] check_style_line_function )
Check / fix a file manually using a function to check / fix each line.

@param filename Name of the file to be checked.
@param fix Whether to fix (True) or just check (False) the style of the file.
@param verbose Show the lines that are not compliant with the style.
@param respect_clang_format_guards Whether to respect clang-format guards.
@param check_style_line_function Function used to check each line.
@return Tuple [Filename,
               Whether the file is compliant with the style (before the check),
               Verbose information].

Definition at line 619 of file check-style-clang-format.py.

◆ check_style_clang_format()

bool check-style-clang-format.check_style_clang_format ( List[str] paths,
Dict[str, bool] checks_enabled,
bool fix,
bool verbose,
int n_jobs = 1 )

CHECK STYLE MAIN FUNCTIONS.

Check / fix the coding style of a list of files.

@param paths List of paths to the files to check.
@param checks_enabled Dictionary of checks indicating whether to enable each of them.
@param fix Whether to fix (True) or just check (False) the file.
@param verbose Show the lines that are not compliant with the style.
@param n_jobs Number of parallel jobs.
@return Whether all files are compliant with all enabled style checks.

Definition at line 311 of file check-style-clang-format.py.

References check_style_files(), find_clang_format_path(), and find_files_to_check_style().

+ Here is the call graph for this function:

◆ check_style_files()

bool check-style-clang-format.check_style_files ( str style_check_str,
Callable[..., Tuple[str, bool, List[str]]] check_style_file_function,
List[str] filenames,
bool fix,
bool verbose,
int n_jobs,
** kwargs )
Check / fix style of a list of files.

@param style_check_str Description of the check to be performed.
@param check_style_file_function Function used to check the file.
@param filename Name of the file to be checked.
@param fix Whether to fix (True) or just check (False) the file (True).
@param verbose Show the lines that are not compliant with the style.
@param n_jobs Number of parallel jobs.
@param kwargs Additional keyword arguments to the check_style_file_function.
@return Whether all files are compliant with the style.

Definition at line 432 of file check-style-clang-format.py.

Referenced by check_style_clang_format().

+ Here is the caller graph for this function:

◆ check_tabs_line()

Tuple[bool, str, List[str]] check-style-clang-format.check_tabs_line ( str line,
str filename,
int line_number )
Check / fix tabs in a line.

@param line The line to check.
@param filename Name of the file to be checked.
@param line_number The number of the line checked.
@return Tuple [Whether the line is compliant with the style (before the check),
               Fixed line,
               Verbose information].

Definition at line 959 of file check-style-clang-format.py.

◆ check_whitespace_line()

Tuple[bool, str, List[str]] check-style-clang-format.check_whitespace_line ( str line,
str filename,
int line_number )
Check / fix whitespace in a line.

@param line The line to check.
@param filename Name of the file to be checked.
@param line_number The number of the line checked.
@return Tuple [Whether the line is compliant with the style (before the check),
               Fixed line,
               Verbose information].

Definition at line 926 of file check-style-clang-format.py.

◆ find_clang_format_path()

str check-style-clang-format.find_clang_format_path ( )
Find the path to one of the supported versions of clang-format.
If no supported version of clang-format is found, raise an exception.

@return Path to clang-format.

Definition at line 264 of file check-style-clang-format.py.

Referenced by check_style_clang_format().

+ Here is the caller graph for this function:

◆ find_files_to_check_style()

Dict[str, List[str]] check-style-clang-format.find_files_to_check_style ( List[str] paths)
Find all files to be checked in a given list of paths.

@param paths List of paths to the files to check.
@return Dictionary of checks and corresponding list of files to check.
        Example: {
            "formatting": list_of_files_to_check_formatting,
            ...,
        }

Definition at line 216 of file check-style-clang-format.py.

References should_analyze_directory(), and should_analyze_file().

Referenced by check_style_clang_format().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ should_analyze_directory()

bool check-style-clang-format.should_analyze_directory ( str dirpath)

AUXILIARY FUNCTIONS.

Check whether a directory should be analyzed.

@param dirpath Directory path.
@return Whether the directory should be analyzed.

Definition at line 179 of file check-style-clang-format.py.

Referenced by find_files_to_check_style().

+ Here is the caller graph for this function:

◆ should_analyze_file()

bool check-style-clang-format.should_analyze_file ( str path,
List[str] files_to_check,
List[str] file_extensions_to_check )
Check whether a file should be analyzed.

@param path Path to the file.
@param files_to_check List of files that shall be checked.
@param file_extensions_to_check List of file extensions that shall be checked.
@return Whether the file should be analyzed.

Definition at line 192 of file check-style-clang-format.py.

Referenced by find_files_to_check_style().

+ Here is the caller graph for this function:

Variable Documentation

◆ action

check-style-clang-format.action

Definition at line 1011 of file check-style-clang-format.py.

◆ all_checks_successful

bool check-style-clang-format.all_checks_successful
Initial value:
1= check_style_clang_format(
2 paths=args.paths,
3 checks_enabled={
4 "include_prefixes": not args.no_include_prefixes,
5 "include_quotes": not args.no_include_quotes,
6 "doxygen_tags": not args.no_doxygen_tags,
7 "license": not args.no_licenses,
8 "emacs": not args.no_emacs,
9 "whitespace": not args.no_whitespace,
10 "tabs": not args.no_tabs,
11 "formatting": not args.no_formatting,
12 "encoding": not args.no_encoding,
13 },
14 fix=args.fix,
15 verbose=args.verbose,
16 n_jobs=args.jobs,
17 )

Definition at line 1095 of file check-style-clang-format.py.

◆ args

check-style-clang-format.args = parser.parse_args()

Definition at line 1092 of file check-style-clang-format.py.

◆ CHECKS

list check-style-clang-format.CHECKS
Initial value:
1= [
2 "include_prefixes",
3 "include_quotes",
4 "doxygen_tags",
5 "license",
6 "emacs",
7 "whitespace",
8 "tabs",
9 "formatting",
10 "encoding",
11]

Definition at line 77 of file check-style-clang-format.py.

◆ CLANG_FORMAT_MAX_VERSION

int check-style-clang-format.CLANG_FORMAT_MAX_VERSION = 17

PARAMETERS.

Definition at line 44 of file check-style-clang-format.py.

◆ CLANG_FORMAT_MIN_VERSION

int check-style-clang-format.CLANG_FORMAT_MIN_VERSION = 15

Definition at line 45 of file check-style-clang-format.py.

◆ default

check-style-clang-format.default

Definition at line 1088 of file check-style-clang-format.py.

◆ DIRECTORIES_TO_SKIP

list check-style-clang-format.DIRECTORIES_TO_SKIP
Initial value:
1= [
2 "__pycache__",
3 ".git",
4 ".venv",
5 "bindings",
6 "build",
7 "cmake-cache",
8 "testpy-output",
9 "venv",
10]

Definition at line 59 of file check-style-clang-format.py.

◆ FILE_ENCODING

str check-style-clang-format.FILE_ENCODING = "UTF-8"

Definition at line 173 of file check-style-clang-format.py.

◆ FILE_EXTENSIONS_TO_CHECK

dict check-style-clang-format.FILE_EXTENSIONS_TO_CHECK = {c: [] for c in CHECKS}

Definition at line 107 of file check-style-clang-format.py.

◆ FILES_TO_CHECK

dict check-style-clang-format.FILES_TO_CHECK = {c: [] for c in CHECKS}

Definition at line 90 of file check-style-clang-format.py.

◆ FILES_TO_SKIP

list check-style-clang-format.FILES_TO_SKIP
Initial value:
1= [
2 "valgrind.h",
3]

Definition at line 72 of file check-style-clang-format.py.

◆ FORMAT_GUARD_OFF

list check-style-clang-format.FORMAT_GUARD_OFF
Initial value:
1= [
2 "// clang-format off",
3 "# cmake-format: off",
4 "# fmt: off",
5]

Definition at line 53 of file check-style-clang-format.py.

◆ FORMAT_GUARD_ON

list check-style-clang-format.FORMAT_GUARD_ON
Initial value:
1= [
2 "// clang-format on",
3 "# cmake-format: on",
4 "# fmt: on",
5]

Definition at line 47 of file check-style-clang-format.py.

◆ help

check-style-clang-format.help

Definition at line 1014 of file check-style-clang-format.py.

◆ nargs

check-style-clang-format.nargs

Definition at line 1013 of file check-style-clang-format.py.

◆ parser

check-style-clang-format.parser
Initial value:
1= argparse.ArgumentParser(
2 description="Check and apply the ns-3 coding style recursively to all files in the given PATHs. "
3 "The script checks the formatting of the files using clang-format and"
4 " other coding style rules manually (see script arguments). "
5 "All checks respect clang-format guards, except trailing whitespace and file encoding,"
6 " which are always checked. "
7 'When used in "check mode" (default), the script runs all checks in all files. '
8 "If it detects non-formatted files, they will be printed and this process exits with a non-zero code. "
9 'When used in "fix mode", this script automatically fixes the files and exits with 0 code.'
10 )

Definition at line 998 of file check-style-clang-format.py.

◆ sep

check-style-clang-format.sep

Definition at line 1126 of file check-style-clang-format.py.

◆ TAB_SIZE

int check-style-clang-format.TAB_SIZE = 4

Definition at line 172 of file check-style-clang-format.py.

◆ type

check-style-clang-format.type

Definition at line 1012 of file check-style-clang-format.py.