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)
| 1188 | |
| 1189 | |
| 1190 | def Error(filename, linenum, category, confidence, message): |
| 1191 | """Logs the fact we've found a lint error. |
| 1192 | |
| 1193 | We log where the error was found, and also our confidence in the error, |
| 1194 | that is, how certain we are this is a legitimate style regression, and |
| 1195 | not a misidentification or a use that's sometimes justified. |
| 1196 | |
| 1197 | False positives can be suppressed by the use of |
| 1198 | "cpplint(category)" comments on the offending line. These are |
| 1199 | parsed into _error_suppressions. |
| 1200 | |
| 1201 | Args: |
| 1202 | filename: The name of the file containing the error. |
| 1203 | linenum: The number of the line containing the error. |
| 1204 | category: A string used to describe the "category" this bug |
| 1205 | falls under: "whitespace", say, or "runtime". Categories |
| 1206 | may have a hierarchy separated by slashes: "whitespace/indent". |
| 1207 | confidence: A number from 1-5 representing a confidence score for |
| 1208 | the error, with 5 meaning that we are certain of the problem, |
| 1209 | and 1 meaning that it could be a legitimate construct. |
| 1210 | message: The error message. |
| 1211 | """ |
| 1212 | if _ShouldPrintError(category, confidence, linenum): |
| 1213 | _cpplint_state.IncrementErrorCount(category) |
| 1214 | if _cpplint_state.output_format == 'vs7': |
| 1215 | sys.stderr.write('%s(%s): %s [%s] [%d]\n' % ( |
| 1216 | filename, linenum, message, category, confidence)) |
| 1217 | elif _cpplint_state.output_format == 'eclipse': |
| 1218 | sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( |
| 1219 | filename, linenum, message, category, confidence)) |
| 1220 | else: |
| 1221 | sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( |
| 1222 | filename, linenum, message, category, confidence)) |
| 1223 | |
| 1224 | |
| 1225 | # Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. |
no test coverage detected