File PyGIT.py
has 896 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2023 Edgewall Software
# Copyright (C) 2006-2011, Herbert Valerio Riedel <hvr@gnu.org>
# All rights reserved.
Storage
has 47 functions (exceeds 20 allowed). Consider refactoring. Open
class Storage(object):
"""High-level wrapper around GitCore with in-memory caching"""
__SREV_MIN = 4 # minimum short-rev length
Function get_historian
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def get_historian(self, sha, base_path):
p = []
change = {}
next_path = []
base_path = self._fs_from_unicode(base_path) or '.'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verifyrev
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def verifyrev(self, rev):
"""verify/lookup given revision object and return a sha id or None
if lookup failed
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, git_dir, log, git_bin='git', git_fs_encoding=None,
rev_cache=None):
"""Initialize PyGit.Storage instance
`git_dir`: path to .git folder;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
if youngest_rev is not None and oldest_rev is not None and \
rev_dict and refs_dict and srev_dict:
pass # all fields are not empty
elif not youngest_rev and not oldest_rev and \
not rev_dict and not refs_dict and not srev_dict:
Function parse_commit
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse_commit(raw):
"""Parse the raw content of a commit (as given by `git cat-file -p <rev>`).
Return the commit message and a dict of properties.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_changes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_changes(self, tree1, tree2):
with self.__diff_tree_pipe_lock:
if self.__diff_tree_pipe is None:
self.__diff_tree_pipe = self.repo.diff_tree_pipe()
proc = self.__diff_tree_pipe
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _build_rev_cache
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _build_rev_cache(self, refs):
self.logger.debug("triggered rebuild of commit tree db for '%s'",
self.repo_path)
ts0 = time_now()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __build_git_cmd
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __build_git_cmd(self, gitcmd, *args):
"""construct command tuple for git call suitable for Popen()"""
cmd = [self.__git_bin]
if self.__git_dir:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _cat_file_reader
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _cat_file_reader(self, kind, sha):
with self.__cat_file_pipe_lock:
if self.__cat_file_pipe is None:
self.__cat_file_pipe = self.repo.cat_file_batch()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function history_relative_rev
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def history_relative_rev(self, sha, rel_pos):
def get_history_relative_rev(sha, rel_pos):
rev_dict = self.get_commits()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function shortrev
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def shortrev(self, rev, min_len=7):
def get_shortrev(rev, min_len):
"""try to shorten sha id"""
#try to emulate the following:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function diff_tree
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def diff_tree(self, tree1, tree2, path='', find_renames=False):
"""calls `git diff-tree` and returns tuples of the kind
(mode1,mode2,obj1,obj2,action,path1,path2)"""
# diff-tree returns records with the following structure:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _get_refs
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _get_refs(self):
refs = {}
tags = {}
for line in self.repo.show_ref('--dereference').splitlines():
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fullrev
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def fullrev(self, rev):
"""try to reverse shortrev()"""
_rev_cache = self.rev_cache
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function blame
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def blame(self, commit_sha, path):
in_metadata = False
commit_sha = _rev_b(commit_sha)
path = self._fs_from_unicode(path)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, git_dir, log, git_bin='git', git_fs_encoding=None,
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, youngest_rev, oldest_rev, rev_dict, refs_dict,
Function diff_tree
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def diff_tree(self, tree1, tree2, path='', find_renames=False):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, repo, log, weak=True, git_bin='git',
Avoid too many return
statements within this function. Open
return resolved
Avoid too many return
statements within this function. Open
return None
Avoid too many return
statements within this function. Open
return rc
Avoid too many return
statements within this function. Open
return None
Function __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, repo, log, weak=True, git_bin='git',
git_fs_encoding=None):
self.logger = log
with self.__dict_lock:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _unquote
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _unquote(path):
if path.startswith(b'"') and path.endswith(b'"'):
def replace(match):
match = match.group(0)
if len(match) == 4:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _cleanup_proc
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _cleanup_proc(self, proc):
if proc:
for f in (proc.stdin, proc.stdout, proc.stderr):
if f:
f.close()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"