@@ -2283,6 +2283,7 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
22832283 fileinfo = FileInfo (filename )
22842284
22852285 line = clean_lines .lines [linenum ]
2286+ ParseNolintSuppressions (filename , line , linenum , error )
22862287
22872288 # we shouldn't include a file more than once. actually, there are a
22882289 # handful of instances where doing so is okay, but in general it's
@@ -2292,9 +2293,10 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
22922293 include = match .group (2 )
22932294 is_system = (match .group (1 ) == '<' )
22942295 if include in include_state :
2295- error (filename , linenum , 'build/include' , 4 ,
2296- '"%s" already included at %s:%s' %
2297- (include , filename , include_state [include ]))
2296+ if not IsErrorSuppressedByNolint ('build/include' , linenum ):
2297+ error (filename , linenum , 'build/include' , 4 ,
2298+ '"%s" already included at %s:%s' %
2299+ (include , filename , include_state [include ]))
22982300 else :
22992301 include_state [include ] = linenum
23002302
@@ -2309,15 +2311,17 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
23092311 # using a number of techniques. The include_state object keeps
23102312 # track of the highest type seen, and complains if we see a
23112313 # lower type after that.
2312- error_message = include_state .CheckNextIncludeOrder (
2313- _ClassifyInclude (fileinfo , include , is_system ))
2314- if error_message :
2315- error (filename , linenum , 'build/include_order' , 4 ,
2316- '%s. Should be: %s.h, c system, c++ system, other.' %
2317- (error_message , fileinfo .BaseName ()))
2314+ if not IsErrorSuppressedByNolint ('build/include_order' , linenum ):
2315+ error_message = include_state .CheckNextIncludeOrder (
2316+ _ClassifyInclude (fileinfo , include , is_system ))
2317+ if error_message :
2318+ error (filename , linenum , 'build/include_order' , 4 ,
2319+ '%s. Should be: %s.h, c system, c++ system, other.' %
2320+ (error_message , fileinfo .BaseName ()))
23182321 if not include_state .IsInAlphabeticalOrder (include ):
2319- error (filename , linenum , 'build/include_alpha' , 4 ,
2320- 'Include "%s" not in alphabetical order' % include )
2322+ if not IsErrorSuppressedByNolint ('build/include_alpha' , linenum ):
2323+ error (filename , linenum , 'build/include_alpha' , 4 ,
2324+ 'Include "%s" not in alphabetical order' % include )
23212325
23222326 # Look for any of the stream classes that are part of standard C++.
23232327 match = _RE_PATTERN_INCLUDE .match (line )
@@ -2326,8 +2330,9 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error):
23262330 if Match (r'(f|ind|io|i|o|parse|pf|stdio|str|)?stream$' , include ):
23272331 # Many unit tests use cout, so we exempt them.
23282332 if not _IsTestFilename (filename ):
2329- error (filename , linenum , 'readability/streams' , 3 ,
2330- 'Streams are highly discouraged.' )
2333+ if not IsErrorSuppressedByNolint ('readability/streams' , linenum ):
2334+ error (filename , linenum , 'readability/streams' , 3 ,
2335+ 'Streams are highly discouraged.' )
23312336
23322337def CheckLanguage (filename , clean_lines , linenum , file_extension , include_state ,
23332338 error ):
0 commit comments