Classes | |
class | _BlockInfo |
class | _ClassInfo |
class | _CppLintState |
class | _ExternCInfo |
class | _FunctionState |
class | _IncludeError |
class | _IncludeState |
class | _NamespaceInfo |
class | _PreprocessorInfo |
class | CleansedLines |
class | FileInfo |
class | NestingState |
Functions | |
def | _AddFilters (filters) |
def | _BackupFilters () |
def | _ClassifyInclude (fileinfo, include, is_system) |
def | _DropCommonSuffixes (filename) |
def | _Filters () |
def | _GetTextInside (text, start_pattern) |
def | _IsTestFilename (filename) |
def | _OutputFormat () |
def | _RestoreFilters () |
def | _SetCountingStyle (level) |
def | _SetFilters (filters) |
def | _SetOutputFormat (output_format) |
def | _SetVerboseLevel (level) |
def | _ShouldPrintError (category, confidence, linenum) |
def | _VerboseLevel () |
def | CheckAccess (filename, clean_lines, linenum, nesting_state, error) |
def | CheckAltTokens (filename, clean_lines, linenum, error) |
def | CheckBraces (filename, clean_lines, linenum, error) |
def | CheckBracesSpacing (filename, clean_lines, linenum, error) |
def | CheckCasts (filename, clean_lines, linenum, error) |
def | CheckCheck (filename, clean_lines, linenum, error) |
def | CheckCommaSpacing (filename, clean_lines, linenum, error) |
def | CheckComment (line, filename, linenum, next_line_start, error) |
def | CheckCStyleCast (filename, clean_lines, linenum, cast_type, pattern, error) |
def | CheckDefaultLambdaCaptures (filename, clean_lines, linenum, error) |
def | CheckEmptyBlockBody (filename, clean_lines, linenum, error) |
def | CheckForBadCharacters (filename, lines, error) |
def | CheckForCopyright (filename, lines, error) |
def | CheckForFunctionLengths (filename, clean_lines, linenum, function_state, error) |
def | CheckForHeaderGuard (filename, clean_lines, error) |
def | CheckForIncludeWhatYouUse (filename, clean_lines, include_state, error, io=codecs) |
def | CheckForMultilineCommentsAndStrings (filename, clean_lines, linenum, error) |
def | CheckForNamespaceIndentation (filename, nesting_state, clean_lines, line, error) |
def | CheckForNewlineAtEOF (filename, lines, error) |
def | CheckForNonConstReference (filename, clean_lines, linenum, nesting_state, error) |
def | CheckForNonStandardConstructs (filename, clean_lines, linenum, nesting_state, error) |
def | CheckGlobalStatic (filename, clean_lines, linenum, error) |
def | CheckHeaderFileIncluded (filename, include_state, error) |
def | CheckIncludeLine (filename, clean_lines, linenum, include_state, error) |
def | CheckInvalidIncrement (filename, clean_lines, linenum, error) |
def | CheckItemIndentationInNamespace (filename, raw_lines_no_comments, linenum, error) |
def | CheckLanguage (filename, clean_lines, linenum, file_extension, include_state, nesting_state, error) |
def | CheckMakePairUsesDeduction (filename, clean_lines, linenum, error) |
def | CheckOperatorSpacing (filename, clean_lines, linenum, error) |
def | CheckParenthesisSpacing (filename, clean_lines, linenum, error) |
def | CheckPosixThreading (filename, clean_lines, linenum, error) |
def | CheckPrintf (filename, clean_lines, linenum, error) |
def | CheckRedundantOverrideOrFinal (filename, clean_lines, linenum, error) |
def | CheckRedundantVirtual (filename, clean_lines, linenum, error) |
def | CheckRValueReference (filename, clean_lines, linenum, nesting_state, error) |
def | CheckSectionSpacing (filename, clean_lines, class_info, linenum, error) |
def | CheckSpacing (filename, clean_lines, linenum, nesting_state, error) |
def | CheckSpacingForFunctionCall (filename, clean_lines, linenum, error) |
def | CheckStyle (filename, clean_lines, linenum, file_extension, nesting_state, error) |
def | CheckTrailingSemicolon (filename, clean_lines, linenum, error) |
def | CheckVlogArguments (filename, clean_lines, linenum, error) |
def | CleanseComments (line) |
def | CleanseRawStrings (raw_lines) |
def | CloseExpression (clean_lines, linenum, pos) |
def | Error (filename, linenum, category, confidence, message) |
def | ExpectingFunctionArgs (clean_lines, linenum) |
def | FilesBelongToSameModule (filename_cc, filename_h) |
def | FindCheckMacro (line) |
def | FindEndOfExpressionInLine (line, startpos, stack) |
def | FindNextMultiLineCommentEnd (lines, lineix) |
def | FindNextMultiLineCommentStart (lines, lineix) |
def | FindStartOfExpressionInLine (line, endpos, stack) |
def | FlagCxx11Features (filename, clean_lines, linenum, error) |
def | GetHeaderGuardCPPVariable (filename) |
def | GetIndentLevel (line) |
def | GetLineWidth (line) |
def | GetPreviousNonBlankLine (clean_lines, linenum) |
def | GetTemplateArgs (clean_lines, linenum) |
def | IsBlankLine (line) |
def | IsBlockInNameSpace (nesting_state, is_forward_declaration) |
def | IsCppString (line) |
def | IsDecltype (clean_lines, linenum, column) |
def | IsDeletedOrDefault (clean_lines, linenum) |
def | IsDerivedFunction (clean_lines, linenum) |
def | IsErrorSuppressedByNolint (category, linenum) |
def | IsForwardClassDeclaration (clean_lines, linenum) |
def | IsInitializerList (clean_lines, linenum) |
def | IsMacroDefinition (clean_lines, linenum) |
def | IsOutOfLineMethodDefinition (clean_lines, linenum) |
def | IsRValueAllowed (clean_lines, linenum, typenames) |
def | IsRValueType (typenames, clean_lines, nesting_state, linenum, column) |
def | IsTemplateParameterList (clean_lines, linenum, column) |
def | main () |
def | Match (pattern, s) |
def | ParseArguments (args) |
def | ParseNolintSuppressions (filename, raw_line, linenum, error) |
def | PrintCategories () |
def | PrintUsage (message) |
def | ProcessConfigOverrides (filename) |
def | ProcessFile (filename, vlevel, extra_check_functions=[]) |
def | ProcessFileData (filename, file_extension, lines, error, extra_check_functions=[]) |
def | ProcessLine (filename, file_extension, clean_lines, line, include_state, function_state, nesting_state, error, extra_check_functions=[]) |
def | RemoveMultiLineComments (filename, lines, error) |
def | RemoveMultiLineCommentsFromRange (lines, begin, end) |
def | ReplaceAll (pattern, rep, s) |
def | ResetNolintSuppressions () |
def | ReverseCloseExpression (clean_lines, linenum, pos) |
def | Search (pattern, s) |
def | ShouldCheckNamespaceIndentation (nesting_state, is_namespace_indent_item, raw_lines_no_comments, linenum) |
def | UpdateIncludeState (filename, include_dict, io=codecs) |
|
private |
Adds more filter overrides. Unlike _SetFilters, this function does not reset the current list of filters available. Args: filters: A string of comma-separated filters (eg "whitespace/indent"). Each filter should start with + or -; else we die.
Definition at line 898 of file cpplint.py.
|
private |
Saves the current filter list to backup storage.
Definition at line 910 of file cpplint.py.
|
private |
Figures out what kind of header 'include' is. Args: fileinfo: The current file cpplint is running over. A FileInfo instance. include: The path to a #included file. is_system: True if the #include used <> rather than "". Returns: One of the _XXX_HEADER constants. For example: >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'stdio.h', True) _C_SYS_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'string', True) _CPP_SYS_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', False) _LIKELY_MY_HEADER >>> _ClassifyInclude(FileInfo('foo/foo_unknown_extension.cc'), ... 'bar/foo_other_ext.h', False) _POSSIBLE_MY_HEADER >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/bar.h', False) _OTHER_HEADER
Definition at line 4550 of file cpplint.py.
|
private |
Drops common suffixes like _test.cc or -inl.h from filename. For example: >>> _DropCommonSuffixes('foo/foo-inl.h') 'foo/foo' >>> _DropCommonSuffixes('foo/bar/foo.cc') 'foo/bar/foo' >>> _DropCommonSuffixes('foo/foo_internal.h') 'foo/foo' >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') 'foo/foo_unusualinternal' Args: filename: The input filename. Returns: The filename with the common suffix removed.
Definition at line 4506 of file cpplint.py.
|
private |
Returns the module's list of output filters, as a list.
Definition at line 881 of file cpplint.py.
|
private |
Definition at line 4684 of file cpplint.py.
|
private |
Determines if the given filename has a suffix that identifies it as a test. Args: filename: The input filename. Returns: True if 'filename' looks like a test, False otherwise.
Definition at line 4533 of file cpplint.py.
|
private |
Gets the module's output format.
Definition at line 856 of file cpplint.py.
|
private |
Restores filters previously backed up.
Definition at line 914 of file cpplint.py.
|
private |
Sets the module's counting options.
Definition at line 876 of file cpplint.py.
|
private |
Sets the module's error-message filters. These filters are applied when deciding whether to emit a given error message. Args: filters: A string of comma-separated filters (eg "whitespace/indent"). Each filter should start with + or -; else we die.
Definition at line 886 of file cpplint.py.
|
private |
Sets the module's output format.
Definition at line 861 of file cpplint.py.
|
private |
Sets the module's verbosity, and returns the previous setting.
Definition at line 871 of file cpplint.py.
|
private |
If confidence >= verbose, category passes filter and is not suppressed.
Definition at line 1069 of file cpplint.py.
|
private |
Returns the module's verbosity setting.
Definition at line 866 of file cpplint.py.
def roslint.cpplint.CheckAccess | ( | filename, | |
clean_lines, | |||
linenum, | |||
nesting_state, | |||
error | |||
) |
Checks for improper use of DISALLOW* macros. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found.
Definition at line 2974 of file cpplint.py.
def roslint.cpplint.CheckAltTokens | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Check alternative keywords being used in boolean expressions. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 4324 of file cpplint.py.
def roslint.cpplint.CheckBraces | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Looks for misplaced braces (e.g. at the end of line). Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 3895 of file cpplint.py.
def roslint.cpplint.CheckBracesSpacing | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks for horizontal spacing near commas. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 3321 of file cpplint.py.
def roslint.cpplint.CheckCasts | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Various cast related checks. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 5223 of file cpplint.py.
def roslint.cpplint.CheckCheck | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks the use of CHECK and EXPECT macros. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 4206 of file cpplint.py.
def roslint.cpplint.CheckCommaSpacing | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks for horizontal spacing near commas and semicolons. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 3285 of file cpplint.py.
def roslint.cpplint.CheckComment | ( | line, | |
filename, | |||
linenum, | |||
next_line_start, | |||
error | |||
) |
Checks for common mistakes in comments. Args: line: The line in question. filename: The name of the current file. linenum: The number of the line to check. next_line_start: The first non-whitespace column of the next line. error: The function to call with any errors found.
Definition at line 2918 of file cpplint.py.
def roslint.cpplint.CheckCStyleCast | ( | filename, | |
clean_lines, | |||
linenum, | |||
cast_type, | |||
pattern, | |||
error | |||
) |
Checks for a C-style cast by looking for the pattern. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. cast_type: The string for the C++ cast to recommend. This is either reinterpret_cast, static_cast, or const_cast, depending. pattern: The regular expression used to find C-style casts. error: The function to call with any errors found. Returns: True if an error was emitted. False otherwise.
Definition at line 5342 of file cpplint.py.
def roslint.cpplint.CheckDefaultLambdaCaptures | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Check that default lambda captures are not used. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 5727 of file cpplint.py.
def roslint.cpplint.CheckEmptyBlockBody | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Look for empty loop/conditional body with only a single semicolon. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 4148 of file cpplint.py.
def roslint.cpplint.CheckForBadCharacters | ( | filename, | |
lines, | |||
error | |||
) |
Logs an error for each line containing bad characters. Two kinds of bad characters: 1. Unicode replacement characters: These indicate that either the file contained invalid UTF-8 (likely) or Unicode replacement characters (which it shouldn't). Note that it's possible for this to throw off line numbering if the invalid UTF-8 occurred adjacent to a newline. 2. NUL bytes. These are problematic for some tools. Args: filename: The name of the current file. lines: An array of strings, each representing a line of the file. error: The function to call with any errors found.
Definition at line 1805 of file cpplint.py.
def roslint.cpplint.CheckForCopyright | ( | filename, | |
lines, | |||
error | |||
) |
Logs an error if no Copyright message appears at the top of the file.
Definition at line 1627 of file cpplint.py.
def roslint.cpplint.CheckForFunctionLengths | ( | filename, | |
clean_lines, | |||
linenum, | |||
function_state, | |||
error | |||
) |
Reports for long function bodies. For an overview why this is done, see: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions Uses a simplistic algorithm assuming other style guidelines (especially spacing) are followed. Only checks unindented functions, so class members are unchecked. Trivial bodies are unchecked, so constructors with huge initializer lists may be missed. Blank/comment lines are not counted so as to avoid encouraging the removal of vertical space and comments just to get through a lint check. NOLINT *on the last line of a function* disables this check. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. function_state: Current function name and lines in body so far. error: The function to call with any errors found.
Definition at line 2848 of file cpplint.py.
def roslint.cpplint.CheckForHeaderGuard | ( | filename, | |
clean_lines, | |||
error | |||
) |
Checks that the file contains a header guard. Logs an error if no #ifndef header guard is present. For other headers, checks that the full pathname is used. Args: filename: The name of the C++ header file. clean_lines: A CleansedLines instance containing the file. error: The function to call with any errors found.
Definition at line 1682 of file cpplint.py.
def roslint.cpplint.CheckForIncludeWhatYouUse | ( | filename, | |
clean_lines, | |||
include_state, | |||
error, | |||
io = codecs |
|||
) |
Reports for missing stl includes. This function will output warnings to make sure you are including the headers necessary for the stl containers and functions that you use. We only give one reason to include a header. For example, if you use both equal_to<> and less<> in a .h file, only one (the latter in the file) of these will be reported as a reason to include the <functional>. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. include_state: An _IncludeState instance. error: The function to call with any errors found. io: The IO factory to use to read the header file. Provided for unittest injection.
Definition at line 5610 of file cpplint.py.
def roslint.cpplint.CheckForMultilineCommentsAndStrings | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Logs an error if we see /* ... */ or "..." that extend past one line. /* ... */ comments are legit inside macros, for one line. Otherwise, we prefer // comments, so it's ok to warn about the other. Likewise, it's ok for strings to extend across multiple lines, as long as a line continuation character (backslash) terminates each line. Although not currently prohibited by the C++ style guide, it's ugly and unnecessary. We don't do well with either in this lint program, so we warn about both. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 1848 of file cpplint.py.
def roslint.cpplint.CheckForNamespaceIndentation | ( | filename, | |
nesting_state, | |||
clean_lines, | |||
line, | |||
error | |||
) |
Definition at line 2834 of file cpplint.py.
def roslint.cpplint.CheckForNewlineAtEOF | ( | filename, | |
lines, | |||
error | |||
) |
Logs an error if there is no newline char at the end of the file. Args: filename: The name of the current file. lines: An array of strings, each representing a line of the file. error: The function to call with any errors found.
Definition at line 1830 of file cpplint.py.
def roslint.cpplint.CheckForNonConstReference | ( | filename, | |
clean_lines, | |||
linenum, | |||
nesting_state, | |||
error | |||
) |
Check for non-const references. Separate from CheckLanguage since it scans backwards from current line, instead of scanning forward. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found.
Definition at line 5086 of file cpplint.py.
def roslint.cpplint.CheckForNonStandardConstructs | ( | filename, | |
clean_lines, | |||
linenum, | |||
nesting_state, | |||
error | |||
) |
Definition at line 2579 of file cpplint.py.
def roslint.cpplint.CheckGlobalStatic | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Check for unsafe global or static objects. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 4924 of file cpplint.py.
def roslint.cpplint.CheckHeaderFileIncluded | ( | filename, | |
include_state, | |||
error | |||
) |
Logs an error if a .cc file does not include its header.
Definition at line 1780 of file cpplint.py.
def roslint.cpplint.CheckIncludeLine | ( | filename, | |
clean_lines, | |||
linenum, | |||
include_state, | |||
error | |||
) |
Check rules that are applicable to #include lines. Strings on #include lines are NOT removed from elided line, to make certain tasks easier. However, to prevent false positives, checks applicable to #include lines in CheckLanguage must be put here. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. include_state: An _IncludeState instance in which the headers are inserted. error: The function to call with any errors found.
Definition at line 4610 of file cpplint.py.
def roslint.cpplint.CheckInvalidIncrement | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks for invalid increment *count++. For example following function: void increment_counter(int* count) { *count++; } is invalid, because it effectively does count++, moving pointer, and should be replaced with ++*count, (*count)++ or *count += 1. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 1966 of file cpplint.py.
def roslint.cpplint.CheckItemIndentationInNamespace | ( | filename, | |
raw_lines_no_comments, | |||
linenum, | |||
error | |||
) |
Definition at line 5904 of file cpplint.py.
def roslint.cpplint.CheckLanguage | ( | filename, | |
clean_lines, | |||
linenum, | |||
file_extension, | |||
include_state, | |||
nesting_state, | |||
error | |||
) |
Checks rules from the 'C++ language rules' section of cppguide.html. Some of these rules are hard to test (function overloading, using uint32 inappropriately), but we do the best we can. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. file_extension: The extension (without the dot) of the filename. include_state: An _IncludeState instance in which the headers are inserted. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found.
Definition at line 4767 of file cpplint.py.
def roslint.cpplint.CheckMakePairUsesDeduction | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Check that make_pair's template arguments are deduced. G++ 4.6 in C++11 mode fails badly if make_pair's template arguments are specified explicitly, and such use isn't intended in any case. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 5706 of file cpplint.py.
def roslint.cpplint.CheckOperatorSpacing | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks for horizontal spacing around operators. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 3132 of file cpplint.py.
def roslint.cpplint.CheckParenthesisSpacing | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks for horizontal spacing around parentheses. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 3247 of file cpplint.py.
def roslint.cpplint.CheckPosixThreading | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks for calls to thread-unsafe functions. Much code has been originally written without consideration of multi-threading. Also, engineers are relying on their old experience; they have learned posix before threading extensions were added. These tests guide the engineers to use thread-safe functions (when using posix directly). Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 1916 of file cpplint.py.
def roslint.cpplint.CheckPrintf | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Check for printf related issues. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 4976 of file cpplint.py.
def roslint.cpplint.CheckRedundantOverrideOrFinal | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Check if line contains a redundant "override" or "final" virt-specifier. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 5816 of file cpplint.py.
def roslint.cpplint.CheckRedundantVirtual | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Check if line contains a redundant "virtual" function-specifier. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 5752 of file cpplint.py.
def roslint.cpplint.CheckRValueReference | ( | filename, | |
clean_lines, | |||
linenum, | |||
nesting_state, | |||
error | |||
) |
Check for rvalue references. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found.
Definition at line 3781 of file cpplint.py.
def roslint.cpplint.CheckSectionSpacing | ( | filename, | |
clean_lines, | |||
class_info, | |||
linenum, | |||
error | |||
) |
Checks for additional blank line issues related to sections. Currently the only thing checked here is blank line before protected/private. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. class_info: A _ClassInfo objects. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 3817 of file cpplint.py.
def roslint.cpplint.CheckSpacing | ( | filename, | |
clean_lines, | |||
linenum, | |||
nesting_state, | |||
error | |||
) |
Checks for the correctness of various spacing issues in the code. Things we check for: spaces around operators, spaces after if/for/while/switch, no spaces around parens in function calls, two spaces between code and comment, don't start a block with a blank line, don't end a function with a blank line, don't add a blank line after public/protected/private, don't have too many blank lines in a row. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found.
Definition at line 3004 of file cpplint.py.
def roslint.cpplint.CheckSpacingForFunctionCall | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks for the correctness of various spacing around function calls. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 2742 of file cpplint.py.
def roslint.cpplint.CheckStyle | ( | filename, | |
clean_lines, | |||
linenum, | |||
file_extension, | |||
nesting_state, | |||
error | |||
) |
Checks rules from the 'C++ style rules' section of cppguide.html. Most of these rules are hard to test (naming, comment style), but we do what we can. In particular we check for 2-space indents, line lengths, tab usage, spaces inside code, etc. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. file_extension: The extension (without the dot) of the filename. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: The function to call with any errors found.
Definition at line 4379 of file cpplint.py.
def roslint.cpplint.CheckTrailingSemicolon | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Looks for redundant trailing semicolon. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 4011 of file cpplint.py.
def roslint.cpplint.CheckVlogArguments | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Checks that VLOG() is only used for defining a logging level. For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and VLOG(FATAL) are not. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 1942 of file cpplint.py.
def roslint.cpplint.CleanseComments | ( | line | ) |
Removes //-comments and single-line C-style /* */ comments. Args: line: A line of C++ source. Returns: The line with single-line comments removed.
Definition at line 1279 of file cpplint.py.
def roslint.cpplint.CleanseRawStrings | ( | raw_lines | ) |
Removes C++11 raw strings from lines. Before: static const char kData[] = R"( multi-line string )"; After: static const char kData[] = "" (replaced by blank line) ""; Args: raw_lines: list of raw lines. Returns: list of lines with C++11 raw strings replaced by empty strings.
Definition at line 1169 of file cpplint.py.
def roslint.cpplint.CloseExpression | ( | clean_lines, | |
linenum, | |||
pos | |||
) |
If input points to ( or { or [ or <, finds the position that closes it. If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the linenum/pos that correspond to the closing of the expression. TODO(unknown): cpplint spends a fair bit of time matching parentheses. Ideally we would want to index all opening and closing parentheses once and have CloseExpression be just a simple lookup, but due to preprocessor tricks, this is not so easy. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: A position on the line. Returns: A tuple (line, linenum, pos) pointer *past* the closing brace, or (line, len(lines), -1) if we never find a close. Note we ignore strings and comments when matching; and the line we return is the 'cleansed' line at linenum.
Definition at line 1468 of file cpplint.py.
def roslint.cpplint.Error | ( | filename, | |
linenum, | |||
category, | |||
confidence, | |||
message | |||
) |
Logs the fact we've found a lint error. We log where the error was found, and also our confidence in the error, that is, how certain we are this is a legitimate style regression, and not a misidentification or a use that's sometimes justified. False positives can be suppressed by the use of "cpplint(category)" comments on the offending line. These are parsed into _error_suppressions. Args: filename: The name of the file containing the error. linenum: The number of the line containing the error. category: A string used to describe the "category" this bug falls under: "whitespace", say, or "runtime". Categories may have a hierarchy separated by slashes: "whitespace/indent". confidence: A number from 1-5 representing a confidence score for the error, with 5 meaning that we are certain of the problem, and 1 meaning that it could be a legitimate construct. message: The error message.
Definition at line 1097 of file cpplint.py.
def roslint.cpplint.ExpectingFunctionArgs | ( | clean_lines, | |
linenum | |||
) |
Checks whether where function type arguments are expected. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if the line at 'linenum' is inside something that expects arguments of function types.
Definition at line 5446 of file cpplint.py.
def roslint.cpplint.FilesBelongToSameModule | ( | filename_cc, | |
filename_h | |||
) |
Check if these two filenames belong to the same module. The concept of a 'module' here is a as follows: foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the same 'module' if they are in the same directory. some/path/public/xyzzy and some/path/internal/xyzzy are also considered to belong to the same module here. If the filename_cc contains a longer path than the filename_h, for example, '/absolute/path/to/base/sysinfo.cc', and this file would include 'base/sysinfo.h', this function also produces the prefix needed to open the header. This is used by the caller of this function to more robustly open the header file. We don't have access to the real include paths in this context, so we need this guesswork here. Known bugs: tools/base/bar.cc and base/bar.h belong to the same module according to this implementation. Because of this, this function gives some false positives. This should be sufficiently rare in practice. Args: filename_cc: is the path for the .cc file filename_h: is the path for the header path Returns: Tuple with a bool and a string: bool: True if filename_cc and filename_h belong to the same module. string: the additional prefix needed to open the header file.
Definition at line 5527 of file cpplint.py.
def roslint.cpplint.FindCheckMacro | ( | line | ) |
Find a replaceable CHECK-like macro. Args: line: line to search on. Returns: (macro name, start position), or (None, -1) if no replaceable macro is found.
Definition at line 4183 of file cpplint.py.
def roslint.cpplint.FindEndOfExpressionInLine | ( | line, | |
startpos, | |||
stack | |||
) |
Find the position just after the end of current parenthesized expression. Args: line: a CleansedLines line. startpos: start searching at this position. stack: nesting stack at startpos. Returns: On finding matching end: (index just after matching end, None) On finding an unclosed expression: (-1, None) Otherwise: (-1, new stack at end of this line)
Definition at line 1390 of file cpplint.py.
def roslint.cpplint.FindNextMultiLineCommentEnd | ( | lines, | |
lineix | |||
) |
We are inside a comment, find the end marker.
Definition at line 1246 of file cpplint.py.
def roslint.cpplint.FindNextMultiLineCommentStart | ( | lines, | |
lineix | |||
) |
Find the beginning marker for a multiline comment.
Definition at line 1235 of file cpplint.py.
def roslint.cpplint.FindStartOfExpressionInLine | ( | line, | |
endpos, | |||
stack | |||
) |
Find position at the matching start of current expression. This is almost the reverse of FindEndOfExpressionInLine, but note that the input position and returned position differs by 1. Args: line: a CleansedLines line. endpos: start searching at this position. stack: nesting stack at endpos. Returns: On finding matching start: (index at matching start, None) On finding an unclosed expression: (-1, None) Otherwise: (-1, new stack at beginning of this line)
Definition at line 1512 of file cpplint.py.
def roslint.cpplint.FlagCxx11Features | ( | filename, | |
clean_lines, | |||
linenum, | |||
error | |||
) |
Flag those c++11 features that we only allow in certain places. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
Definition at line 5956 of file cpplint.py.
def roslint.cpplint.GetHeaderGuardCPPVariable | ( | filename | ) |
Returns the CPP variable that should be used as a header guard. Args: filename: The name of a C++ header file. Returns: The CPP variable that should be used as a header guard in the named file.
Definition at line 1656 of file cpplint.py.
def roslint.cpplint.GetIndentLevel | ( | line | ) |
Return the number of leading spaces in line. Args: line: A string to check. Returns: An integer count of leading spaces, possibly zero.
Definition at line 1640 of file cpplint.py.
def roslint.cpplint.GetLineWidth | ( | line | ) |
Determines the width of the line in column positions. Args: line: A string, which may be a Unicode string. Returns: The width of the line in column positions, accounting for Unicode combining characters and wide characters.
Definition at line 4356 of file cpplint.py.
def roslint.cpplint.GetPreviousNonBlankLine | ( | clean_lines, | |
linenum | |||
) |
Return the most recent non-blank line and its line number. Args: clean_lines: A CleansedLines instance containing the file contents. linenum: The number of the line to check. Returns: A tuple with two elements. The first element is the contents of the last non-blank line before the current line, or the empty string if this is the first non-blank line. The second is the line number of that line, or -1 if this is the first non-blank line.
Definition at line 3872 of file cpplint.py.
def roslint.cpplint.GetTemplateArgs | ( | clean_lines, | |
linenum | |||
) |
Find list of template arguments associated with this function declaration. Args: clean_lines: A CleansedLines instance containing the file. linenum: Line number containing the start of the function declaration, usually one line after the end of the template-argument-list. Returns: Set of type names, or empty set if this does not appear to have any template parameters.
Definition at line 3717 of file cpplint.py.
def roslint.cpplint.IsBlankLine | ( | line | ) |
Returns true if the given line is blank. We consider a line to be blank if the line is empty or consists of only white spaces. Args: line: A line of a string. Returns: True, if the given line is blank.
Definition at line 2818 of file cpplint.py.
def roslint.cpplint.IsBlockInNameSpace | ( | nesting_state, | |
is_forward_declaration | |||
) |
Checks that the new block is directly in a namespace. Args: nesting_state: The _NestingState object that contains info about our state. is_forward_declaration: If the class is a forward declared class. Returns: Whether or not the new block is directly in a namespace.
Definition at line 5849 of file cpplint.py.
def roslint.cpplint.IsCppString | ( | line | ) |
Does line terminate so, that the next symbol is in string constant. This function does not consider single-line nor multi-line comments. Args: line: is a partial line of code starting from the 0..n. Returns: True, if next character appended to 'line' is inside a string constant.
Definition at line 1152 of file cpplint.py.
def roslint.cpplint.IsDecltype | ( | clean_lines, | |
linenum, | |||
column | |||
) |
Check if the token ending on (linenum, column) is decltype(). Args: clean_lines: A CleansedLines instance containing the file. linenum: the number of the line to check. column: end column of the token to check. Returns: True if this token is decltype() expression, False otherwise.
Definition at line 3400 of file cpplint.py.
def roslint.cpplint.IsDeletedOrDefault | ( | clean_lines, | |
linenum | |||
) |
Check if current constructor or operator is deleted or default. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if this is a deleted or default constructor.
Definition at line 3640 of file cpplint.py.
def roslint.cpplint.IsDerivedFunction | ( | clean_lines, | |
linenum | |||
) |
Check if current line contains an inherited function. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains a function with "override" virt-specifier.
Definition at line 5005 of file cpplint.py.
def roslint.cpplint.IsErrorSuppressedByNolint | ( | category, | |
linenum | |||
) |
Returns true if the specified error category is suppressed on this line. Consults the global error_suppressions map populated by ParseNolintSuppressions/ResetNolintSuppressions. Args: category: str, the category of the error. linenum: int, the current line number. Returns: bool, True iff the error should be suppressed due to a NOLINT comment.
Definition at line 546 of file cpplint.py.
def roslint.cpplint.IsForwardClassDeclaration | ( | clean_lines, | |
linenum | |||
) |
Definition at line 1998 of file cpplint.py.
def roslint.cpplint.IsInitializerList | ( | clean_lines, | |
linenum | |||
) |
Check if current line is inside constructor initializer list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line appears to be inside constructor initializer list, False otherwise.
Definition at line 5043 of file cpplint.py.
def roslint.cpplint.IsMacroDefinition | ( | clean_lines, | |
linenum | |||
) |
Definition at line 1988 of file cpplint.py.
def roslint.cpplint.IsOutOfLineMethodDefinition | ( | clean_lines, | |
linenum | |||
) |
Check if current line contains an out-of-line method definition. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. Returns: True if current line contains an out-of-line method definition.
Definition at line 5027 of file cpplint.py.
def roslint.cpplint.IsRValueAllowed | ( | clean_lines, | |
linenum, | |||
typenames | |||
) |
Check if RValue reference is allowed on a particular line. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. typenames: set of type names from template-argument-list. Returns: True if line is within the region where RValue references are allowed.
Definition at line 3659 of file cpplint.py.
def roslint.cpplint.IsRValueType | ( | typenames, | |
clean_lines, | |||
nesting_state, | |||
linenum, | |||
column | |||
) |
Check if the token ending on (linenum, column) is a type. Assumes that text to the right of the column is "&&" or a function name. Args: typenames: set of type names from template-argument-list. clean_lines: A CleansedLines instance containing the file. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. linenum: the number of the line to check. column: end column of the token to check. Returns: True if this token is a type, False if we are not sure.
Definition at line 3436 of file cpplint.py.
def roslint.cpplint.IsTemplateParameterList | ( | clean_lines, | |
linenum, | |||
column | |||
) |
Check if the token ending on (linenum, column) is the end of template<>. Args: clean_lines: A CleansedLines instance containing the file. linenum: the number of the line to check. column: end column of the token to check. Returns: True if this token is end of a template parameter list, False otherwise.
Definition at line 3418 of file cpplint.py.
def roslint.cpplint.main | ( | ) |
Definition at line 6309 of file cpplint.py.
def roslint.cpplint.Match | ( | pattern, | |
s | |||
) |
Matches the string with the pattern, caching the compiled regexp.
Definition at line 562 of file cpplint.py.
def roslint.cpplint.ParseArguments | ( | args | ) |
Parses the command line arguments. This may set the output format and verbosity level as side-effects. Args: args: The command line arguments: Returns: The list of filenames to lint.
Definition at line 6239 of file cpplint.py.
def roslint.cpplint.ParseNolintSuppressions | ( | filename, | |
raw_line, | |||
linenum, | |||
error | |||
) |
Updates the global list of error-suppressions. Parses any NOLINT comments on the current line, updating the global error_suppressions store. Reports an error if the NOLINT comment was malformed. Args: filename: str, the name of the input file. raw_line: str, the line of input text, with comments. linenum: int, the number of the current line. error: function, an error handler.
Definition at line 509 of file cpplint.py.
def roslint.cpplint.PrintCategories | ( | ) |
Prints a list of all the error-categories used by error messages. These are the categories used to filter messages via --filter.
Definition at line 6230 of file cpplint.py.
def roslint.cpplint.PrintUsage | ( | message | ) |
Prints a brief usage string and exits, optionally with an error message. Args: message: The optional error message.
Definition at line 6217 of file cpplint.py.
def roslint.cpplint.ProcessConfigOverrides | ( | filename | ) |
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.
Definition at line 6053 of file cpplint.py.
def roslint.cpplint.ProcessFile | ( | filename, | |
vlevel, | |||
extra_check_functions = [] |
|||
) |
Does google-lint on a single file. Args: filename: The name of the file to parse. vlevel: The level of errors to report. Every error of confidence >= verbose_level will be reported. 0 is a good default. extra_check_functions: An array of additional check functions that will be run on each source line. Each function takes 4 arguments: filename, clean_lines, line, error
Definition at line 6129 of file cpplint.py.
def roslint.cpplint.ProcessFileData | ( | filename, | |
file_extension, | |||
lines, | |||
error, | |||
extra_check_functions = [] |
|||
) |
Performs lint checks and reports any errors to the given error function. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file. lines: An array of strings, each representing a line of the file, with the last element being empty if the file is terminated with a newline. error: A callable to which errors are reported, which takes 4 arguments: filename, line number, error level, and message extra_check_functions: An array of additional check functions that will be run on each source line. Each function takes 4 arguments: filename, clean_lines, line, error
Definition at line 6003 of file cpplint.py.
def roslint.cpplint.ProcessLine | ( | filename, | |
file_extension, | |||
clean_lines, | |||
line, | |||
include_state, | |||
function_state, | |||
nesting_state, | |||
error, | |||
extra_check_functions = [] |
|||
) |
Processes a single line in the file. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file. clean_lines: An array of strings, each representing a line of the file, with comments stripped. line: Number of line being processed. include_state: An _IncludeState instance in which the headers are inserted. function_state: A _FunctionState instance which counts function lines, etc. nesting_state: A NestingState instance which maintains information about the current stack of nested blocks being parsed. error: A callable to which errors are reported, which takes 4 arguments: filename, line number, error level, and message extra_check_functions: An array of additional check functions that will be run on each source line. Each function takes 4 arguments: filename, clean_lines, line, error
Definition at line 5913 of file cpplint.py.
def roslint.cpplint.RemoveMultiLineComments | ( | filename, | |
lines, | |||
error | |||
) |
Removes multiline (c-style) comments from lines.
Definition at line 1263 of file cpplint.py.
def roslint.cpplint.RemoveMultiLineCommentsFromRange | ( | lines, | |
begin, | |||
end | |||
) |
Clears a range of lines for multi-line comments.
Definition at line 1255 of file cpplint.py.
def roslint.cpplint.ReplaceAll | ( | pattern, | |
rep, | |||
s | |||
) |
Replaces instances of pattern in a string with a replacement. The compiled regex is kept in a cache shared by Match and Search. Args: pattern: regex pattern rep: replacement text s: search string Returns: string with replacements made (or original string if no replacements)
Definition at line 572 of file cpplint.py.
def roslint.cpplint.ResetNolintSuppressions | ( | ) |
Resets the set of NOLINT suppressions to empty.
Definition at line 541 of file cpplint.py.
def roslint.cpplint.ReverseCloseExpression | ( | clean_lines, | |
linenum, | |||
pos | |||
) |
If input points to ) or } or ] or >, finds the position that opens it. If lines[linenum][pos] points to a ')' or '}' or ']' or '>', finds the linenum/pos that correspond to the opening of the expression. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: A position on the line. Returns: A tuple (line, linenum, pos) pointer *at* the opening brace, or (line, 0, -1) if we never find the matching opening brace. Note we ignore strings and comments when matching; and the line we return is the 'cleansed' line at linenum.
Definition at line 1589 of file cpplint.py.
def roslint.cpplint.Search | ( | pattern, | |
s | |||
) |
Searches the string for the pattern, caching the compiled regexp.
Definition at line 590 of file cpplint.py.
def roslint.cpplint.ShouldCheckNamespaceIndentation | ( | nesting_state, | |
is_namespace_indent_item, | |||
raw_lines_no_comments, | |||
linenum | |||
) |
This method determines if we should apply our namespace indentation check. Args: nesting_state: The current nesting state. is_namespace_indent_item: If we just put a new class on the stack, True. If the top of the stack is not a class, or we did not recently add the class, False. raw_lines_no_comments: The lines without the comments. linenum: The current line number we are processing. Returns: True if we should apply our namespace indentation check. Currently, it only works for classes and namespaces inside of a namespace.
Definition at line 5871 of file cpplint.py.
def roslint.cpplint.UpdateIncludeState | ( | filename, | |
include_dict, | |||
io = codecs |
|||
) |
Fill up the include_dict with new includes found from the file. Args: filename: the name of the header to read. include_dict: a dictionary in which the headers are inserted. io: The io factory to use to read the file. Provided for testability. Returns: True if a header was successfully added. False otherwise.
Definition at line 5582 of file cpplint.py.
|
private |
Definition at line 448 of file cpplint.py.
|
private |
Definition at line 467 of file cpplint.py.
|
private |
Definition at line 483 of file cpplint.py.
|
private |
Definition at line 473 of file cpplint.py.
|
private |
Definition at line 414 of file cpplint.py.
|
private |
Definition at line 423 of file cpplint.py.
|
private |
Definition at line 266 of file cpplint.py.
|
private |
Definition at line 474 of file cpplint.py.
|
private |
Definition at line 853 of file cpplint.py.
|
private |
Definition at line 259 of file cpplint.py.
|
private |
Definition at line 482 of file cpplint.py.
|
private |
Definition at line 182 of file cpplint.py.
|
private |
Definition at line 495 of file cpplint.py.
|
private |
Definition at line 5468 of file cpplint.py.
|
private |
Definition at line 481 of file cpplint.py.
|
private |
Definition at line 251 of file cpplint.py.
|
private |
Definition at line 475 of file cpplint.py.
|
private |
Definition at line 503 of file cpplint.py.
|
private |
Definition at line 486 of file cpplint.py.
|
private |
Definition at line 480 of file cpplint.py.
|
private |
Definition at line 477 of file cpplint.py.
|
private |
Definition at line 476 of file cpplint.py.
|
private |
Definition at line 4503 of file cpplint.py.
|
private |
Definition at line 5508 of file cpplint.py.
|
private |
Definition at line 1136 of file cpplint.py.
|
private |
Definition at line 1145 of file cpplint.py.
|
private |
Definition at line 1133 of file cpplint.py.
|
private |
Definition at line 4761 of file cpplint.py.
|
private |
Definition at line 5703 of file cpplint.py.
|
private |
Definition at line 4749 of file cpplint.py.
|
private |
Definition at line 4497 of file cpplint.py.
|
private |
Definition at line 1962 of file cpplint.py.
|
private |
Definition at line 4756 of file cpplint.py.
|
private |
Definition at line 5506 of file cpplint.py.
|
private |
Definition at line 5518 of file cpplint.py.
|
private |
Definition at line 2915 of file cpplint.py.
|
private |
Definition at line 4750 of file cpplint.py.
|
private |
Definition at line 491 of file cpplint.py.
|
private |
Definition at line 499 of file cpplint.py.
|
private |
Definition at line 407 of file cpplint.py.
|
private |
Definition at line 1899 of file cpplint.py.
|
private |
Definition at line 1898 of file cpplint.py.
|
private |
Definition at line 61 of file cpplint.py.
|
private |
Definition at line 507 of file cpplint.py.
roslint.cpplint.xrange = range |
Definition at line 58 of file cpplint.py.