def SpacesInsideBrackets( logical_line, tokens ):
  """Require spaces inside parentheses, square brackets, and braces for
  non-empty content."""
  for index in range( len( tokens ) ):
    _, prev_text, _, prev_end, _ = ( tokens[ index - 1 ] if index - 1 >= 0 else
                                     ( None, None, None, None, None ) )
    token_type, text, start, end, _ = tokens[ index ]
    next_token_type, next_text, next_start, _, _ = (
      tokens[ index + 1 ] if index + 1 < len( tokens ) else
      ( None, None, None, None, None ) )
    if text in LEFT_BRACKETS:
      if ( next_text == CORRESPONDING_BRACKET[ text ] and
           next_start != end ):
        code = 'YCM204'
        message = ( ' no spaces between {} and {}'
                    ' for empty content'.format( text, next_text ) )
        yield end, code + message
      if ( next_token_type not in [ tokenize.NL, tokenize.NEWLINE ] and
           next_text != CORRESPONDING_BRACKET[ text ] and
           next_start and
           next_start[ 0 ] == start[ 0 ] and
           next_start[ 1 ] - start[ 1 ] != 2 ):
        code = 'YCM201'
        message = ' exactly one space required after {}'.format( text )
        yield end, code + message
    if text in RIGHT_BRACKETS:
      if ( prev_text != CORRESPONDING_BRACKET[ text ] and
           prev_end and
           prev_end[ 0 ] == end[ 0 ] and
           end[ 1 ] - prev_end[ 1 ] != 2 ):
        code = 'YCM202'
        message = ' exactly one space required before {}'.format( text )
        yield start, code + message
Require spaces inside parentheses, square brackets, and braces for
  non-empty content.