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

Functions

bool check_formatting (List[str] filenames, bool fix, bool verbose, int n_jobs)
 CHECK FORMATTING.
 
Tuple[str, bool, List[str]] check_formatting_file (str filename, str clang_format_path, bool fix, bool verbose)
 
None check_style (str path, bool enable_check_formatting, bool enable_check_whitespace, bool enable_check_tabs, bool fix, bool verbose, int n_jobs=1)
 CHECK STYLE.
 
bool check_tabs (List[str] filenames, bool fix, bool verbose, int n_jobs)
 CHECK TABS.
 
Tuple[str, bool, List[str]] check_tabs_file (str filename, bool fix, bool verbose)
 
bool check_trailing_whitespace (List[str] filenames, bool fix, bool verbose, int n_jobs)
 CHECK TRAILING WHITESPACE.
 
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]] find_files_to_check_style (str path)
 
bool skip_directory (str dirpath)
 AUXILIARY FUNCTIONS.
 
bool skip_file_formatting (str path)
 
bool skip_file_tabs (str path)
 
bool skip_file_whitespace (str path)
 

Variables

 action
 
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
 
 enable_check_formatting
 
 enable_check_tabs
 
 enable_check_whitespace
 
list 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
 
 fix
 
 help
 
 int
 
 n_jobs
 
argparse parser
 MAIN.
 
 path
 
int TAB_SIZE = 4
 
 try :
 
 type
 
 verbose
 

Function Documentation

◆ check_formatting()

bool check-style-clang-format.check_formatting ( List[str]  filenames,
bool  fix,
bool  verbose,
int  n_jobs 
)

CHECK FORMATTING.

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

@param filenames List of filenames to be checked.
@param fix Whether to fix the formatting of the file (True) or
           just check if the file is well-formatted (False).
@param verbose Show the lines that are not well-formatted.
@param n_jobs Number of parallel jobs.
@return True if all files are well formatted after the check process.
        False if there are non-formatted files after the check process.

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

References find_clang_format_path().

Referenced by check_style().

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

◆ check_formatting_file()

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

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

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

◆ check_style()

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

CHECK STYLE.

Check / fix the coding style of a list of files, including formatting and
trailing whitespace.

@param path Path to the files.
@param fix Whether to fix the style of the file (True) or
           just check if the file is well-formatted (False).
@param enable_check_formatting Whether to enable code formatting checking.
@param enable_check_whitespace Whether to enable trailing whitespace checking.
@param enable_check_tabs Whether to enable tabs checking.
@param verbose Show the lines that are not well-formatted.
@param n_jobs Number of parallel jobs.

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

References check_formatting(), check_tabs(), check_trailing_whitespace(), and find_files_to_check_style().

+ Here is the call graph for this function:

◆ check_tabs()

bool check-style-clang-format.check_tabs ( List[str]  filenames,
bool  fix,
bool  verbose,
int  n_jobs 
)

CHECK TABS.

Check / fix tabs in a list of files.

@param filename Name of the file to be checked.
@param fix Whether to fix the file (True) or just check if it has tabs (False).
@param verbose Show the lines that are not well-formatted.
@param n_jobs Number of parallel jobs.
@return True if no files have tabs after the check process.
        False if there are tabs after the check process.

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

Referenced by check_style().

+ 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 the file (True) or just check if it has tabs (False).
@param verbose Show the lines that are not well-formatted.
@return Tuple [Filename, Whether the file has tabs, Verbose information].

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

◆ check_trailing_whitespace()

bool check-style-clang-format.check_trailing_whitespace ( List[str]  filenames,
bool  fix,
bool  verbose,
int  n_jobs 
)

CHECK TRAILING WHITESPACE.

Check / fix trailing whitespace in a list of files.

@param filename Name of the file to be checked.
@param fix Whether to fix the file (True) or
           just check if it has trailing whitespace (False).
@param verbose Show the lines that are not well-formatted.
@param n_jobs Number of parallel jobs.
@return True if no files have trailing whitespace after the check process.
        False if there are trailing whitespace after the check process.

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

Referenced by check_style().

+ Here is the caller graph for this function:

◆ 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 the file (True) or
           just check if it has trailing whitespace (False).
@param verbose Show the lines that are not well-formatted.
@return Tuple [Filename, Whether the file has trailing whitespace, Verbose information].

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

References int.

Referenced by check_formatting().

+ Here is the caller graph for this function:

◆ find_files_to_check_style()

Tuple[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 formatting,
               List of files to check trailing whitespace,
               List of files to check tabs].

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

References skip_directory(), skip_file_formatting(), skip_file_tabs(), and skip_file_whitespace().

Referenced by check_style().

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

◆ skip_directory()

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

AUXILIARY FUNCTIONS.

Check if a directory should be skipped.

@param dirpath Directory path.
@return Whether the directory should be skipped or not.

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:

◆ skip_file_formatting()

bool check-style-clang-format.skip_file_formatting ( str  path)
Check if a file should be skipped from formatting analysis.

@param path Path to the file.
@return Whether the file should be skipped or not.

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:

◆ skip_file_tabs()

bool check-style-clang-format.skip_file_tabs ( str  path)
Check if a file should be skipped from tabs analysis.

@param path Path to the file.
@return Whether the file should be skipped or not.

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

Referenced by find_files_to_check_style().

+ Here is the caller graph for this function:

◆ skip_file_whitespace()

bool check-style-clang-format.skip_file_whitespace ( str  path)
Check if a file should be skipped from trailing whitespace analysis.

@param path Path to the file.
@return Whether the file should be skipped or not.

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

◆ args

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

Definition at line 759 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 60 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 59 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 53 of file check-style-clang-format.py.

◆ default

check-style-clang-format.default

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

◆ enable_check_formatting

check-style-clang-format.enable_check_formatting

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

◆ enable_check_tabs

check-style-clang-format.enable_check_tabs

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

◆ enable_check_whitespace

check-style-clang-format.enable_check_whitespace

Definition at line 765 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 77 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 73 of file check-style-clang-format.py.

◆ fix

check-style-clang-format.fix

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

◆ help

check-style-clang-format.help

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

◆ int

check-style-clang-format.int

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

Referenced by find_clang_format_path().

◆ n_jobs

check-style-clang-format.n_jobs

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

◆ 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 the presence of trailing whitespace and tabs. '
5 'Formatting and tabs checks respect clang-format guards. '
6 'When used in "check mode" (default), the script checks if all files are well '
7 'formatted and do not have trailing whitespace nor tabs. '
8 'If it detects non-formatted files, they will be printed and this process exits with a '
9 'non-zero code. When used in "fix mode", this script automatically fixes the files.')

MAIN.

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

◆ path

check-style-clang-format.path

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

◆ type

check-style-clang-format.type

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

◆ verbose

check-style-clang-format.verbose

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