MCPcopy Index your code
hub / github.com/cpplint/cpplint / CheckNextIncludeOrder

Method CheckNextIncludeOrder

cpplint.py:1329–1386  ·  view source on GitHub ↗

Returns a non-empty error message if the next header is out of order. This function also updates the internal state to be ready to check the next include. Args: header_type: One of the _XXX_HEADER constants defined above. Returns: The empty stri

(self, header_type)

Source from the content-addressed store, hash-verified

1327 )
1328
1329 def CheckNextIncludeOrder(self, header_type):
1330 """Returns a non-empty error message if the next header is out of order.
1331
1332 This function also updates the internal state to be ready to check
1333 the next include.
1334
1335 Args:
1336 header_type: One of the _XXX_HEADER constants defined above.
1337
1338 Returns:
1339 The empty string if the header is in the right order, or an
1340 error message describing what's wrong.
1341
1342 """
1343 error_message = (
1344 f"Found {self._TYPE_NAMES[header_type]} after {self._SECTION_NAMES[self._section]}"
1345 )
1346
1347 last_section = self._section
1348
1349 if header_type == _C_SYS_HEADER:
1350 if self._section <= self._C_SECTION:
1351 self._section = self._C_SECTION
1352 else:
1353 self._last_header = ""
1354 return error_message
1355 elif header_type == _CPP_SYS_HEADER:
1356 if self._section <= self._CPP_SECTION:
1357 self._section = self._CPP_SECTION
1358 else:
1359 self._last_header = ""
1360 return error_message
1361 elif header_type == _OTHER_SYS_HEADER:
1362 if self._section <= self._OTHER_SYS_SECTION:
1363 self._section = self._OTHER_SYS_SECTION
1364 else:
1365 self._last_header = ""
1366 return error_message
1367 elif header_type == _LIKELY_MY_HEADER:
1368 if self._section <= self._MY_H_SECTION:
1369 self._section = self._MY_H_SECTION
1370 else:
1371 self._section = self._OTHER_H_SECTION
1372 elif header_type == _POSSIBLE_MY_HEADER:
1373 if self._section <= self._MY_H_SECTION:
1374 self._section = self._MY_H_SECTION
1375 else:
1376 # This will always be the fallback because we're not sure
1377 # enough that the header is associated with this file.
1378 self._section = self._OTHER_H_SECTION
1379 else:
1380 assert header_type == _OTHER_HEADER
1381 self._section = self._OTHER_H_SECTION
1382
1383 if last_section != self._section:
1384 self._last_header = ""
1385
1386 return ""

Calls

no outgoing calls