OLD | NEW |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # | 2 # |
3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. | 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. |
4 # Copyright (C) 2009 Torch Mobile Inc. | 4 # Copyright (C) 2009 Torch Mobile Inc. |
5 # Copyright (C) 2009 Apple Inc. All rights reserved. | 5 # Copyright (C) 2009 Apple Inc. All rights reserved. |
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
7 # | 7 # |
8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
9 # modification, are permitted provided that the following conditions are | 9 # modification, are permitted provided that the following conditions are |
10 # met: | 10 # met: |
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1484 if not (well_typed_bitfield or classinfo.name.startswith('SameSizeAs') or | 1484 if not (well_typed_bitfield or classinfo.name.startswith('SameSizeAs') or |
1485 classinfo.name.startswith('Expected')): | 1485 classinfo.name.startswith('Expected')): |
1486 args = match(r'\s*(\S+)\s+(\S+)\s*:\s*\d+\s*;', line) | 1486 args = match(r'\s*(\S+)\s+(\S+)\s*:\s*\d+\s*;', line) |
1487 if args: | 1487 if args: |
1488 error(line_number, 'runtime/bitfields', 4, | 1488 error(line_number, 'runtime/bitfields', 4, |
1489 'Member %s of class %s defined as a bitfield of type %s. ' | 1489 'Member %s of class %s defined as a bitfield of type %s. ' |
1490 'Please declare all bitfields as unsigned.' | 1490 'Please declare all bitfields as unsigned.' |
1491 % (args.group(2), classinfo.name, args.group(1))) | 1491 % (args.group(2), classinfo.name, args.group(1))) |
1492 | 1492 |
1493 | 1493 |
1494 def check_spacing_for_function_call(line, line_number, error): | |
1495 """Checks for the correctness of various spacing around function calls. | |
1496 | |
1497 Args: | |
1498 line: The text of the line to check. | |
1499 line_number: The number of the line to check. | |
1500 error: The function to call with any errors found. | |
1501 """ | |
1502 | |
1503 # Since function calls often occur inside if/for/foreach/while/switch | |
1504 # expressions - which have their own, more liberal conventions - we | |
1505 # first see if we should be looking inside such an expression for a | |
1506 # function call, to which we can apply more strict standards. | |
1507 function_call = line # if there's no control flow construct, look at whol e line | |
1508 for pattern in (r'\bif\s*\((.*)\)\s*{', | |
1509 r'\bfor\s*\((.*)\)\s*{', | |
1510 r'\bforeach\s*\((.*)\)\s*{', | |
1511 r'\bwhile\s*\((.*)\)\s*[{;]', | |
1512 r'\bswitch\s*\((.*)\)\s*{'): | |
1513 matched = search(pattern, line) | |
1514 if matched: | |
1515 function_call = matched.group(1) # look inside the parens for fun ction calls | |
1516 break | |
1517 | |
1518 # Except in if/for/foreach/while/switch, there should never be space | |
1519 # immediately inside parens (eg "f( 3, 4 )"). We make an exception | |
1520 # for nested parens ( (a+b) + c ). Likewise, there should never be | |
1521 # a space before a ( when it's a function argument. I assume it's a | |
1522 # function argument when the char before the whitespace is legal in | |
1523 # a function name (alnum + _) and we're not starting a macro. Also ignore | |
1524 # pointers and references to arrays and functions coz they're too tricky: | |
1525 # we use a very simple way to recognize these: | |
1526 # " (something)(maybe-something)" or | |
1527 # " (something)(maybe-something," or | |
1528 # " (something)[something]" | |
1529 # Note that we assume the contents of [] to be short enough that | |
1530 # they'll never need to wrap. | |
1531 if ( # Ignore control structures. | |
1532 not search(r'\b(if|for|foreach|while|switch|return|new|delete)\b', f unction_call) | |
1533 # Ignore pointers/references to functions. | |
1534 and not search(r' \([^)]+\)\([^)]*(\)|,$)', function_call) | |
1535 # Ignore pointers/references to arrays. | |
1536 and not search(r' \([^)]+\)\[[^\]]+\]', function_call)): | |
1537 if search(r'\w\s*\([ \t](?!\s*\\$)', function_call): # a ( used for a fn call | |
1538 error(line_number, 'whitespace/parens', 4, | |
1539 'Extra space after ( in function call') | |
1540 elif search(r'\([ \t]+(?!(\s*\\)|\()', function_call): | |
1541 error(line_number, 'whitespace/parens', 2, | |
1542 'Extra space after (') | |
1543 # If the ) is followed only by a newline or a { + newline, assume it's | |
1544 # part of a control statement (if/while/etc), and don't complain | |
1545 if search(r'[^)\s]\s+\)(?!\s*$|{\s*$)', function_call): | |
1546 error(line_number, 'whitespace/parens', 2, | |
1547 'Extra space before )') | |
1548 | |
1549 | |
1550 def is_blank_line(line): | 1494 def is_blank_line(line): |
1551 """Returns true if the given line is blank. | 1495 """Returns true if the given line is blank. |
1552 | 1496 |
1553 We consider a line to be blank if the line is empty or consists of | 1497 We consider a line to be blank if the line is empty or consists of |
1554 only white spaces. | 1498 only white spaces. |
1555 | 1499 |
1556 Args: | 1500 Args: |
1557 line: A line of a string. | 1501 line: A line of a string. |
1558 | 1502 |
1559 Returns: | 1503 Returns: |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1819 line, don't end a function with a blank line, don't have too many | 1763 line, don't end a function with a blank line, don't have too many |
1820 blank lines in a row. | 1764 blank lines in a row. |
1821 | 1765 |
1822 Args: | 1766 Args: |
1823 file_extension: The current file extension, without the leading dot. | 1767 file_extension: The current file extension, without the leading dot. |
1824 clean_lines: A CleansedLines instance containing the file. | 1768 clean_lines: A CleansedLines instance containing the file. |
1825 line_number: The number of the line to check. | 1769 line_number: The number of the line to check. |
1826 error: The function to call with any errors found. | 1770 error: The function to call with any errors found. |
1827 """ | 1771 """ |
1828 | 1772 |
1829 raw = clean_lines.raw_lines | |
1830 line = raw[line_number] | |
1831 | |
1832 # Before nixing comments, check if the line is blank for no good | |
1833 # reason. This includes the first line after a block is opened, and | |
1834 # blank lines at the end of a function (ie, right before a line like '}'). | |
1835 if is_blank_line(line): | |
1836 elided = clean_lines.elided | |
1837 previous_line = elided[line_number - 1] | |
1838 previous_brace = previous_line.rfind('{') | |
1839 # FIXME: Don't complain if line before blank line, and line after, | |
1840 # both start with alnums and are indented the same amount. | |
1841 # This ignores whitespace at the start of a namespace block | |
1842 # because those are not usually indented. | |
1843 if (previous_brace != -1 and previous_line[previous_brace:].find('}') == -1 | |
1844 and previous_line[:previous_brace].find('namespace') == -1): | |
1845 # OK, we have a blank line at the start of a code block. Before we | |
1846 # complain, we check if it is an exception to the rule: The previous | |
1847 # non-empty line has the parameters of a function header that are in dented | |
1848 # 4 spaces (because they did not fit in a 80 column line when placed on | |
1849 # the same line as the function name). We also check for the case w here | |
1850 # the previous line is indented 6 spaces, which may happen when the | |
1851 # initializers of a constructor do not fit into a 80 column line. | |
1852 exception = False | |
1853 if match(r' {6}\w', previous_line): # Initializer list? | |
1854 # We are looking for the opening column of initializer list, whi ch | |
1855 # should be indented 4 spaces to cause 6 space indentation after wards. | |
1856 search_position = line_number - 2 | |
1857 while (search_position >= 0 | |
1858 and match(r' {6}\w', elided[search_position])): | |
1859 search_position -= 1 | |
1860 exception = (search_position >= 0 | |
1861 and elided[search_position][:5] == ' :') | |
1862 else: | |
1863 # Search for the function arguments or an initializer list. We use a | |
1864 # simple heuristic here: If the line is indented 4 spaces; and w e have a | |
1865 # closing paren, without the opening paren, followed by an openi ng brace | |
1866 # or colon (for initializer lists) we assume that it is the last line of | |
1867 # a function header. If we have a colon indented 4 spaces, it i s an | |
1868 # initializer list. | |
1869 exception = (match(r' {4}\w[^\(]*\)\s*(const\s*)?(\{\s*$|:)', | |
1870 previous_line) | |
1871 or match(r' {4}:', previous_line)) | |
1872 | |
1873 if not exception: | |
1874 error(line_number, 'whitespace/blank_line', 2, | |
1875 'Blank line at the start of a code block. Is this needed? ') | |
1876 # This doesn't ignore whitespace at the end of a namespace block | |
1877 # because that is too hard without pairing open/close braces; | |
1878 # however, a special exception is made for namespace closing | |
1879 # brackets which have a comment containing "namespace". | |
1880 # | |
1881 # Also, ignore blank lines at the end of a block in a long if-else | |
1882 # chain, like this: | |
1883 # if (condition1) { | |
1884 # // Something followed by a blank line | |
1885 # | |
1886 # } else if (condition2) { | |
1887 # // Something else | |
1888 # } | |
1889 if line_number + 1 < clean_lines.num_lines(): | |
1890 next_line = raw[line_number + 1] | |
1891 if next_line and match(r'\s*}', next_line) and 'namespace' not in ne xt_line and '} else ' not in next_line: | |
1892 error(line_number, 'whitespace/blank_line', 3, | |
1893 'Blank line at the end of a code block. Is this needed?') | |
1894 | |
1895 line = clean_lines.elided[line_number] # get rid of comments and strings | 1773 line = clean_lines.elided[line_number] # get rid of comments and strings |
1896 | 1774 |
1897 # Don't try to do spacing checks for operator methods | |
1898 line = sub(r'operator(==|!=|<|<<|<=|>=|>>|>|\+=|-=|\*=|/=|%=|&=|\|=|^=|<<=|> >=|/)\(', 'operator\(', line) | |
1899 # Don't try to do spacing checks for #include or #import statements at | |
1900 # minimum because it messes up checks for spacing around / | |
1901 if match(r'\s*#\s*(?:include|import)', line): | |
1902 return | |
1903 if search(r'[\w.]=[\w.]', line): | |
1904 error(line_number, 'whitespace/operators', 4, | |
1905 'Missing spaces around =') | |
1906 | |
1907 # There shouldn't be space around unary operators | |
1908 matched = search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line) | |
1909 if matched: | |
1910 error(line_number, 'whitespace/operators', 4, | |
1911 'Extra space for operator %s' % matched.group(1)) | |
1912 | |
1913 # A pet peeve of mine: no spaces after an if, while, switch, or for | |
1914 matched = search(r' (if\(|for\(|foreach\(|while\(|switch\()', line) | |
1915 if matched: | |
1916 error(line_number, 'whitespace/parens', 5, | |
1917 'Missing space before ( in %s' % matched.group(1)) | |
1918 | |
1919 # For if/for/foreach/while/switch, the left and right parens should be | |
1920 # consistent about how many spaces are inside the parens, and | |
1921 # there should either be zero or one spaces inside the parens. | |
1922 # We don't want: "if ( foo)" or "if ( foo )". | |
1923 # Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed. | |
1924 matched = search(r'\b(?P<statement>if|for|foreach|while|switch)\s*\((?P<rema inder>.*)$', line) | |
1925 if matched: | |
1926 statement = matched.group('statement') | |
1927 condition, rest = up_to_unmatched_closing_paren(matched.group('remainder ')) | |
1928 if condition is not None: | |
1929 condition_match = search(r'(?P<leading>[ ]*)(?P<separator>.).*[^ ]+( ?P<trailing>[ ]*)', condition) | |
1930 if condition_match: | |
1931 n_leading = len(condition_match.group('leading')) | |
1932 n_trailing = len(condition_match.group('trailing')) | |
1933 if n_leading != 0: | |
1934 for_exception = statement == 'for' and condition.startswith( ' ;') | |
1935 if not for_exception: | |
1936 error(line_number, 'whitespace/parens', 5, | |
1937 'Extra space after ( in %s' % statement) | |
1938 if n_trailing != 0: | |
1939 for_exception = statement == 'for' and condition.endswith('; ') | |
1940 if not for_exception: | |
1941 error(line_number, 'whitespace/parens', 5, | |
1942 'Extra space before ) in %s' % statement) | |
1943 | |
1944 # Do not check for more than one command in macros | |
1945 in_preprocessor_directive = match(r'\s*#', line) | |
1946 if not in_preprocessor_directive and not match(r'((\s*{\s*}?)|(\s*;? ))\s*\\?$', rest): | |
1947 error(line_number, 'whitespace/parens', 4, | |
1948 'More than one command on the same line in %s' % statement ) | |
1949 | |
1950 # You should always have a space after a comma (either as fn arg or operator ) | |
1951 if search(r',[^\s]', line): | |
1952 error(line_number, 'whitespace/comma', 3, | |
1953 'Missing space after ,') | |
1954 | |
1955 matched = search(r'^\s*(?P<token1>[a-zA-Z0-9_\*&]+)\s\s+(?P<token2>[a-zA-Z0- 9_\*&]+)', line) | |
1956 if matched: | |
1957 error(line_number, 'whitespace/declaration', 3, | |
1958 'Extra space between %s and %s' % (matched.group('token1'), matche d.group('token2'))) | |
1959 | |
1960 if file_extension == 'cpp': | |
1961 # C++ should have the & or * beside the type not the variable name. | |
1962 matched = match(r'\s*\w+(?<!\breturn|\bdelete)\s+(?P<pointer_operator>\* |\&)\w+', line) | |
1963 if matched: | |
1964 error(line_number, 'whitespace/declaration', 3, | |
1965 'Declaration has space between type name and %s in %s' % ( | |
1966 matched.group('pointer_operator'), matched.group(0).strip( ))) | |
1967 | |
1968 elif file_extension == 'c': | |
1969 # C Pointer declaration should have the * beside the variable not the ty pe name. | |
1970 matched = search(r'^\s*\w+\*\s+\w+', line) | |
1971 if matched: | |
1972 error(line_number, 'whitespace/declaration', 3, | |
1973 'Declaration has space between * and variable name in %s' % ma tched.group(0).strip()) | |
1974 | |
1975 # Next we will look for issues with function calls. | |
1976 check_spacing_for_function_call(line, line_number, error) | |
1977 | |
1978 # Make sure '} else {' has spaces. | |
1979 if search(r'}else', line): | |
1980 error(line_number, 'whitespace/braces', 5, | |
1981 'Missing space before else') | |
1982 | |
1983 # You shouldn't have spaces before your brackets, except maybe after | |
1984 # 'delete []' or 'new char * []'. | |
1985 if search(r'\w\s+\[', line) and not search(r'delete\s+\[', line): | |
1986 error(line_number, 'whitespace/braces', 5, | |
1987 'Extra space before [') | |
1988 | |
1989 # There should always be zero or one space in between braces on the same lin e. | |
1990 if search(r'\{\s\s+\}', line): | |
1991 error(line_number, 'whitespace/braces', 5, 'Too many spaces inside { }.' ) | |
1992 | |
1993 # You shouldn't have a space before a semicolon at the end of the line. | 1775 # You shouldn't have a space before a semicolon at the end of the line. |
1994 # There's a special case for "for" since the style guide allows space before | 1776 # There's a special case for "for" since the style guide allows space before |
1995 # the semicolon there. | 1777 # the semicolon there. |
1996 if search(r':\s*;\s*$', line): | 1778 if search(r':\s*;\s*$', line): |
1997 error(line_number, 'whitespace/semicolon', 5, | 1779 error(line_number, 'whitespace/semicolon', 5, |
1998 'Semicolon defining empty statement. Use { } instead.') | 1780 'Semicolon defining empty statement. Use { } instead.') |
1999 elif search(r'^\s*;\s*$', line): | 1781 elif search(r'^\s*;\s*$', line): |
2000 error(line_number, 'whitespace/semicolon', 5, | 1782 error(line_number, 'whitespace/semicolon', 5, |
2001 'Line contains only semicolon. If this should be an empty statemen t, ' | 1783 'Line contains only semicolon. If this should be an empty statemen t, ' |
2002 'use { } instead.') | 1784 'use { } instead.') |
2003 elif search(r'\s+;\s*$', line) and not search(r'\bfor\b', line): | |
2004 error(line_number, 'whitespace/semicolon', 5, | |
2005 'Extra space before last semicolon. If this should be an empty ' | |
2006 'statement, use { } instead.') | |
2007 elif (search(r'\b(for|while)\s*\(.*\)\s*;\s*$', line) | 1785 elif (search(r'\b(for|while)\s*\(.*\)\s*;\s*$', line) |
2008 and line.count('(') == line.count(')') | 1786 and line.count('(') == line.count(')') |
2009 # Allow do {} while(); | 1787 # Allow do {} while(); |
2010 and not search(r'}\s*while', line)): | 1788 and not search(r'}\s*while', line)): |
2011 error(line_number, 'whitespace/semicolon', 5, | 1789 error(line_number, 'whitespace/semicolon', 5, |
2012 'Semicolon defining empty statement for this loop. Use { } instead .') | 1790 'Semicolon defining empty statement for this loop. Use { } instead .') |
Nico
2016/10/01 16:39:46
I think this is caught by a compiler warning too
dcheng
2016/10/01 19:48:04
At least in a simple test, I wasn't able to get th
Nico
2016/10/03 18:11:17
It only fires when it's actively buggy:
tthakis@t
| |
2013 | 1791 |
2014 | 1792 |
2015 def get_previous_non_blank_line(clean_lines, line_number): | 1793 def get_previous_non_blank_line(clean_lines, line_number): |
2016 """Return the most recent non-blank line and its line number. | 1794 """Return the most recent non-blank line and its line number. |
2017 | 1795 |
2018 Args: | 1796 Args: |
2019 clean_lines: A CleansedLines instance containing the file contents. | 1797 clean_lines: A CleansedLines instance containing the file contents. |
2020 line_number: The number of the line to check. | 1798 line_number: The number of the line to check. |
2021 | 1799 |
2022 Returns: | 1800 Returns: |
2023 A tuple with two elements. The first element is the contents of the last | 1801 A tuple with two elements. The first element is the contents of the last |
2024 non-blank line before the current line, or the empty string if this is the | 1802 non-blank line before the current line, or the empty string if this is the |
2025 first non-blank line. The second is the line number of that line, or -1 | 1803 first non-blank line. The second is the line number of that line, or -1 |
2026 if this is the first non-blank line. | 1804 if this is the first non-blank line. |
2027 """ | 1805 """ |
2028 | 1806 |
2029 previous_line_number = line_number - 1 | 1807 previous_line_number = line_number - 1 |
2030 while previous_line_number >= 0: | 1808 while previous_line_number >= 0: |
2031 previous_line = clean_lines.elided[previous_line_number] | 1809 previous_line = clean_lines.elided[previous_line_number] |
2032 if not is_blank_line(previous_line): # if not a blank line... | 1810 if not is_blank_line(previous_line): # if not a blank line... |
2033 return (previous_line, previous_line_number) | 1811 return (previous_line, previous_line_number) |
2034 previous_line_number -= 1 | 1812 previous_line_number -= 1 |
2035 return ('', -1) | 1813 return ('', -1) |
2036 | 1814 |
2037 | 1815 |
2038 def check_namespace_indentation(clean_lines, line_number, file_extension, file_s tate, error): | |
2039 """Looks for indentation errors inside of namespaces. | |
2040 | |
2041 Args: | |
2042 clean_lines: A CleansedLines instance containing the file. | |
2043 line_number: The number of the line to check. | |
2044 file_extension: The extension (dot not included) of the file. | |
2045 file_state: A _FileState instance which maintains information about | |
2046 the state of things in the file. | |
2047 error: The function to call with any errors found. | |
2048 """ | |
2049 | |
2050 line = clean_lines.elided[line_number] # Get rid of comments and strings. | |
2051 | |
2052 namespace_match = match(r'(?P<namespace_indentation>\s*)namespace\s+\S+\s*{\ s*$', line) | |
2053 if not namespace_match: | |
2054 return | |
2055 | |
2056 current_indentation_level = len(namespace_match.group('namespace_indentation ')) | |
2057 if current_indentation_level > 0: | |
2058 # Don't warn about an indented namespace if we already warned about inde nted code. | |
2059 if not file_state.did_inside_namespace_indent_warning(): | |
2060 error(line_number, 'whitespace/indent', 4, | |
2061 'namespace should never be indented.') | |
2062 return | |
2063 looking_for_semicolon = False | |
2064 line_offset = 0 | |
2065 in_preprocessor_directive = False | |
2066 for current_line in clean_lines.elided[line_number + 1:]: | |
2067 line_offset += 1 | |
2068 if not current_line.strip(): | |
2069 continue | |
2070 if not current_indentation_level: | |
2071 if in_preprocessor_directive or (current_line.strip()[0] == '#'): # This takes care of preprocessor directive syntax. | |
2072 in_preprocessor_directive = current_line[-1] == '\\' | |
2073 else: | |
2074 looking_for_semicolon = ((';' not in current_line) and (current_ line.strip() | |
2075 [-1] != '}')) or (current_line[-1] == '\\') | |
2076 else: | |
2077 looking_for_semicolon = False # If we have a brace we may not need a semicolon. | |
2078 current_indentation_level += current_line.count('{') - current_line.coun t('}') | |
2079 if current_indentation_level < 0: | |
2080 break | |
2081 | |
2082 | |
2083 def check_enum_casing(clean_lines, line_number, enum_state, error): | 1816 def check_enum_casing(clean_lines, line_number, enum_state, error): |
2084 """Looks for incorrectly named enum values. | 1817 """Looks for incorrectly named enum values. |
2085 | 1818 |
2086 Args: | 1819 Args: |
2087 clean_lines: A CleansedLines instance containing the file. | 1820 clean_lines: A CleansedLines instance containing the file. |
2088 line_number: The number of the line to check. | 1821 line_number: The number of the line to check. |
2089 enum_state: A _EnumState instance which maintains enum declaration state. | 1822 enum_state: A _EnumState instance which maintains enum declaration state. |
2090 error: The function to call with any errors found. | 1823 error: The function to call with any errors found. |
2091 """ | 1824 """ |
2092 | 1825 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2687 the current stack of nested class declarations being parsed. | 2420 the current stack of nested class declarations being parsed. |
2688 file_state: A _FileState instance which maintains information about | 2421 file_state: A _FileState instance which maintains information about |
2689 the state of things in the file. | 2422 the state of things in the file. |
2690 enum_state: A _EnumState instance which maintains the current enum state. | 2423 enum_state: A _EnumState instance which maintains the current enum state. |
2691 error: The function to call with any errors found. | 2424 error: The function to call with any errors found. |
2692 """ | 2425 """ |
2693 | 2426 |
2694 raw_lines = clean_lines.raw_lines | 2427 raw_lines = clean_lines.raw_lines |
2695 line = raw_lines[line_number] | 2428 line = raw_lines[line_number] |
2696 | 2429 |
2697 if '\t' in line: | |
2698 error(line_number, 'whitespace/tab', 1, | |
2699 'Tab found; better to use spaces') | |
2700 | |
2701 cleansed_line = clean_lines.elided[line_number] | |
2702 if line and line[-1].isspace(): | |
2703 error(line_number, 'whitespace/end_of_line', 4, | |
2704 'Line ends in whitespace. Consider deleting these extra spaces.') | |
2705 | |
2706 # Some more style checks | 2430 # Some more style checks |
2707 check_namespace_indentation(clean_lines, line_number, file_extension, file_s tate, error) | |
2708 check_using_std(clean_lines, line_number, file_state, error) | 2431 check_using_std(clean_lines, line_number, file_state, error) |
2709 check_max_min_macros(clean_lines, line_number, file_state, error) | 2432 check_max_min_macros(clean_lines, line_number, file_state, error) |
2710 check_ctype_functions(clean_lines, line_number, file_state, error) | 2433 check_ctype_functions(clean_lines, line_number, file_state, error) |
2711 check_braces(clean_lines, line_number, error) | 2434 check_braces(clean_lines, line_number, error) |
2712 check_exit_statement_simplifications(clean_lines, line_number, error) | 2435 check_exit_statement_simplifications(clean_lines, line_number, error) |
2713 check_spacing(file_extension, clean_lines, line_number, error) | 2436 check_spacing(file_extension, clean_lines, line_number, error) |
2714 check_check(clean_lines, line_number, error) | 2437 check_check(clean_lines, line_number, error) |
2715 check_deprecated_macros(clean_lines, line_number, error) | 2438 check_deprecated_macros(clean_lines, line_number, error) |
2716 check_for_comparisons_to_boolean(clean_lines, line_number, error) | 2439 check_for_comparisons_to_boolean(clean_lines, line_number, error) |
2717 check_for_null(clean_lines, line_number, file_state, error) | 2440 check_for_null(clean_lines, line_number, file_state, error) |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3833 'legal/copyright', | 3556 'legal/copyright', |
3834 'readability/braces', | 3557 'readability/braces', |
3835 'readability/casting', | 3558 'readability/casting', |
3836 'readability/check', | 3559 'readability/check', |
3837 'readability/comparison_to_boolean', | 3560 'readability/comparison_to_boolean', |
3838 'readability/constructors', | 3561 'readability/constructors', |
3839 'readability/control_flow', | 3562 'readability/control_flow', |
3840 'readability/enum_casing', | 3563 'readability/enum_casing', |
3841 'readability/fn_size', | 3564 'readability/fn_size', |
3842 'readability/function', | 3565 'readability/function', |
3566 # TODO(dcheng): Turn on the clang plugin checks and remove this. | |
3843 'readability/inheritance', | 3567 'readability/inheritance', |
3844 'readability/multiline_comment', | 3568 'readability/multiline_comment', |
3845 'readability/multiline_string', | 3569 'readability/multiline_string', |
3846 'readability/parameter_name', | 3570 'readability/parameter_name', |
3847 'readability/naming', | 3571 'readability/naming', |
3848 'readability/naming/underscores', | 3572 'readability/naming/underscores', |
3849 'readability/null', | 3573 'readability/null', |
3850 'readability/pass_ptr', | 3574 'readability/pass_ptr', |
3851 'readability/streams', | 3575 'readability/streams', |
3852 'readability/templatebrackets', | 3576 'readability/templatebrackets', |
(...skipping 13 matching lines...) Expand all Loading... | |
3866 'runtime/memset', | 3590 'runtime/memset', |
3867 'runtime/printf', | 3591 'runtime/printf', |
3868 'runtime/printf_format', | 3592 'runtime/printf_format', |
3869 'runtime/references', | 3593 'runtime/references', |
3870 'runtime/rtti', | 3594 'runtime/rtti', |
3871 'runtime/sizeof', | 3595 'runtime/sizeof', |
3872 'runtime/string', | 3596 'runtime/string', |
3873 'runtime/threadsafe_fn', | 3597 'runtime/threadsafe_fn', |
3874 'runtime/unsigned', | 3598 'runtime/unsigned', |
3875 'runtime/virtual', | 3599 'runtime/virtual', |
3876 'whitespace/blank_line', | |
3877 'whitespace/braces', | 3600 'whitespace/braces', |
3878 'whitespace/comma', | |
3879 'whitespace/declaration', | |
3880 'whitespace/end_of_line', | |
3881 'whitespace/ending_newline', | 3601 'whitespace/ending_newline', |
3882 'whitespace/indent', | |
3883 'whitespace/line_length', | |
3884 'whitespace/operators', | |
3885 'whitespace/parens', | |
3886 'whitespace/semicolon', | 3602 'whitespace/semicolon', |
3887 'whitespace/tab', | |
3888 'whitespace/todo', | |
3889 ]) | 3603 ]) |
3890 | 3604 |
3891 fs = None | 3605 fs = None |
3892 | 3606 |
3893 def __init__(self, file_path, file_extension, handle_style_error, | 3607 def __init__(self, file_path, file_extension, handle_style_error, |
3894 min_confidence, fs=None): | 3608 min_confidence, fs=None): |
3895 """Create a CppChecker instance. | 3609 """Create a CppChecker instance. |
3896 | 3610 |
3897 Args: | 3611 Args: |
3898 file_extension: A string that is the file extension, without | 3612 file_extension: A string that is the file extension, without |
(...skipping 26 matching lines...) Expand all Loading... | |
3925 | 3639 |
3926 def check(self, lines): | 3640 def check(self, lines): |
3927 _process_lines(self.file_path, self.file_extension, lines, | 3641 _process_lines(self.file_path, self.file_extension, lines, |
3928 self.handle_style_error, self.min_confidence) | 3642 self.handle_style_error, self.min_confidence) |
3929 | 3643 |
3930 | 3644 |
3931 # FIXME: Remove this function (requires refactoring unit tests). | 3645 # FIXME: Remove this function (requires refactoring unit tests). |
3932 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): | 3646 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): |
3933 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 3647 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
3934 checker.check(lines) | 3648 checker.check(lines) |
OLD | NEW |