parameters: (filename, clean_lines, linenum,
                              function_state, error)
docstring: Reports for long function bodies.
  
    For an overview why this is done, see:
    http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions
  
    Uses a simplistic algorithm assuming other style guidelines
    (especially spacing) are followed.
    Only checks unindented functions, so class members are unchecked.
    Trivial bodies are unchecked, so constructors with huge initializer lists
    may be missed.
    Blank/comment lines are not counted so as to avoid encouraging the removal
    of vertical space and comments just to get through a lint check.
    NOLINT *on the last line of a function* disables this check.
  
    Args:
      filename: The name of the current file.
      clean_lines: A CleansedLines instance containing the file.
      linenum: The number of the line to check.
      function_state: Current function name and lines in body so far.
      error: The function to call with any errors found.
docstring_summary: Reports for long function bodies.
docstring_tokens: Reports for long function bodies .
function: def CheckForFunctionLengths(filename, clean_lines, linenum,
                              function_state, error):
    """Reports for long function bodies.
  
    For an overview why this is done, see:
    http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions
  
    Uses a simplistic algorithm assuming other style guidelines
    (especially spacing) are followed.
    Only checks unindented functions, so class members are unchecked.
    Trivial bodies are unchecked, so constructors with huge initializer lists
    may be missed.
    Blank/comment lines are not counted so as to avoid encouraging the removal
    of vertical space and comments just to get through a lint check.
    NOLINT *on the last line of a function* disables this check.
  
    Args:
      filename: The name of the current file.
      clean_lines: A CleansedLines instance containing the file.
      linenum: The number of the line to check.
      function_state: Current function name and lines in body so far.
      error: The function to call with any errors found.
    """
    lines = clean_lines.lines
    line = lines[linenum]
    raw = clean_lines.raw_lines
    raw_line = raw[linenum]
    joined_line = ''
  
    starting_func = False
    regexp = r'(\w(\w|::|\*|\&|\s)*)\('  # decls * & space::name( ...
    match_result = Match(regexp, line)
    if match_result:
      # If the name is all caps and underscores, figure it's a macro and
      # ignore it, unless it's TEST or TEST_F.
      function_name = match_result.group(1).split()[-1]
      if function_name == 'TEST' or function_name == 'TEST_F' or (
          not Match(r'[A-Z_]+$', function_name)):
        starting_func = True
  
    if starting_func:
      body_found = False
      for start_linenum in xrange(linenum, clean_lines.NumLines()):
        start_line = lines[start_linenum]
        joined_line += ' ' + start_line.lstrip()
        if Search(r'(;|})', start_line):  # Declarations and trivial functions
          body_found = True
          break                              # ... ignore
        elif Search(r'{', start_line):
          body_found = True
          function = Search(r'((\w|:)*)\(', line).group(1)
          if Match(r'TEST', function):    # Handle TEST... macros
            parameter_regexp = Search(r'(\(.*\))', joined_line)
            if parameter_regexp:             # Ignore bad syntax
              function += parameter_regexp.group(1)
          else:
            function += '()'
          function_state.Begin(function)
          break
      if not body_found:
        # No body for the function (or evidence of a non-function) was found.
        error(filename, linenum, 'readability/fn_size', 5,
              'Lint failed to find start of function body.')
    elif Match(r'^\}\s*$', line):  # function end
      function_state.Check(error, filename, linenum)
      function_state.End()
    elif not Match(r'^\s*$', line):
      function_state.Count()
function_tokens: def CheckForFunctionLengths ( filename , clean_lines , linenum , function_state , error ) : lines = clean_lines . lines line = lines [ linenum ] raw = clean_lines . raw_lines raw_line = raw [ linenum ] joined_line = '' starting_func = False regexp = r'(\w(\w|::|\*|\&|\s)*)\(' # decls * & space::name( ... match_result = Match ( regexp , line ) if match_result : # If the name is all caps and underscores, figure it's a macro and # ignore it, unless it's TEST or TEST_F. function_name = match_result . group ( 1 ) . split ( ) [ - 1 ] if function_name == 'TEST' or function_name == 'TEST_F' or ( not Match ( r'[A-Z_]+$' , function_name ) ) : starting_func = True if starting_func : body_found = False for start_linenum in xrange ( linenum , clean_lines . NumLines ( ) ) : start_line = lines [ start_linenum ] joined_line += ' ' + start_line . lstrip ( ) if Search ( r'(;|})' , start_line ) : # Declarations and trivial functions body_found = True break # ... ignore elif Search ( r'{' , start_line ) : body_found = True function = Search ( r'((\w|:)*)\(' , line ) . group ( 1 ) if Match ( r'TEST' , function ) : # Handle TEST... macros parameter_regexp = Search ( r'(\(.*\))' , joined_line ) if parameter_regexp : # Ignore bad syntax function += parameter_regexp . group ( 1 ) else : function += '()' function_state . Begin ( function ) break if not body_found : # No body for the function (or evidence of a non-function) was found. error ( filename , linenum , 'readability/fn_size' , 5 , 'Lint failed to find start of function body.' ) elif Match ( r'^\}\s*$' , line ) : # function end function_state . Check ( error , filename , linenum ) function_state . End ( ) elif not Match ( r'^\s*$' , line ) : function_state . Count ( )