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

Method testErrorSuppression

cpplint_unittest.py:497–790  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

495
496 # Test error suppression annotations.
497 def testErrorSuppression(self):
498 # Two errors on same line:
499 self.TestLint(
500 "long a = (int64_t) 65;",
501 [
502 "Using C-style cast. Use static_cast<int64_t>(...) instead"
503 " [readability/casting] [4]",
504 "Use int16_t/int64_t/etc, rather than the C type long [runtime/int] [4]",
505 ],
506 )
507 # One category of error suppressed:
508 self.TestLint(
509 "long a = (int64_t) 65; // NOLINT(runtime/int)",
510 "Using C-style cast. Use static_cast<int64_t>(...) instead [readability/casting] [4]",
511 )
512 # Two categories of errors suppressed:
513 self.TestLint("long a = (int64_t) 65; // NOLINT(runtime/int,readability/casting)", "")
514
515 # All categories suppressed: (two aliases)
516 self.TestLint("long a = (int64_t) 65; // NOLINT", "")
517 self.TestLint("long a = (int64_t) 65; // NOLINT(*)", "")
518
519 # Linting a C file
520 error_collector = ErrorCollector(self.assertTrue)
521 cpplint.ProcessFileData(
522 "test.c",
523 "c",
524 ["// Copyright 2014 Your Majesty.", "int64_t a = (int64_t) 65;", ""],
525 error_collector,
526 )
527 assert error_collector.Results() == ""
528
529 # Malformed NOLINT directive:
530 self.TestLint(
531 "long a = 65; // NOLINT(foo)",
532 [
533 "Unknown NOLINT error category: foo [readability/nolint] [5]",
534 "Use int16_t/int64_t/etc, rather than the C type long [runtime/int] [4]",
535 ],
536 )
537 # Irrelevant NOLINT directive has no effect:
538 self.TestLint(
539 "long a = 65; // NOLINT(readability/casting)",
540 "Use int16_t/int64_t/etc, rather than the C type long [runtime/int] [4]",
541 )
542 # NOLINTNEXTLINE silences warning for the next line instead of current line
543 error_collector = ErrorCollector(self.assertTrue)
544 cpplint.ProcessFileData(
545 "test.cc",
546 "cc",
547 [
548 "// Copyright 2014 Your Company.",
549 "// NOLINTNEXTLINE(whitespace/line_length)",
550 "// ./command" + (" -verbose" * 80),
551 "",
552 ],
553 error_collector,
554 )

Callers

nothing calls this directly

Calls 3

ResultsMethod · 0.95
ErrorCollectorClass · 0.85
TestLintMethod · 0.80

Tested by

no test coverage detected