| @@ 5845-5870 (lines=26) @@ | ||
| 5842 | break |
|
| 5843 | ||
| 5844 | ||
| 5845 | def CheckRedundantOverrideOrFinal(filename, clean_lines, linenum, error): |
|
| 5846 | """Check if line contains a redundant "override" or "final" virt-specifier. |
|
| 5847 | ||
| 5848 | Args: |
|
| 5849 | filename: The name of the current file. |
|
| 5850 | clean_lines: A CleansedLines instance containing the file. |
|
| 5851 | linenum: The number of the line to check. |
|
| 5852 | error: The function to call with any errors found. |
|
| 5853 | """ |
|
| 5854 | # Look for closing parenthesis nearby. We need one to confirm where |
|
| 5855 | # the declarator ends and where the virt-specifier starts to avoid |
|
| 5856 | # false positives. |
|
| 5857 | line = clean_lines.elided[linenum] |
|
| 5858 | declarator_end = line.rfind(')') |
|
| 5859 | if declarator_end >= 0: |
|
| 5860 | fragment = line[declarator_end:] |
|
| 5861 | else: |
|
| 5862 | if linenum > 1 and clean_lines.elided[linenum - 1].rfind(')') >= 0: |
|
| 5863 | fragment = line |
|
| 5864 | else: |
|
| 5865 | return |
|
| 5866 | ||
| 5867 | # Check that at most one of "override" or "final" is present, not both |
|
| 5868 | if Search(r'\boverride\b', fragment) and Search(r'\bfinal\b', fragment): |
|
| 5869 | error(filename, linenum, 'readability/inheritance', 4, |
|
| 5870 | ('"override" is redundant since function is ' |
|
| 5871 | 'already declared as "final"')) |
|
| 5872 | ||
| 5873 | ||
| @@ 5845-5870 (lines=26) @@ | ||
| 5842 | break |
|
| 5843 | ||
| 5844 | ||
| 5845 | def CheckRedundantOverrideOrFinal(filename, clean_lines, linenum, error): |
|
| 5846 | """Check if line contains a redundant "override" or "final" virt-specifier. |
|
| 5847 | ||
| 5848 | Args: |
|
| 5849 | filename: The name of the current file. |
|
| 5850 | clean_lines: A CleansedLines instance containing the file. |
|
| 5851 | linenum: The number of the line to check. |
|
| 5852 | error: The function to call with any errors found. |
|
| 5853 | """ |
|
| 5854 | # Look for closing parenthesis nearby. We need one to confirm where |
|
| 5855 | # the declarator ends and where the virt-specifier starts to avoid |
|
| 5856 | # false positives. |
|
| 5857 | line = clean_lines.elided[linenum] |
|
| 5858 | declarator_end = line.rfind(')') |
|
| 5859 | if declarator_end >= 0: |
|
| 5860 | fragment = line[declarator_end:] |
|
| 5861 | else: |
|
| 5862 | if linenum > 1 and clean_lines.elided[linenum - 1].rfind(')') >= 0: |
|
| 5863 | fragment = line |
|
| 5864 | else: |
|
| 5865 | return |
|
| 5866 | ||
| 5867 | # Check that at most one of "override" or "final" is present, not both |
|
| 5868 | if Search(r'\boverride\b', fragment) and Search(r'\bfinal\b', fragment): |
|
| 5869 | error(filename, linenum, 'readability/inheritance', 4, |
|
| 5870 | ('"override" is redundant since function is ' |
|
| 5871 | 'already declared as "final"')) |
|
| 5872 | ||
| 5873 | ||