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 the use o
(filename, linenum, category, confidence, message)
| 1090 | |
| 1091 | |
| 1092 | def Error(filename, linenum, category, confidence, message): |
| 1093 | """Logs the fact we've found a lint error. |
| 1094 | |
| 1095 | We log where the error was found, and also our confidence in the error, |
| 1096 | that is, how certain we are this is a legitimate style regression, and |
| 1097 | not a misidentification or a use that's sometimes justified. |
| 1098 | |
| 1099 | False positives can be suppressed by the use of |
| 1100 | "cpplint(category)" comments on the offending line. These are |
| 1101 | parsed into _error_suppressions. |
| 1102 | |
| 1103 | Args: |
| 1104 | filename: The name of the file containing the error. |
| 1105 | linenum: The number of the line containing the error. |
| 1106 | category: A string used to describe the "category" this bug |
| 1107 | falls under: "whitespace", say, or "runtime". Categories |
| 1108 | may have a hierarchy separated by slashes: "whitespace/indent". |
| 1109 | confidence: A number from 1-5 representing a confidence score for |
| 1110 | the error, with 5 meaning that we are certain of the problem, |
| 1111 | and 1 meaning that it could be a legitimate construct. |
| 1112 | message: The error message. |
| 1113 | """ |
| 1114 | if _ShouldPrintError(category, confidence, linenum): |
| 1115 | _cpplint_state.IncrementErrorCount(category) |
| 1116 | if _cpplint_state.output_format == 'vs7': |
| 1117 | sys.stderr.write('%s(%s): %s [%s] [%d]\n' % ( |
| 1118 | filename, linenum, message, category, confidence)) |
| 1119 | elif _cpplint_state.output_format == 'eclipse': |
| 1120 | sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( |
| 1121 | filename, linenum, message, category, confidence)) |
| 1122 | else: |
| 1123 | sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( |
| 1124 | filename, linenum, message, category, confidence)) |
| 1125 | |
| 1126 | |
| 1127 | # Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. |
no test coverage detected