def check(self, patch_string): """Check style in the given patch.""" patch_files = parse_patch(patch_string) # The diff variable is a DiffFile instance. for path, diff in patch_files.iteritems(): line_numbers = set() for line in diff.lines: # When deleted line is not set, it means that # the line is newly added (or modified). if not line[0]: line_numbers.add(line[1]) _log.debug('Found %s new or modified lines in: %s' % (len(line_numbers), path)) self._file_checker.check_file(file_path=path, line_numbers=line_numbers)
def check(self, patch_string): """Check style in the given patch.""" patch_files = parse_patch(patch_string) # The diff variable is a DiffFile instance. for path, diff in patch_files.iteritems(): line_numbers = set() for line in diff.lines: # When deleted line is not set, it means that # the line is newly added (or modified). if not line[0]: line_numbers.add(line[1]) _log.debug('Found %s new or modified lines in: %s' % (len(line_numbers), path)) # If line_numbers is empty, the file has no new or # modified lines. In this case, we don't check the file # because we'll never output errors for the file. # This optimization also prevents the program from exiting # due to a deleted file. if line_numbers: self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers)