parameters: (file_line_mapping, **extra)
return_statement: return '\n\n'.join(result), error_count, fatal
docstring: Checks changed files for contents and alalyzes them.
  
      :param file_line_mapping: Mapping of files with changed lines (obtained
          `get_git_line_sets()`).
      :param extra: Optional keyword arguments (none available).
      :return: A tuple containing the formatted string suitable for output and
          an integer containing the number of failed rules.
docstring_summary: Checks changed files for contents and alalyzes them.
docstring_tokens: Checks changed files for contents and alalyzes them .
function: def reduce_validator(file_line_mapping, **extra):
      """
      Checks changed files for contents and alalyzes them.
  
      :param file_line_mapping: Mapping of files with changed lines (obtained
          `get_git_line_sets()`).
      :param extra: Optional keyword arguments (none available).
      :return: A tuple containing the formatted string suitable for output and
          an integer containing the number of failed rules.
      """
  
      exclude = ['vendor', 'asm', 'sjcl', 'dont-deploy', 'secureboot', 'test']
      special_chars_exclude = ['secureboot', 'test', 'emoji', 'dont-deploy', 'pdf.worker', 'images' + os.path.sep]
      logging.info('Analyzing modified files ...')
      result = ['\nValidator output:\n=================']
      warning = 'This is a security product. Do not add unverifiable code to the repository!'
      fatal = 0
  
      # Analise changed lines per modified file
      for filename, line_set in file_line_mapping.items():
          file_path = os.path.join(*filename)
          file_extension = os.path.splitext(file_path)[-1]
  
          if not any([n in file_path for n in special_chars_exclude]):
              if analyse_files_for_special_chars(file_path, result):
                  fatal += 1
                  # break
          # Ignore known custom made files
          if file_path in config.VALIDATOR_IGNORE_FILES:
              continue
          if any([n in file_path for n in exclude]):
              if 'secureboot' in file_path and analyse_secureboot(file_path, result):
                  fatal += 1
              continue
  
          # Ignore this specific file types
          if file_extension in ['.json','.py','.sh', '.svg']:
              continue
  
          # If .min.js is in the filename (most basic detection), then log it and move onto the next file
          if '.min.js' in file_path:
              fatal += 1
              result.append('Minified/obfuscated code found in file {}. {}'
                            .format(file_path, warning))
              # continue
  
          if os.path.getsize(file_path) > 190000 and not file_extension in ['.css', '.html']:
              result.append('The file "{}" has turned too big, '
                            'any new functions must be moved elsewhere.'.format(file_path))
              # continue
  
          lines = []
          with open(file_path, 'r') as fd:
              # Check line lengths in file.
              line_number = 0
              for line in fd.readlines():
                  line_number += 1
                  if line_number not in line_set:
                      # Not a changed line.
                      continue
                  line_length = len(line)
  
                  # Analyse CSS files...
                  if file_extension == '.css':
                      fatal += inspectcss(file_path, line_number, line, result)
                      continue
  
                  # Analyse HTML files...
                  if file_extension == '.html':
                      fatal += inspecthtml(file_path, line_number, line, result)
                      continue
  
      # Add the number of errors and return in a nicely formatted way.
      error_count = len(result) - 1
      if error_count == 0:
          return '', 0
      result.append('\n{} issues found analysing modified files.'
                    .format(error_count))
      return '\n\n'.join(result), error_count, fatal
function_tokens: def reduce_validator ( file_line_mapping , * * extra ) : exclude = [ 'vendor' , 'asm' , 'sjcl' , 'dont-deploy' , 'secureboot' , 'test' ] special_chars_exclude = [ 'secureboot' , 'test' , 'emoji' , 'dont-deploy' , 'pdf.worker' , 'images' + os . path . sep ] logging . info ( 'Analyzing modified files ...' ) result = [ '\nValidator output:\n=================' ] warning = 'This is a security product. Do not add unverifiable code to the repository!' fatal = 0 # Analise changed lines per modified file for filename , line_set in file_line_mapping . items ( ) : file_path = os . path . join ( * filename ) file_extension = os . path . splitext ( file_path ) [ - 1 ] if not any ( [ n in file_path for n in special_chars_exclude ] ) : if analyse_files_for_special_chars ( file_path , result ) : fatal += 1 # break # Ignore known custom made files if file_path in config . VALIDATOR_IGNORE_FILES : continue if any ( [ n in file_path for n in exclude ] ) : if 'secureboot' in file_path and analyse_secureboot ( file_path , result ) : fatal += 1 continue # Ignore this specific file types if file_extension in [ '.json' , '.py' , '.sh' , '.svg' ] : continue # If .min.js is in the filename (most basic detection), then log it and move onto the next file if '.min.js' in file_path : fatal += 1 result . append ( 'Minified/obfuscated code found in file {}. {}' . format ( file_path , warning ) ) # continue if os . path . getsize ( file_path ) > 190000 and not file_extension in [ '.css' , '.html' ] : result . append ( 'The file "{}" has turned too big, ' 'any new functions must be moved elsewhere.' . format ( file_path ) ) # continue lines = [ ] with open ( file_path , 'r' ) as fd : # Check line lengths in file. line_number = 0 for line in fd . readlines ( ) : line_number += 1 if line_number not in line_set : # Not a changed line. continue line_length = len ( line ) # Analyse CSS files... if file_extension == '.css' : fatal += inspectcss ( file_path , line_number , line , result ) continue # Analyse HTML files... if file_extension == '.html' : fatal += inspecthtml ( file_path , line_number , line , result ) continue # Add the number of errors and return in a nicely formatted way. error_count = len ( result ) - 1 if error_count == 0 : return '' , 0 result . append ( '\n{} issues found analysing modified files.' . format ( error_count ) ) return '\n\n' . join ( result ) , error_count , fatal