Logs the fact we've found a lint error. We log where the error was found, and also our confidence in the error, that is, how certain we are this is a legitimate style regression, and not a misidentification or a use that's sometimes justified. False positives can be suppressed by t
(filename, linenum, category, confidence, message)
| 1887 | |
| 1888 | |
| 1889 | def Error(filename, linenum, category, confidence, message): |
| 1890 | """Logs the fact we've found a lint error. |
| 1891 | |
| 1892 | We log where the error was found, and also our confidence in the error, |
| 1893 | that is, how certain we are this is a legitimate style regression, and |
| 1894 | not a misidentification or a use that's sometimes justified. |
| 1895 | |
| 1896 | False positives can be suppressed by the use of "NOLINT(category)" |
| 1897 | comments, NOLINTNEXTLINE or in blocks started by NOLINTBEGIN. These |
| 1898 | are parsed into _error_suppressions. |
| 1899 | |
| 1900 | Args: |
| 1901 | filename: The name of the file containing the error. |
| 1902 | linenum: The number of the line containing the error. |
| 1903 | category: A string used to describe the "category" this bug |
| 1904 | falls under: "whitespace", say, or "runtime". Categories |
| 1905 | may have a hierarchy separated by slashes: "whitespace/indent". |
| 1906 | confidence: A number from 1-5 representing a confidence score for |
| 1907 | the error, with 5 meaning that we are certain of the problem, |
| 1908 | and 1 meaning that it could be a legitimate construct. |
| 1909 | message: The error message. |
| 1910 | """ |
| 1911 | if _ShouldPrintError(category, confidence, filename, linenum): |
| 1912 | _cpplint_state.IncrementErrorCount(category) |
| 1913 | if _cpplint_state.output_format == "vs7": |
| 1914 | _cpplint_state.PrintError( |
| 1915 | f"{filename}({linenum}): error cpplint: [{category}] {message} [{confidence}]\n" |
| 1916 | ) |
| 1917 | elif _cpplint_state.output_format == "eclipse": |
| 1918 | sys.stderr.write( |
| 1919 | f"{filename}:{linenum}: warning: {message} [{category}] [{confidence}]\n" |
| 1920 | ) |
| 1921 | elif _cpplint_state.output_format == "junit": |
| 1922 | _cpplint_state.AddJUnitFailure(filename, linenum, message, category, confidence) |
| 1923 | elif _cpplint_state.output_format in ["sed", "gsed"]: |
| 1924 | if message in _SED_FIXUPS: |
| 1925 | sys.stdout.write( |
| 1926 | f"{_cpplint_state.output_format} -i" |
| 1927 | f" '{linenum}{_SED_FIXUPS[message]}' {filename}" |
| 1928 | f" # {message} [{category}] [{confidence}]\n" |
| 1929 | ) |
| 1930 | else: |
| 1931 | sys.stderr.write( |
| 1932 | f'# {filename}:{linenum}: "{message}" [{category}] [{confidence}]\n' |
| 1933 | ) |
| 1934 | else: |
| 1935 | final_message = f"{filename}:{linenum}: {message} [{category}] [{confidence}]\n" |
| 1936 | sys.stderr.write(final_message) |
| 1937 | |
| 1938 | |
| 1939 | # Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. |
no test coverage detected
searching dependent graphs…