@@ 1383-1419 (lines=37) @@ | ||
1380 | return True |
|
1381 | ||
1382 | ||
1383 | def Error(filename, linenum, category, confidence, message): |
|
1384 | """Logs the fact we've found a lint error. |
|
1385 | ||
1386 | We log where the error was found, and also our confidence in the error, |
|
1387 | that is, how certain we are this is a legitimate style regression, and |
|
1388 | not a misidentification or a use that's sometimes justified. |
|
1389 | ||
1390 | False positives can be suppressed by the use of |
|
1391 | "cpplint(category)" comments on the offending line. These are |
|
1392 | parsed into _error_suppressions. |
|
1393 | ||
1394 | Args: |
|
1395 | filename: The name of the file containing the error. |
|
1396 | linenum: The number of the line containing the error. |
|
1397 | category: A string used to describe the "category" this bug |
|
1398 | falls under: "whitespace", say, or "runtime". Categories |
|
1399 | may have a hierarchy separated by slashes: "whitespace/indent". |
|
1400 | confidence: A number from 1-5 representing a confidence score for |
|
1401 | the error, with 5 meaning that we are certain of the problem, |
|
1402 | and 1 meaning that it could be a legitimate construct. |
|
1403 | message: The error message. |
|
1404 | """ |
|
1405 | if _ShouldPrintError(category, confidence, linenum): |
|
1406 | _cpplint_state.IncrementErrorCount(category) |
|
1407 | if _cpplint_state.output_format == 'vs7': |
|
1408 | _cpplint_state.PrintError('%s(%s): warning: %s [%s] [%d]\n' % ( |
|
1409 | filename, linenum, message, category, confidence)) |
|
1410 | elif _cpplint_state.output_format == 'eclipse': |
|
1411 | sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( |
|
1412 | filename, linenum, message, category, confidence)) |
|
1413 | elif _cpplint_state.output_format == 'junit': |
|
1414 | _cpplint_state.AddJUnitFailure(filename, linenum, message, category, |
|
1415 | confidence) |
|
1416 | else: |
|
1417 | final_message = '%s:%s: %s [%s] [%d]\n' % ( |
|
1418 | filename, linenum, message, category, confidence) |
|
1419 | sys.stderr.write(final_message) |
|
1420 | ||
1421 | # Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. |
|
1422 | _RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( |
@@ 1383-1419 (lines=37) @@ | ||
1380 | return True |
|
1381 | ||
1382 | ||
1383 | def Error(filename, linenum, category, confidence, message): |
|
1384 | """Logs the fact we've found a lint error. |
|
1385 | ||
1386 | We log where the error was found, and also our confidence in the error, |
|
1387 | that is, how certain we are this is a legitimate style regression, and |
|
1388 | not a misidentification or a use that's sometimes justified. |
|
1389 | ||
1390 | False positives can be suppressed by the use of |
|
1391 | "cpplint(category)" comments on the offending line. These are |
|
1392 | parsed into _error_suppressions. |
|
1393 | ||
1394 | Args: |
|
1395 | filename: The name of the file containing the error. |
|
1396 | linenum: The number of the line containing the error. |
|
1397 | category: A string used to describe the "category" this bug |
|
1398 | falls under: "whitespace", say, or "runtime". Categories |
|
1399 | may have a hierarchy separated by slashes: "whitespace/indent". |
|
1400 | confidence: A number from 1-5 representing a confidence score for |
|
1401 | the error, with 5 meaning that we are certain of the problem, |
|
1402 | and 1 meaning that it could be a legitimate construct. |
|
1403 | message: The error message. |
|
1404 | """ |
|
1405 | if _ShouldPrintError(category, confidence, linenum): |
|
1406 | _cpplint_state.IncrementErrorCount(category) |
|
1407 | if _cpplint_state.output_format == 'vs7': |
|
1408 | _cpplint_state.PrintError('%s(%s): warning: %s [%s] [%d]\n' % ( |
|
1409 | filename, linenum, message, category, confidence)) |
|
1410 | elif _cpplint_state.output_format == 'eclipse': |
|
1411 | sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( |
|
1412 | filename, linenum, message, category, confidence)) |
|
1413 | elif _cpplint_state.output_format == 'junit': |
|
1414 | _cpplint_state.AddJUnitFailure(filename, linenum, message, category, |
|
1415 | confidence) |
|
1416 | else: |
|
1417 | final_message = '%s:%s: %s [%s] [%d]\n' % ( |
|
1418 | filename, linenum, message, category, confidence) |
|
1419 | sys.stderr.write(final_message) |
|
1420 | ||
1421 | # Matches standard C++ escape sequences per 2.13.2.3 of the C++ standard. |
|
1422 | _RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( |