Maintains module-wide state..
| 1427 | |
| 1428 | |
| 1429 | class _CppLintState: |
| 1430 | """Maintains module-wide state..""" |
| 1431 | |
| 1432 | def __init__(self): |
| 1433 | self.verbose_level = 1 # global setting. |
| 1434 | self.error_count = 0 # global count of reported errors |
| 1435 | # filters to apply when emitting error messages |
| 1436 | self.filters = _DEFAULT_FILTERS[:] |
| 1437 | # backup of filter list. Used to restore the state after each file. |
| 1438 | self._filters_backup = self.filters[:] |
| 1439 | self.counting = "total" # In what way are we counting errors? |
| 1440 | self.errors_by_category = {} # string to int dict storing error counts |
| 1441 | self.quiet = False # Suppress non-error messages? |
| 1442 | |
| 1443 | # output format: |
| 1444 | # "emacs" - format that emacs can parse (default) |
| 1445 | # "eclipse" - format that eclipse can parse |
| 1446 | # "vs7" - format that Microsoft Visual Studio 7 can parse |
| 1447 | # "junit" - format that Jenkins, Bamboo, etc can parse |
| 1448 | # "sed" - returns a gnu sed command to fix the problem |
| 1449 | # "gsed" - like sed, but names the command gsed, e.g. for macOS homebrew users |
| 1450 | self.output_format = "emacs" |
| 1451 | |
| 1452 | # For JUnit output, save errors and failures until the end so that they |
| 1453 | # can be written into the XML |
| 1454 | self._junit_errors = [] |
| 1455 | self._junit_failures = [] |
| 1456 | |
| 1457 | def SetOutputFormat(self, output_format): |
| 1458 | """Sets the output format for errors.""" |
| 1459 | self.output_format = output_format |
| 1460 | |
| 1461 | def SetQuiet(self, quiet): |
| 1462 | """Sets the module's quiet settings, and returns the previous setting.""" |
| 1463 | last_quiet = self.quiet |
| 1464 | self.quiet = quiet |
| 1465 | return last_quiet |
| 1466 | |
| 1467 | def SetVerboseLevel(self, level): |
| 1468 | """Sets the module's verbosity, and returns the previous setting.""" |
| 1469 | last_verbose_level = self.verbose_level |
| 1470 | self.verbose_level = level |
| 1471 | return last_verbose_level |
| 1472 | |
| 1473 | def SetCountingStyle(self, counting_style): |
| 1474 | """Sets the module's counting options.""" |
| 1475 | self.counting = counting_style |
| 1476 | |
| 1477 | def SetFilters(self, filters): |
| 1478 | """Sets the error-message filters. |
| 1479 | |
| 1480 | These filters are applied when deciding whether to emit a given |
| 1481 | error message. |
| 1482 | |
| 1483 | Args: |
| 1484 | filters: A string of comma-separated filters (eg "+whitespace/indent"). |
| 1485 | Each filter should start with + or -; else we die. |
| 1486 |
no outgoing calls
no test coverage detected
searching dependent graphs…