| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,7 @@ | |||
| 59 | 59 | # if empty, use defaults | |
| 60 | 60 | _valid_extensions = set([]) | |
| 61 | 61 | ||
| 62 | - __VERSION__ = '1.5.4' | ||
| 62 | + __VERSION__ = '1.5.5' | ||
| 63 | 63 | ||
| 64 | 64 | try: | |
| 65 | 65 | xrange # Python 2 | |
@@ -127,11 +127,11 @@ | |||
| 127 | 127 | error messages whose category names pass the filters will be printed. | |
| 128 | 128 | (Category names are printed with the message and look like | |
| 129 | 129 | "[whitespace/indent]".) Filters are evaluated left to right. | |
| 130 | - "-FOO" and "FOO" means "do not print categories that start with FOO". | ||
| 130 | + "-FOO" means "do not print categories that start with FOO". | ||
| 131 | 131 | "+FOO" means "do print categories that start with FOO". | |
| 132 | 132 | ||
| 133 | 133 | Examples: --filter=-whitespace,+whitespace/braces | |
| 134 | - --filter=whitespace,runtime/printf,+runtime/printf_format | ||
| 134 | + --filter=-whitespace,-runtime/printf,+runtime/printf_format | ||
| 135 | 135 | --filter=-,+build/include_what_you_use | |
| 136 | 136 | ||
| 137 | 137 | To see a list of all the categories used in cpplint, pass no arg: | |
@@ -295,7 +295,6 @@ | |||
| 295 | 295 | 'build/include', | |
| 296 | 296 | 'build/include_subdir', | |
| 297 | 297 | 'build/include_alpha', | |
| 298 | - 'build/include_inline', | ||
| 299 | 298 | 'build/include_order', | |
| 300 | 299 | 'build/include_what_you_use', | |
| 301 | 300 | 'build/namespaces_headers', | |
@@ -311,13 +310,11 @@ | |||
| 311 | 310 | 'readability/constructors', | |
| 312 | 311 | 'readability/fn_size', | |
| 313 | 312 | 'readability/inheritance', | |
| 314 | - 'readability/pointer_notation', | ||
| 315 | 313 | 'readability/multiline_comment', | |
| 316 | 314 | 'readability/multiline_string', | |
| 317 | 315 | 'readability/namespace', | |
| 318 | 316 | 'readability/nolint', | |
| 319 | 317 | 'readability/nul', | |
| 320 | - 'readability/null_usage', | ||
| 321 | 318 | 'readability/strings', | |
| 322 | 319 | 'readability/todo', | |
| 323 | 320 | 'readability/utf8', | |
@@ -337,7 +334,6 @@ | |||
| 337 | 334 | 'runtime/string', | |
| 338 | 335 | 'runtime/threadsafe_fn', | |
| 339 | 336 | 'runtime/vlog', | |
| 340 | - 'runtime/v8_persistent', | ||
| 341 | 337 | 'whitespace/blank_line', | |
| 342 | 338 | 'whitespace/braces', | |
| 343 | 339 | 'whitespace/comma', | |
@@ -846,14 +842,6 @@ | |||
| 846 | 842 | 'Missing space after ,': r's/,\([^ ]\)/, \1/g', | |
| 847 | 843 | } | |
| 848 | 844 | ||
| 849 | - _NULL_TOKEN_PATTERN = re.compile(r'\bNULL\b') | ||
| 850 | - | ||
| 851 | - _V8_PERSISTENT_PATTERN = re.compile(r'\bv8::Persistent\b') | ||
| 852 | - | ||
| 853 | - _RIGHT_LEANING_POINTER_PATTERN = re.compile(r'[^=|(,\s><);&?:}]' | ||
| 854 | - r'(?<!(sizeof|return))' | ||
| 855 | - r'\s\*[a-zA-Z_][0-9a-zA-Z_]*') | ||
| 856 | - | ||
| 857 | 845 | _regexp_compile_cache = {} | |
| 858 | 846 | ||
| 859 | 847 | # {str, set(int)}: a map from error categories to sets of linenumbers | |
@@ -1094,11 +1082,10 @@ class _IncludeState(object): | |||
| 1094 | 1082 | # needs to move backwards, CheckNextIncludeOrder will raise an error. | |
| 1095 | 1083 | _INITIAL_SECTION = 0 | |
| 1096 | 1084 | _MY_H_SECTION = 1 | |
| 1097 | - _OTHER_H_SECTION = 2 | ||
| 1098 | - _OTHER_SYS_SECTION = 3 | ||
| 1099 | - _C_SECTION = 4 | ||
| 1100 | - _CPP_SECTION = 5 | ||
| 1101 | - | ||
| 1085 | + _C_SECTION = 2 | ||
| 1086 | + _CPP_SECTION = 3 | ||
| 1087 | + _OTHER_SYS_SECTION = 4 | ||
| 1088 | + _OTHER_H_SECTION = 5 | ||
| 1102 | 1089 | ||
| 1103 | 1090 | _TYPE_NAMES = { | |
| 1104 | 1091 | _C_SYS_HEADER: 'C system header', | |
@@ -2350,7 +2337,8 @@ def StripListPrefix(lst, prefix): | |||
| 2350 | 2337 | ||
| 2351 | 2338 | # --root=.. , will prepend the outer directory to the header guard | |
| 2352 | 2339 | full_path = fileinfo.FullName() | |
| 2353 | - root_abspath = os.path.abspath(_root) | ||
| 2340 | + # adapt slashes for windows | ||
| 2341 | + root_abspath = os.path.abspath(_root).replace('\\', '/') | ||
| 2354 | 2342 | ||
| 2355 | 2343 | maybe_path = StripListPrefix(PathSplitToList(full_path), | |
| 2356 | 2344 | PathSplitToList(root_abspath)) | |
@@ -2533,21 +2521,6 @@ def CheckForBadCharacters(filename, lines, error): | |||
| 2533 | 2521 | error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.') | |
| 2534 | 2522 | ||
| 2535 | 2523 | ||
| 2536 | - def CheckInlineHeader(filename, include_state, error): | ||
| 2537 | - """Logs an error if both a header and its inline variant are included.""" | ||
| 2538 | - | ||
| 2539 | - all_headers = dict(item for sublist in include_state.include_list | ||
| 2540 | - for item in sublist) | ||
| 2541 | - bad_headers = set('%s.h' % name[:-6] for name in all_headers.keys() | ||
| 2542 | - if name.endswith('-inl.h')) | ||
| 2543 | - bad_headers &= set(all_headers.keys()) | ||
| 2544 | - | ||
| 2545 | - for name in bad_headers: | ||
| 2546 | - err = '%s includes both %s and %s-inl.h' % (filename, name, name) | ||
| 2547 | - linenum = all_headers[name] | ||
| 2548 | - error(filename, linenum, 'build/include_inline', 5, err) | ||
| 2549 | - | ||
| 2550 | - | ||
| 2551 | 2524 | def CheckForNewlineAtEOF(filename, lines, error): | |
| 2552 | 2525 | """Logs an error if there is no newline char at the end of the file. | |
| 2553 | 2526 | ||
@@ -3499,7 +3472,7 @@ def CheckSpacingForFunctionCall(filename, clean_lines, linenum, error): | |||
| 3499 | 3472 | # Note that we assume the contents of [] to be short enough that | |
| 3500 | 3473 | # they'll never need to wrap. | |
| 3501 | 3474 | if ( # Ignore control structures. | |
| 3502 | - not Search(r'\b(if|for|while|switch|return|new|delete|catch|sizeof)\b', | ||
| 3475 | + not Search(r'\b(if|elif|for|while|switch|return|new|delete|catch|sizeof)\b', | ||
| 3503 | 3476 | fncall) and | |
| 3504 | 3477 | # Ignore pointers/references to functions. | |
| 3505 | 3478 | not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and | |
@@ -3571,7 +3544,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, | |||
| 3571 | 3544 | """Reports for long function bodies. | |
| 3572 | 3545 | ||
| 3573 | 3546 | For an overview why this is done, see: | |
| 3574 | - https://google.github.io/styleguide/cppguide.html#Write_Short_Functions | ||
| 3547 | + https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions | ||
| 3575 | 3548 | ||
| 3576 | 3549 | Uses a simplistic algorithm assuming other style guidelines | |
| 3577 | 3550 | (especially spacing) are followed. | |
@@ -4798,71 +4771,6 @@ def CheckAltTokens(filename, clean_lines, linenum, error): | |||
| 4798 | 4771 | 'Use operator %s instead of %s' % ( | |
| 4799 | 4772 | _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) | |
| 4800 | 4773 | ||
| 4801 | - def CheckNullTokens(filename, clean_lines, linenum, error): | ||
| 4802 | - """Check NULL usage. | ||
| 4803 | - | ||
| 4804 | - Args: | ||
| 4805 | - filename: The name of the current file. | ||
| 4806 | - clean_lines: A CleansedLines instance containing the file. | ||
| 4807 | - linenum: The number of the line to check. | ||
| 4808 | - error: The function to call with any errors found. | ||
| 4809 | - """ | ||
| 4810 | - line = clean_lines.elided[linenum] | ||
| 4811 | - | ||
| 4812 | - # Avoid preprocessor lines | ||
| 4813 | - if Match(r'^\s*#', line): | ||
| 4814 | - return | ||
| 4815 | - | ||
| 4816 | - if line.find('/*') >= 0 or line.find('*/') >= 0: | ||
| 4817 | - return | ||
| 4818 | - | ||
| 4819 | - for match in _NULL_TOKEN_PATTERN.finditer(line): | ||
| 4820 | - error(filename, linenum, 'readability/null_usage', 2, | ||
| 4821 | - 'Use nullptr instead of NULL') | ||
| 4822 | - | ||
| 4823 | - def CheckV8PersistentTokens(filename, clean_lines, linenum, error): | ||
| 4824 | - """Check v8::Persistent usage. | ||
| 4825 | - | ||
| 4826 | - Args: | ||
| 4827 | - filename: The name of the current file. | ||
| 4828 | - clean_lines: A CleansedLines instance containing the file. | ||
| 4829 | - linenum: The number of the line to check. | ||
| 4830 | - error: The function to call with any errors found. | ||
| 4831 | - """ | ||
| 4832 | - line = clean_lines.elided[linenum] | ||
| 4833 | - | ||
| 4834 | - # Avoid preprocessor lines | ||
| 4835 | - if Match(r'^\s*#', line): | ||
| 4836 | - return | ||
| 4837 | - | ||
| 4838 | - if line.find('/*') >= 0 or line.find('*/') >= 0: | ||
| 4839 | - return | ||
| 4840 | - | ||
| 4841 | - for match in _V8_PERSISTENT_PATTERN.finditer(line): | ||
| 4842 | - error(filename, linenum, 'runtime/v8_persistent', 2, | ||
| 4843 | - 'Use v8::Global instead of v8::Persistent') | ||
| 4844 | - | ||
| 4845 | - def CheckLeftLeaningPointer(filename, clean_lines, linenum, error): | ||
| 4846 | - """Check for left-leaning pointer placement. | ||
| 4847 | - | ||
| 4848 | - Args: | ||
| 4849 | - filename: The name of the current file. | ||
| 4850 | - clean_lines: A CleansedLines instance containing the file. | ||
| 4851 | - linenum: The number of the line to check. | ||
| 4852 | - error: The function to call with any errors found. | ||
| 4853 | - """ | ||
| 4854 | - line = clean_lines.elided[linenum] | ||
| 4855 | - | ||
| 4856 | - # Avoid preprocessor lines | ||
| 4857 | - if Match(r'^\s*#', line): | ||
| 4858 | - return | ||
| 4859 | - | ||
| 4860 | - if '/*' in line or '*/' in line: | ||
| 4861 | - return | ||
| 4862 | - | ||
| 4863 | - for match in _RIGHT_LEANING_POINTER_PATTERN.finditer(line): | ||
| 4864 | - error(filename, linenum, 'readability/pointer_notation', 2, | ||
| 4865 | - 'Use left leaning pointer instead of right leaning') | ||
| 4866 | 4774 | ||
| 4867 | 4775 | def GetLineWidth(line): | |
| 4868 | 4776 | """Determines the width of the line in column positions. | |
@@ -5017,9 +4925,6 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, | |||
| 5017 | 4925 | CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) | |
| 5018 | 4926 | CheckCheck(filename, clean_lines, linenum, error) | |
| 5019 | 4927 | CheckAltTokens(filename, clean_lines, linenum, error) | |
| 5020 | - CheckNullTokens(filename, clean_lines, linenum, error) | ||
| 5021 | - CheckV8PersistentTokens(filename, clean_lines, linenum, error) | ||
| 5022 | - CheckLeftLeaningPointer(filename, clean_lines, linenum, error) | ||
| 5023 | 4928 | classinfo = nesting_state.InnermostClass() | |
| 5024 | 4929 | if classinfo: | |
| 5025 | 4930 | CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) | |
@@ -5205,10 +5110,11 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): | |||
| 5205 | 5110 | include_state.include_list[-1].append((include, linenum)) | |
| 5206 | 5111 | ||
| 5207 | 5112 | # We want to ensure that headers appear in the right order: | |
| 5208 | - # 1) for foo.cc, foo.h | ||
| 5209 | - # 2) other project headers | ||
| 5210 | - # 3) c system files | ||
| 5211 | - # 4) cpp system files | ||
| 5113 | + # 1) for foo.cc, foo.h (preferred location) | ||
| 5114 | + # 2) c system files | ||
| 5115 | + # 3) cpp system files | ||
| 5116 | + # 4) for foo.cc, foo.h (deprecated location) | ||
| 5117 | + # 5) other google headers | ||
| 5212 | 5118 | # | |
| 5213 | 5119 | # We classify each include statement as one of those 5 types | |
| 5214 | 5120 | # using a number of techniques. The include_state object keeps | |
@@ -5471,7 +5377,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, | |||
| 5471 | 5377 | and line[-1] != '\\'): | |
| 5472 | 5378 | error(filename, linenum, 'build/namespaces_headers', 4, | |
| 5473 | 5379 | 'Do not use unnamed namespaces in header files. See ' | |
| 5474 | - 'https://google.github.io/styleguide/cppguide.html#Namespaces' | ||
| 5380 | + 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' | ||
| 5475 | 5381 | ' for more information.') | |
| 5476 | 5382 | ||
| 5477 | 5383 | ||
@@ -5846,7 +5752,7 @@ def CheckCasts(filename, clean_lines, linenum, error): | |||
| 5846 | 5752 | ||
| 5847 | 5753 | if not expecting_function: | |
| 5848 | 5754 | CheckCStyleCast(filename, clean_lines, linenum, 'static_cast', | |
| 5849 | - r'\((int|float|double|bool|char|u?int(16|32|64))\)', error) | ||
| 5755 | + r'\((int|float|double|bool|char|u?int(16|32|64)|size_t)\)', error) | ||
| 5850 | 5756 | ||
| 5851 | 5757 | # This doesn't catch all cases. Consider (const char * const)"hello". | |
| 5852 | 5758 | # | |
@@ -6593,8 +6499,6 @@ def ProcessFileData(filename, file_extension, lines, error, | |||
| 6593 | 6499 | ||
| 6594 | 6500 | CheckForNewlineAtEOF(filename, lines, error) | |
| 6595 | 6501 | ||
| 6596 | - CheckInlineHeader(filename, include_state, error) | ||
| 6597 | - | ||
| 6598 | 6502 | def ProcessConfigOverrides(filename): | |
| 6599 | 6503 | """ Loads the configuration files and processes the config overrides. | |
| 6600 | 6504 | ||
@@ -6613,7 +6517,7 @@ def ProcessConfigOverrides(filename): | |||
| 6613 | 6517 | if not base_name: | |
| 6614 | 6518 | break # Reached the root directory. | |
| 6615 | 6519 | ||
| 6616 | - cfg_file = os.path.join(abs_path, ".cpplint") | ||
| 6520 | + cfg_file = os.path.join(abs_path, "CPPLINT.cfg") | ||
| 6617 | 6521 | abs_filename = abs_path | |
| 6618 | 6522 | if not os.path.isfile(cfg_file): | |
| 6619 | 6523 | continue | |
@@ -6783,10 +6687,10 @@ def PrintUsage(message): | |||
| 6783 | 6687 | Args: | |
| 6784 | 6688 | message: The optional error message. | |
| 6785 | 6689 | """ | |
| 6786 | - sys.stderr.write(_USAGE % (list(GetAllExtensions()), | ||
| 6787 | - ','.join(list(GetAllExtensions())), | ||
| 6788 | - GetHeaderExtensions(), | ||
| 6789 | - ','.join(GetHeaderExtensions()))) | ||
| 6690 | + sys.stderr.write(_USAGE % (sorted(list(GetAllExtensions())), | ||
| 6691 | + ','.join(sorted(list(GetAllExtensions()))), | ||
| 6692 | + sorted(GetHeaderExtensions()), | ||
| 6693 | + ','.join(sorted(GetHeaderExtensions())))) | ||
| 6790 | 6694 | ||
| 6791 | 6695 | if message: | |
| 6792 | 6696 | sys.exit('\nFATAL ERROR: ' + message) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments