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

Functions

Tuple[str, bool, List[str]] check_formatting_file (str filename, bool fix, bool verbose, str clang_format_path)
 
Tuple[str, bool, List[str]] check_include_prefixes_file (str filename, bool fix, bool verbose)
 CHECK STYLE FUNCTIONS.
 
bool check_style_clang_format (str path, bool enable_check_include_prefixes, bool enable_check_formatting, bool enable_check_whitespace, bool enable_check_tabs, bool fix, bool verbose, int n_jobs=1)
 CHECK STYLE MAIN FUNCTIONS.
 
bool check_style_file (List[str] filenames, Callable check_style_file_function, str style_check_str, bool fix, bool verbose, int n_jobs, **kwargs)
 
Tuple[str, bool, List[str]] check_tabs_file (str filename, bool fix, bool verbose)
 
Tuple[str, bool, List[str]] check_trailing_whitespace_file (str filename, bool fix, bool verbose)
 
str find_clang_format_path ()
 
Tuple[List[str], List[str], List[str], List[str]] find_files_to_check_style (str path)
 
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
 
argparse args = parser.parse_args()
 
str CLANG_FORMAT_GUARD_OFF = '// clang-format off'
 
str CLANG_FORMAT_GUARD_ON = '// clang-format on'
 
list CLANG_FORMAT_VERSIONS
 PARAMETERS.
 
 default
 
list DIRECTORIES_TO_SKIP
 
 else :
 
list FILE_EXTENSIONS_TO_CHECK_FORMATTING
 
list FILE_EXTENSIONS_TO_CHECK_INCLUDE_PREFIXES = FILE_EXTENSIONS_TO_CHECK_FORMATTING
 
list FILE_EXTENSIONS_TO_CHECK_TABS
 
list FILE_EXTENSIONS_TO_CHECK_WHITESPACE
 
list FILES_TO_CHECK_WHITESPACE
 
list FILES_TO_SKIP
 
 help
 
 int
 
argparse parser
 MAIN.
 
int TAB_SIZE = 4
 
 try :
 
 type
 

Function Documentation

◆ 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 / 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 (True).
@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 501 of file check-style-clang-format.py.

◆ check_include_prefixes_file()

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

CHECK STYLE FUNCTIONS.

Check / fix #include headers from the same module with the "ns3/" prefix in a file.

@param filename Name of the file to be checked.
@param fix Whether to fix (True) or just check (False) the style of the file (True).
@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 426 of file check-style-clang-format.py.

◆ check_style_clang_format()

bool check-style-clang-format.check_style_clang_format ( str  path,
bool  enable_check_include_prefixes,
bool  enable_check_formatting,
bool  enable_check_whitespace,
bool  enable_check_tabs,
bool  fix,
bool  verbose,
int   n_jobs = 1 
)

CHECK STYLE MAIN FUNCTIONS.

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

@param path Path to the files.
@param enable_check_include_prefixes Whether to enable checking #include headers from the same module with the "ns3/" prefix.
@param enable_check_formatting Whether to enable checking code formatting.
@param enable_check_whitespace Whether to enable checking trailing whitespace.
@param enable_check_tabs Whether to enable checking tabs.
@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 271 of file check-style-clang-format.py.

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

+ Here is the call graph for this function:

◆ check_style_file()

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

@param filename Name of the file to be checked.
@param check_style_file_function Function used to check the file.
@param style_check_str Description of the check to be performed.
@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 359 of file check-style-clang-format.py.

Referenced by check_style_clang_format().

+ Here is the caller graph for this function:

◆ check_tabs_file()

Tuple[str, bool, List[str]] check-style-clang-format.check_tabs_file ( str  filename,
bool  fix,
bool  verbose 
)
Check / fix tabs in a file.

@param filename Name of the file to be checked.
@param fix Whether to fix (True) or just check (False) the style of the file (True).
@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 610 of file check-style-clang-format.py.

◆ check_trailing_whitespace_file()

Tuple[str, bool, List[str]] check-style-clang-format.check_trailing_whitespace_file ( str  filename,
bool  fix,
bool  verbose 
)
Check / fix trailing whitespace in a file.

@param filename Name of the file to be checked.
@param fix Whether to fix (True) or just check (False) the style of the file (True).
@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.

◆ 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 229 of file check-style-clang-format.py.

References int.

Referenced by check_style_clang_format().

+ Here is the caller graph for this function:

◆ find_files_to_check_style()

Tuple[List[str], List[str], List[str], List[str]] check-style-clang-format.find_files_to_check_style ( str  path)
Find all files to be checked in a given path.

@param path Path to check.
@return Tuple [List of files to check include prefixes,
               List of files to check formatting,
               List of files to check trailing whitespace,
               List of files to check tabs].

Definition at line 172 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 134 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 148 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 691 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 path=args.path,
3 enable_check_include_prefixes=(not args.no_include_prefixes),
4 enable_check_formatting=(not args.no_formatting),
5 enable_check_whitespace=(not args.no_whitespace),
6 enable_check_tabs=(not args.no_tabs),
7 fix=args.fix,
8 verbose=args.verbose,
9 n_jobs=args.jobs,
10 )

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

◆ args

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

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

◆ CLANG_FORMAT_GUARD_OFF

str check-style-clang-format.CLANG_FORMAT_GUARD_OFF = '// clang-format off'

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

◆ CLANG_FORMAT_GUARD_ON

str check-style-clang-format.CLANG_FORMAT_GUARD_ON = '// clang-format on'

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

◆ CLANG_FORMAT_VERSIONS

list check-style-clang-format.CLANG_FORMAT_VERSIONS
Initial value:
1= [
2 16,
3 15,
4 14,
5]

PARAMETERS.

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

◆ default

check-style-clang-format.default

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

◆ DIRECTORIES_TO_SKIP

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

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

◆ else

check-style-clang-format.else :

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

◆ FILE_EXTENSIONS_TO_CHECK_FORMATTING

list check-style-clang-format.FILE_EXTENSIONS_TO_CHECK_FORMATTING
Initial value:
1= [
2 '.c',
3 '.cc',
4 '.h',
5]

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

◆ FILE_EXTENSIONS_TO_CHECK_INCLUDE_PREFIXES

list check-style-clang-format.FILE_EXTENSIONS_TO_CHECK_INCLUDE_PREFIXES = FILE_EXTENSIONS_TO_CHECK_FORMATTING

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

◆ FILE_EXTENSIONS_TO_CHECK_TABS

list check-style-clang-format.FILE_EXTENSIONS_TO_CHECK_TABS
Initial value:
1= [
2 '.c',
3 '.cc',
4 '.h',
5 '.md',
6 '.py',
7 '.rst',
8 '.sh',
9 '.yml',
10]

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

◆ FILE_EXTENSIONS_TO_CHECK_WHITESPACE

list check-style-clang-format.FILE_EXTENSIONS_TO_CHECK_WHITESPACE
Initial value:
1= [
2 '.c',
3 '.cc',
4 '.click',
5 '.cmake',
6 '.conf',
7 '.css',
8 '.dot',
9 '.gnuplot',
10 '.gp',
11 '.h',
12 '.html',
13 '.js',
14 '.json',
15 '.m',
16 '.md',
17 '.mob',
18 '.ns_params',
19 '.ns_movements',
20 '.params',
21 '.pl',
22 '.plt',
23 '.py',
24 '.rst',
25 '.seqdiag',
26 '.sh',
27 '.txt',
28 '.yml',
29]

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

◆ FILES_TO_CHECK_WHITESPACE

list check-style-clang-format.FILES_TO_CHECK_WHITESPACE
Initial value:
1= [
2 'Makefile',
3 'ns3',
4]

Definition at line 113 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 71 of file check-style-clang-format.py.

◆ help

check-style-clang-format.help

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

◆ int

check-style-clang-format.int

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

Referenced by find_clang_format_path().

◆ parser

argparse check-style-clang-format.parser
Initial value:
1= argparse.ArgumentParser(
2 description='Check and apply the ns-3 coding style to all files in a given PATH. '
3 'The script checks the formatting of the file with clang-format. '
4 'Additionally, it checks #include headers from the same module with the "ns3/" prefix, '
5 'the presence of trailing whitespace and tabs. '
6 'Formatting, local #include "ns3/" prefixes and tabs checks respect clang-format guards. '
7 'When used in "check mode" (default), the script checks if all files are well '
8 'formatted and do not have trailing whitespace nor tabs. '
9 'If it detects non-formatted files, they will be printed and this process exits with a '
10 'non-zero code. When used in "fix mode", this script automatically fixes the files.')

MAIN.

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

◆ TAB_SIZE

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

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

◆ try

check-style-clang-format.try :

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

◆ type

check-style-clang-format.type

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