MCPcopy Index your code
hub / github.com/tensorflow/tfjs / ProcessFile

Function ProcessFile

tfjs-backend-wasm/tools/cpplint.py:6031–6120  ·  view source on GitHub ↗

Does google-lint on a single file. Args: filename: The name of the file to parse. vlevel: The level of errors to report. Every error of confidence >= verbose_level will be reported. 0 is a good default. extra_check_functions: An array of additional check functions that will be

(filename, vlevel, extra_check_functions=[])

Source from the content-addressed store, hash-verified

6029
6030
6031def ProcessFile(filename, vlevel, extra_check_functions=[]):
6032 """Does google-lint on a single file.
6033
6034 Args:
6035 filename: The name of the file to parse.
6036
6037 vlevel: The level of errors to report. Every error of confidence
6038 >= verbose_level will be reported. 0 is a good default.
6039
6040 extra_check_functions: An array of additional check functions that will be
6041 run on each source line. Each function takes 4
6042 arguments: filename, clean_lines, line, error
6043 """
6044
6045 _SetVerboseLevel(vlevel)
6046 _BackupFilters()
6047 old_errors = _cpplint_state.error_count
6048
6049 if not ProcessConfigOverrides(filename):
6050 _RestoreFilters()
6051 return
6052
6053 lf_lines = []
6054 crlf_lines = []
6055 try:
6056 # Support the UNIX convention of using "-" for stdin. Note that
6057 # we are not opening the file with universal newline support
6058 # (which codecs doesn't support anyway), so the resulting lines do
6059 # contain trailing '\r' characters if we are reading a file that
6060 # has CRLF endings.
6061 # If after the split a trailing '\r' is present, it is removed
6062 # below.
6063 if filename == '-':
6064 lines = codecs.StreamReaderWriter(sys.stdin,
6065 codecs.getreader('utf8'),
6066 codecs.getwriter('utf8'),
6067 'replace').read().split('\n')
6068 else:
6069 lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n')
6070
6071 # Remove trailing '\r'.
6072 # The -1 accounts for the extra trailing blank line we get from split()
6073 for linenum in range(len(lines) - 1):
6074 if lines[linenum].endswith('\r'):
6075 lines[linenum] = lines[linenum].rstrip('\r')
6076 crlf_lines.append(linenum + 1)
6077 else:
6078 lf_lines.append(linenum + 1)
6079
6080 except IOError:
6081 sys.stderr.write(
6082 "Skipping input '%s': Can't open for reading\n" % filename)
6083 _RestoreFilters()
6084 return
6085
6086 # Note, if no dot is found, this will give the entire filename as the ext.
6087 file_extension = filename[filename.rfind('.') + 1:]
6088

Callers 1

mainFunction · 0.85

Calls 13

_SetVerboseLevelFunction · 0.85
_BackupFiltersFunction · 0.85
ProcessConfigOverridesFunction · 0.85
_RestoreFiltersFunction · 0.85
ProcessFileDataFunction · 0.85
ErrorFunction · 0.85
appendMethod · 0.80
joinMethod · 0.80
splitMethod · 0.65
readMethod · 0.65
writeMethod · 0.65
rangeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…