MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / ProcessFile

Function ProcessFile

util/cpplint.py:5949–6034  ·  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

5947
5948
5949def ProcessFile(filename, vlevel, extra_check_functions=[]):
5950 """Does google-lint on a single file.
5951
5952 Args:
5953 filename: The name of the file to parse.
5954
5955 vlevel: The level of errors to report. Every error of confidence
5956 >= verbose_level will be reported. 0 is a good default.
5957
5958 extra_check_functions: An array of additional check functions that will be
5959 run on each source line. Each function takes 4
5960 arguments: filename, clean_lines, line, error
5961 """
5962
5963 _SetVerboseLevel(vlevel)
5964 _BackupFilters()
5965
5966 if not ProcessConfigOverrides(filename):
5967 _RestoreFilters()
5968 return
5969
5970 lf_lines = []
5971 crlf_lines = []
5972 try:
5973 # Support the UNIX convention of using "-" for stdin. Note that
5974 # we are not opening the file with universal newline support
5975 # (which codecs doesn't support anyway), so the resulting lines do
5976 # contain trailing '\r' characters if we are reading a file that
5977 # has CRLF endings.
5978 # If after the split a trailing '\r' is present, it is removed
5979 # below.
5980 if filename == '-':
5981 lines = codecs.StreamReaderWriter(sys.stdin,
5982 codecs.getreader('utf8'),
5983 codecs.getwriter('utf8'),
5984 'replace').read().split('\n')
5985 else:
5986 lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n')
5987
5988 # Remove trailing '\r'.
5989 # The -1 accounts for the extra trailing blank line we get from split()
5990 for linenum in range(len(lines) - 1):
5991 if lines[linenum].endswith('\r'):
5992 lines[linenum] = lines[linenum].rstrip('\r')
5993 crlf_lines.append(linenum + 1)
5994 else:
5995 lf_lines.append(linenum + 1)
5996
5997 except IOError:
5998 sys.stderr.write(
5999 "Skipping input '%s': Can't open for reading\n" % filename)
6000 _RestoreFilters()
6001 return
6002
6003 # Note, if no dot is found, this will give the entire filename as the ext.
6004 file_extension = filename[filename.rfind('.') + 1:]
6005
6006 # When reading from stdin, the extension is unknown, so no cpplint tests

Callers 1

mainFunction · 0.85

Calls 8

_SetVerboseLevelFunction · 0.85
_BackupFiltersFunction · 0.85
ProcessConfigOverridesFunction · 0.85
_RestoreFiltersFunction · 0.85
ProcessFileDataFunction · 0.85
ErrorFunction · 0.85
readMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected