def check(self, patch_string, fs=None): """Check style in the given patch.""" fs = fs or FileSystem() patch_files = DiffParser(patch_string.splitlines()).files # If the user uses git, checking subversion config file only once is enough. call_only_once = True for path, diff_file in patch_files.iteritems(): line_numbers = diff_file.added_or_modified_line_numbers() _log.debug('Found %s new or modified lines in: %s' % (len(line_numbers), path)) if not line_numbers: match = re.search("\s*png$", path) if match and fs.exists(path): if call_only_once: self._text_file_reader.process_file(file_path=path, line_numbers=None) cwd = FileSystem().getcwd() detection = SCMDetector(fs, Executive()).detect_scm_system(cwd) if detection.display_name() == "git": call_only_once = False continue # Don't check files which contain only deleted lines # as they can never add style errors. However, mark them as # processed so that we count up number of such files. self._text_file_reader.count_delete_only_file() continue self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers)
def check(self, patch_string, fs=None): """Check style in the given patch.""" fs = fs or FileSystem() patch_files = DiffParser(patch_string.splitlines()).files # If the user uses git, checking subversion config file only once is enough. call_only_once = True for path, diff_file in patch_files.iteritems(): line_numbers = diff_file.added_or_modified_line_numbers() _log.debug('Found %s new or modified lines in: %s' % (len(line_numbers), path)) if not line_numbers: match = re.search("\s*png$", path) if match and fs.exists(path): if call_only_once: self._text_file_reader.process_file(file_path=path, line_numbers=None) cwd = FileSystem().getcwd() detection = SCMDetector( fs, Executive()).detect_scm_system(cwd) if detection.display_name() == "git": call_only_once = False continue # Don't check files which contain only deleted lines # as they can never add style errors. However, mark them as # processed so that we count up number of such files. self._text_file_reader.delete_file(path) continue self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers) self._text_file_reader.do_association_check(fs.getcwd())
def check(self, patch_string): """Check style in the given patch.""" patch_files = DiffParser(patch_string.splitlines()).files # 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) else: # We don't check the file which contains deleted lines only # but would like to treat it as to be processed so that # we count up number of such files. self._text_file_reader.count_delete_only_file()
def check(self, patch_string, fs=None): """Check style in the given patch.""" fs = fs or FileSystem() patch_files = DiffParser(patch_string.splitlines()).files # If the user uses git, checking subversion config file only once is enough. # TODO(qyearsley): Simplify this since git is now the only supported SCM system. call_only_once = True for path, diff_file in patch_files.iteritems(): line_numbers = diff_file.added_or_modified_line_numbers() _log.debug('Found %s new or modified lines in: %s', len(line_numbers), path) if not line_numbers: match = re.search(r"\s*png$", path) if match and fs.exists(path): if call_only_once: self._text_file_reader.process_file(file_path=path, line_numbers=None) call_only_once = False continue # Don't check files which contain only deleted lines # as they can never add style errors. However, mark them as # processed so that we count up number of such files. self._text_file_reader.count_delete_only_file() continue self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers)
def check(self, patch_string): """Check style in the given patch.""" patch_files = DiffParser(patch_string.splitlines()).files # 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) else: # We don't check the file which contains deleted lines only # but would like to treat it as to be processed so that # we count up number of such files. self._text_file_reader.count_delete_only_file()
def check(self, patch_string): """Check style in the given patch.""" patch_files = DiffParser(patch_string.splitlines()).files for path, diff_file in patch_files.iteritems(): line_numbers = diff_file.added_or_modified_line_numbers() _log.debug('Found %s new or modified lines in: %s' % (len(line_numbers), path)) if not line_numbers: # Don't check files which contain only deleted lines # as they can never add style errors. However, mark them as # processed so that we count up number of such files. self._text_file_reader.count_delete_only_file() continue self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers)
def find_matching_definitions(self, diff): matching_definitions = set() patch_files = DiffParser(diff.splitlines()).files for path, diff_file in patch_files.iteritems(): for definition in self.definitions: # If a definition has already matched, there is no need to process it. if definition in matching_definitions: continue # See if the definition matches within one file. for pattern in self.definitions[definition]: if not pattern.match(path, diff_file.lines): break else: matching_definitions.add(definition) return matching_definitions
def find_matching_definitions(self, diff): matching_definitions = set() patch_files = DiffParser(diff.splitlines()).files for path, diff_file in patch_files.iteritems(): for definition in self.definitions: # If a definition has already matched, there is no need to process it. if definition in matching_definitions: continue # See if the definition matches within one file. for pattern in self.definitions[definition]: if not pattern.match(path, diff_file.lines): break else: matching_definitions.add(definition) return matching_definitions
def check(self, patch_string): """Check style in the given patch.""" patch_files = DiffParser(patch_string.splitlines()).files for path, diff_file in patch_files.iteritems(): line_numbers = diff_file.added_or_modified_line_numbers() _log.debug('Found %s new or modified lines in: %s' % (len(line_numbers), path)) if not line_numbers: # Don't check files which contain only deleted lines # as they can never add style errors. However, mark them as # processed so that we count up number of such files. self._text_file_reader.count_delete_only_file() continue self._text_file_reader.process_file(file_path=path, line_numbers=line_numbers)