| 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.2' | ||
| 62 | + __VERSION__ = '1.5.3' | ||
| 63 | 63 | ||
| 64 | 64 | try: | |
| 65 | 65 | xrange # Python 2 | |
@@ -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', | |
@@ -358,6 +354,13 @@ | |||
| 358 | 354 | 'whitespace/todo', | |
| 359 | 355 | ] | |
| 360 | 356 | ||
| 357 | + # keywords to use with --outputs which generate stdout for machine processing | ||
| 358 | + _MACHINE_OUTPUTS = [ | ||
| 359 | + 'junit', | ||
| 360 | + 'sed', | ||
| 361 | + 'gsed' | ||
| 362 | + ] | ||
| 363 | + | ||
| 361 | 364 | # These error categories are no longer enforced by cpplint, but for backwards- | |
| 362 | 365 | # compatibility they may still appear in NOLINT comments. | |
| 363 | 366 | _LEGACY_ERROR_CATEGORIES = [ | |
@@ -839,14 +842,6 @@ | |||
| 839 | 842 | 'Missing space after ,': r's/,\([^ ]\)/, \1/g', | |
| 840 | 843 | } | |
| 841 | 844 | ||
| 842 | - _NULL_TOKEN_PATTERN = re.compile(r'\bNULL\b') | ||
| 843 | - | ||
| 844 | - _V8_PERSISTENT_PATTERN = re.compile(r'\bv8::Persistent\b') | ||
| 845 | - | ||
| 846 | - _RIGHT_LEANING_POINTER_PATTERN = re.compile(r'[^=|(,\s><);&?:}]' | ||
| 847 | - r'(?<!(sizeof|return))' | ||
| 848 | - r'\s\*[a-zA-Z_][0-9a-zA-Z_]*') | ||
| 849 | - | ||
| 850 | 845 | _regexp_compile_cache = {} | |
| 851 | 846 | ||
| 852 | 847 | # {str, set(int)}: a map from error categories to sets of linenumbers | |
@@ -866,7 +861,7 @@ | |||
| 866 | 861 | # Files to exclude from linting. This is set by the --exclude flag. | |
| 867 | 862 | _excludes = None | |
| 868 | 863 | ||
| 869 | - # Whether to suppress PrintInfo messages | ||
| 864 | + # Whether to supress all PrintInfo messages, UNRELATED to --quiet flag | ||
| 870 | 865 | _quiet = False | |
| 871 | 866 | ||
| 872 | 867 | # The allowed line length of files. | |
@@ -1087,11 +1082,10 @@ class _IncludeState(object): | |||
| 1087 | 1082 | # needs to move backwards, CheckNextIncludeOrder will raise an error. | |
| 1088 | 1083 | _INITIAL_SECTION = 0 | |
| 1089 | 1084 | _MY_H_SECTION = 1 | |
| 1090 | - _OTHER_H_SECTION = 2 | ||
| 1091 | - _OTHER_SYS_SECTION = 3 | ||
| 1092 | - _C_SECTION = 4 | ||
| 1093 | - _CPP_SECTION = 5 | ||
| 1094 | - | ||
| 1085 | + _C_SECTION = 2 | ||
| 1086 | + _CPP_SECTION = 3 | ||
| 1087 | + _OTHER_SYS_SECTION = 4 | ||
| 1088 | + _OTHER_H_SECTION = 5 | ||
| 1095 | 1089 | ||
| 1096 | 1090 | _TYPE_NAMES = { | |
| 1097 | 1091 | _C_SYS_HEADER: 'C system header', | |
@@ -1357,7 +1351,9 @@ def PrintErrorCounts(self): | |||
| 1357 | 1351 | self.PrintInfo('Total errors found: %d\n' % self.error_count) | |
| 1358 | 1352 | ||
| 1359 | 1353 | def PrintInfo(self, message): | |
| 1360 | - if not _quiet and self.output_format != 'junit': | ||
| 1354 | + # _quiet does not represent --quiet flag. | ||
| 1355 | + # Hide infos from stdout to keep stdout pure for machine consumption | ||
| 1356 | + if not _quiet and self.output_format not in _MACHINE_OUTPUTS: | ||
| 1361 | 1357 | sys.stdout.write(message) | |
| 1362 | 1358 | ||
| 1363 | 1359 | def PrintError(self, message): | |
@@ -2524,21 +2520,6 @@ def CheckForBadCharacters(filename, lines, error): | |||
| 2524 | 2520 | error(filename, linenum, 'readability/nul', 5, 'Line contains NUL byte.') | |
| 2525 | 2521 | ||
| 2526 | 2522 | ||
| 2527 | - def CheckInlineHeader(filename, include_state, error): | ||
| 2528 | - """Logs an error if both a header and its inline variant are included.""" | ||
| 2529 | - | ||
| 2530 | - all_headers = dict(item for sublist in include_state.include_list | ||
| 2531 | - for item in sublist) | ||
| 2532 | - bad_headers = set('%s.h' % name[:-6] for name in all_headers.keys() | ||
| 2533 | - if name.endswith('-inl.h')) | ||
| 2534 | - bad_headers &= set(all_headers.keys()) | ||
| 2535 | - | ||
| 2536 | - for name in bad_headers: | ||
| 2537 | - err = '%s includes both %s and %s-inl.h' % (filename, name, name) | ||
| 2538 | - linenum = all_headers[name] | ||
| 2539 | - error(filename, linenum, 'build/include_inline', 5, err) | ||
| 2540 | - | ||
| 2541 | - | ||
| 2542 | 2523 | def CheckForNewlineAtEOF(filename, lines, error): | |
| 2543 | 2524 | """Logs an error if there is no newline char at the end of the file. | |
| 2544 | 2525 | ||
@@ -3562,7 +3543,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, | |||
| 3562 | 3543 | """Reports for long function bodies. | |
| 3563 | 3544 | ||
| 3564 | 3545 | For an overview why this is done, see: | |
| 3565 | - https://google.github.io/styleguide/cppguide.html#Write_Short_Functions | ||
| 3546 | + https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions | ||
| 3566 | 3547 | ||
| 3567 | 3548 | Uses a simplistic algorithm assuming other style guidelines | |
| 3568 | 3549 | (especially spacing) are followed. | |
@@ -4788,71 +4769,6 @@ def CheckAltTokens(filename, clean_lines, linenum, error): | |||
| 4788 | 4769 | 'Use operator %s instead of %s' % ( | |
| 4789 | 4770 | _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) | |
| 4790 | 4771 | ||
| 4791 | - def CheckNullTokens(filename, clean_lines, linenum, error): | ||
| 4792 | - """Check NULL usage. | ||
| 4793 | - | ||
| 4794 | - Args: | ||
| 4795 | - filename: The name of the current file. | ||
| 4796 | - clean_lines: A CleansedLines instance containing the file. | ||
| 4797 | - linenum: The number of the line to check. | ||
| 4798 | - error: The function to call with any errors found. | ||
| 4799 | - """ | ||
| 4800 | - line = clean_lines.elided[linenum] | ||
| 4801 | - | ||
| 4802 | - # Avoid preprocessor lines | ||
| 4803 | - if Match(r'^\s*#', line): | ||
| 4804 | - return | ||
| 4805 | - | ||
| 4806 | - if line.find('/*') >= 0 or line.find('*/') >= 0: | ||
| 4807 | - return | ||
| 4808 | - | ||
| 4809 | - for match in _NULL_TOKEN_PATTERN.finditer(line): | ||
| 4810 | - error(filename, linenum, 'readability/null_usage', 2, | ||
| 4811 | - 'Use nullptr instead of NULL') | ||
| 4812 | - | ||
| 4813 | - def CheckV8PersistentTokens(filename, clean_lines, linenum, error): | ||
| 4814 | - """Check v8::Persistent usage. | ||
| 4815 | - | ||
| 4816 | - Args: | ||
| 4817 | - filename: The name of the current file. | ||
| 4818 | - clean_lines: A CleansedLines instance containing the file. | ||
| 4819 | - linenum: The number of the line to check. | ||
| 4820 | - error: The function to call with any errors found. | ||
| 4821 | - """ | ||
| 4822 | - line = clean_lines.elided[linenum] | ||
| 4823 | - | ||
| 4824 | - # Avoid preprocessor lines | ||
| 4825 | - if Match(r'^\s*#', line): | ||
| 4826 | - return | ||
| 4827 | - | ||
| 4828 | - if line.find('/*') >= 0 or line.find('*/') >= 0: | ||
| 4829 | - return | ||
| 4830 | - | ||
| 4831 | - for match in _V8_PERSISTENT_PATTERN.finditer(line): | ||
| 4832 | - error(filename, linenum, 'runtime/v8_persistent', 2, | ||
| 4833 | - 'Use v8::Global instead of v8::Persistent') | ||
| 4834 | - | ||
| 4835 | - def CheckLeftLeaningPointer(filename, clean_lines, linenum, error): | ||
| 4836 | - """Check for left-leaning pointer placement. | ||
| 4837 | - | ||
| 4838 | - Args: | ||
| 4839 | - filename: The name of the current file. | ||
| 4840 | - clean_lines: A CleansedLines instance containing the file. | ||
| 4841 | - linenum: The number of the line to check. | ||
| 4842 | - error: The function to call with any errors found. | ||
| 4843 | - """ | ||
| 4844 | - line = clean_lines.elided[linenum] | ||
| 4845 | - | ||
| 4846 | - # Avoid preprocessor lines | ||
| 4847 | - if Match(r'^\s*#', line): | ||
| 4848 | - return | ||
| 4849 | - | ||
| 4850 | - if '/*' in line or '*/' in line: | ||
| 4851 | - return | ||
| 4852 | - | ||
| 4853 | - for match in _RIGHT_LEANING_POINTER_PATTERN.finditer(line): | ||
| 4854 | - error(filename, linenum, 'readability/pointer_notation', 2, | ||
| 4855 | - 'Use left leaning pointer instead of right leaning') | ||
| 4856 | 4772 | ||
| 4857 | 4773 | def GetLineWidth(line): | |
| 4858 | 4774 | """Determines the width of the line in column positions. | |
@@ -5007,9 +4923,6 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, | |||
| 5007 | 4923 | CheckSpacingForFunctionCall(filename, clean_lines, linenum, error) | |
| 5008 | 4924 | CheckCheck(filename, clean_lines, linenum, error) | |
| 5009 | 4925 | CheckAltTokens(filename, clean_lines, linenum, error) | |
| 5010 | - CheckNullTokens(filename, clean_lines, linenum, error) | ||
| 5011 | - CheckV8PersistentTokens(filename, clean_lines, linenum, error) | ||
| 5012 | - CheckLeftLeaningPointer(filename, clean_lines, linenum, error) | ||
| 5013 | 4926 | classinfo = nesting_state.InnermostClass() | |
| 5014 | 4927 | if classinfo: | |
| 5015 | 4928 | CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) | |
@@ -5195,10 +5108,11 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): | |||
| 5195 | 5108 | include_state.include_list[-1].append((include, linenum)) | |
| 5196 | 5109 | ||
| 5197 | 5110 | # We want to ensure that headers appear in the right order: | |
| 5198 | - # 1) for foo.cc, foo.h | ||
| 5199 | - # 2) other project headers | ||
| 5200 | - # 3) c system files | ||
| 5201 | - # 4) cpp system files | ||
| 5111 | + # 1) for foo.cc, foo.h (preferred location) | ||
| 5112 | + # 2) c system files | ||
| 5113 | + # 3) cpp system files | ||
| 5114 | + # 4) for foo.cc, foo.h (deprecated location) | ||
| 5115 | + # 5) other google headers | ||
| 5202 | 5116 | # | |
| 5203 | 5117 | # We classify each include statement as one of those 5 types | |
| 5204 | 5118 | # using a number of techniques. The include_state object keeps | |
@@ -5461,7 +5375,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, | |||
| 5461 | 5375 | and line[-1] != '\\'): | |
| 5462 | 5376 | error(filename, linenum, 'build/namespaces_headers', 4, | |
| 5463 | 5377 | 'Do not use unnamed namespaces in header files. See ' | |
| 5464 | - 'https://google.github.io/styleguide/cppguide.html#Namespaces' | ||
| 5378 | + 'https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' | ||
| 5465 | 5379 | ' for more information.') | |
| 5466 | 5380 | ||
| 5467 | 5381 | ||
@@ -6583,8 +6497,6 @@ def ProcessFileData(filename, file_extension, lines, error, | |||
| 6583 | 6497 | ||
| 6584 | 6498 | CheckForNewlineAtEOF(filename, lines, error) | |
| 6585 | 6499 | ||
| 6586 | - CheckInlineHeader(filename, include_state, error) | ||
| 6587 | - | ||
| 6588 | 6500 | def ProcessConfigOverrides(filename): | |
| 6589 | 6501 | """ Loads the configuration files and processes the config overrides. | |
| 6590 | 6502 | ||
@@ -6603,7 +6515,7 @@ def ProcessConfigOverrides(filename): | |||
| 6603 | 6515 | if not base_name: | |
| 6604 | 6516 | break # Reached the root directory. | |
| 6605 | 6517 | ||
| 6606 | - cfg_file = os.path.join(abs_path, ".cpplint") | ||
| 6518 | + cfg_file = os.path.join(abs_path, "CPPLINT.cfg") | ||
| 6607 | 6519 | abs_filename = abs_path | |
| 6608 | 6520 | if not os.path.isfile(cfg_file): | |
| 6609 | 6521 | continue | |
@@ -6840,9 +6752,9 @@ def ParseArguments(args): | |||
| 6840 | 6752 | if opt == '--version': | |
| 6841 | 6753 | PrintVersion() | |
| 6842 | 6754 | elif opt == '--output': | |
| 6843 | - if val not in ('emacs', 'vs7', 'eclipse', 'junit'): | ||
| 6755 | + if val not in ('emacs', 'vs7', 'eclipse', 'junit', 'sed', 'gsed'): | ||
| 6844 | 6756 | PrintUsage('The only allowed output formats are emacs, vs7, eclipse ' | |
| 6845 | - 'and junit.') | ||
| 6757 | + 'sed, gsed and junit.') | ||
| 6846 | 6758 | output_format = val | |
| 6847 | 6759 | elif opt == '--quiet': | |
| 6848 | 6760 | quiet = True | |
@@ -6985,3 +6897,4 @@ def main(): | |||
| 6985 | 6897 | ||
| 6986 | 6898 | if __name__ == '__main__': | |
| 6987 | 6899 | main() | |
| 6900 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments