parameters: (filename, file_contents, clean_file_contents, file_lines, clean_file_lines)
docstring: Checks that there is no unnecessary code on same line with curly braces.
docstring_summary: Checks that there is no unnecessary code on same line with curly braces.
docstring_tokens: Checks that there is no unnecessary code on same line with curly braces .
function: def check_curly_braces_alone_on_line(filename, file_contents, clean_file_contents, file_lines, clean_file_lines):
      """
      Checks that there is no unnecessary code on same line with curly braces.
      """
  
      # if: not at end
      re_if = re.compile(r'\W+if\s*\(.*\)\s*(?:\{|.*\}|.*;)$')
  
      # else: neither before nor after
      re_else = re.compile(r'}\s*else|else\s*{')
  
      # switch: not at end
      re_switch = re.compile(r'\W+switch\s*\(.*\)\s*(?:\{|.*\}|.*;)$')
  
      # while: before ok, not after
      re_while = re.compile(r'\W+while\s*\(.*\)\s*{')
  
      # for: not at end
      re_for = re.compile(r'\W+for\s*\(.*\)\s*(?:\{|.*\}|.*\)\s*;)$')
  
      # NOTE(tobias) not checking function definitions because too many false positives with lambdas, enums ...
  
      for i in range(len(clean_file_lines)):
          line = clean_file_lines[i]
  
          if re_if.search(line):
              common.log_warning("check_curly_braces_alone_on_line", filename, i + 1,
                                 "curly brace or statement on same line with if", file_lines[i].strip(" "))
          elif re_else.search(line):
              common.log_warning("check_curly_braces_alone_on_line", filename, i + 1,
                                 "curly brace on same line with else", file_lines[i].strip(" "))
          elif re_switch.search(line):
              common.log_warning("check_curly_braces_alone_on_line", filename, i + 1,
                                 "curly brace or statement on same line with switch", file_lines[i].strip(" "))
          elif re_while.search(line):
              common.log_warning("check_curly_braces_alone_on_line", filename, i + 1,
                                 "curly brace after while", file_lines[i].strip(" "))
          elif re_for.search(line):
              common.log_warning("check_curly_braces_alone_on_line", filename, i + 1,
                                 "curly brace or statement on same line with for", file_lines[i].strip(" "))
function_tokens: def check_curly_braces_alone_on_line ( filename , file_contents , clean_file_contents , file_lines , clean_file_lines ) : # if: not at end re_if = re . compile ( r'\W+if\s*\(.*\)\s*(?:\{|.*\}|.*;)$' ) # else: neither before nor after re_else = re . compile ( r'}\s*else|else\s*{' ) # switch: not at end re_switch = re . compile ( r'\W+switch\s*\(.*\)\s*(?:\{|.*\}|.*;)$' ) # while: before ok, not after re_while = re . compile ( r'\W+while\s*\(.*\)\s*{' ) # for: not at end re_for = re . compile ( r'\W+for\s*\(.*\)\s*(?:\{|.*\}|.*\)\s*;)$' ) # NOTE(tobias) not checking function definitions because too many false positives with lambdas, enums ... for i in range ( len ( clean_file_lines ) ) : line = clean_file_lines [ i ] if re_if . search ( line ) : common . log_warning ( "check_curly_braces_alone_on_line" , filename , i + 1 , "curly brace or statement on same line with if" , file_lines [ i ] . strip ( " " ) ) elif re_else . search ( line ) : common . log_warning ( "check_curly_braces_alone_on_line" , filename , i + 1 , "curly brace on same line with else" , file_lines [ i ] . strip ( " " ) ) elif re_switch . search ( line ) : common . log_warning ( "check_curly_braces_alone_on_line" , filename , i + 1 , "curly brace or statement on same line with switch" , file_lines [ i ] . strip ( " " ) ) elif re_while . search ( line ) : common . log_warning ( "check_curly_braces_alone_on_line" , filename , i + 1 , "curly brace after while" , file_lines [ i ] . strip ( " " ) ) elif re_for . search ( line ) : common . log_warning ( "check_curly_braces_alone_on_line" , filename , i + 1 , "curly brace or statement on same line with for" , file_lines [ i ] . strip ( " " ) )