parameters: (build_folder, filename_to_check, auto_fix,
                             line_ranges=[])
docstring: Run clang-tidy on a single file.
docstring_summary: Run clang-tidy on a single file.
docstring_tokens: Run clang - tidy on a single file .
function: def ClangTidyRunSingleFile(build_folder, filename_to_check, auto_fix,
                             line_ranges=[]):
    """
    Run clang-tidy on a single file.
    """
    files_with_relative_path = []
  
    compdb_filepath = os.path.join(build_folder, 'compile_commands.json')
    with open(compdb_filepath) as raw_json_file:
      compdb = json.load(raw_json_file)
  
    for db_entry in compdb:
      if db_entry['file'].endswith(filename_to_check):
        files_with_relative_path.append(db_entry['file'])
  
    with open(os.devnull, 'w') as DEVNULL:
      for file_with_relative_path in files_with_relative_path:
        line_filter = None
        if len(line_ranges) != 0:
          line_filter = '['
          line_filter += '{ \"lines\":[' + ', '.join(line_ranges)
          line_filter += '], \"name\":\"'
          line_filter += rm_prefix(file_with_relative_path,
                                   '../') + '\"}'
          line_filter += ']'
  
        extra_args = ['-line-filter=' + line_filter] if line_filter else []
  
        if auto_fix:
          extra_args.append('-fix')
  
        subprocess.call(['clang-tidy', '-p', '.'] +
                        extra_args +
                        [file_with_relative_path],
                        cwd=build_folder,
                        stderr=DEVNULL)
function_tokens: def ClangTidyRunSingleFile ( build_folder , filename_to_check , auto_fix , line_ranges = [ ] ) : files_with_relative_path = [ ] compdb_filepath = os . path . join ( build_folder , 'compile_commands.json' ) with open ( compdb_filepath ) as raw_json_file : compdb = json . load ( raw_json_file ) for db_entry in compdb : if db_entry [ 'file' ] . endswith ( filename_to_check ) : files_with_relative_path . append ( db_entry [ 'file' ] ) with open ( os . devnull , 'w' ) as DEVNULL : for file_with_relative_path in files_with_relative_path : line_filter = None if len ( line_ranges ) != 0 : line_filter = '[' line_filter += '{ \"lines\":[' + ', ' . join ( line_ranges ) line_filter += '], \"name\":\"' line_filter += rm_prefix ( file_with_relative_path , '../' ) + '\"}' line_filter += ']' extra_args = [ '-line-filter=' + line_filter ] if line_filter else [ ] if auto_fix : extra_args . append ( '-fix' ) subprocess . call ( [ 'clang-tidy' , '-p' , '.' ] + extra_args + [ file_with_relative_path ] , cwd = build_folder , stderr = DEVNULL )