Showing 611 of 611 total issues
Function process_symlink
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def process_symlink(self, *, path, parent_fd, name, st, strip_prefix):
Function valid_msgpacked_dict
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def valid_msgpacked_dict(d, keys_serialized):
"""check if the data <d> looks like a msgpacked dict"""
d_len = len(d)
if d_len == 0:
return False
- 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
Avoid deeply nested control flow statements. Open
Open
if pi:
pi.show(increase=len(data), info=[remove_surrogates(item.path)])
with backup_io("write"):
Avoid deeply nested control flow statements. Open
Open
with backup_io("write"):
if sparse and zeros.startswith(data):
# all-zero chunk: create a hole in a sparse file
fd.seek(len(data), 1)
else:
Avoid deeply nested control flow statements. Open
Open
if not is_special_file and not changed_while_backup:
# we must not memorize special files, because the contents of e.g. a
# block or char device will change without its mtime/size/inode changing.
# also, we must not memorize a potentially inconsistent/corrupt file that
# changed while we backed it up.
Avoid deeply nested control flow statements. Open
Open
if msgid in self.ignore_responses:
self.ignore_responses.remove(msgid)
# async methods never return values, but may raise exceptions.
if "exception_class" in unpacked:
self.async_responses[msgid] = unpacked
Avoid deeply nested control flow statements. Open
Open
with backup_io("read"):
self.process_file_chunks(
item,
cache,
self.stats,
Avoid deeply nested control flow statements. Open
Open
if not self.shadow_index[key]:
# shadowed segments list is empty -> remove it
del self.shadow_index[key]
assert segments[segment] == 0, "Corrupted segment reference count - corrupted index or hints"
Avoid deeply nested control flow statements. Open
Open
if tag == TAG_PUT2:
c_offset = self.HEADER_ID_SIZE + self.ENTRY_HASH_SIZE
# skip if header is invalid
if crc32(d[4:c_offset]) & 0xFFFFFFFF != crc:
d = d[1:]
Avoid deeply nested control flow statements. Open
Open
for archive_info in manifest.archives.list(sort_by=["ts"]):
msg.append(format_archive(archive_info))
else:
Function cache_if_remote
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def cache_if_remote(repository, *, decrypted_cache=False, pack=None, unpack=None, transform=None, force_cache=False):
"""
Return a Repository(No)Cache for *repository*.
If *decrypted_cache* is a repo_objs object, then get and get_many will return a tuple
- 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 process_dir
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def process_dir(self, *, path, parent_fd, name, st, strip_prefix):
Avoid deeply nested control flow statements. Open
Open
if "size" in item:
item_size = item.size
if item_size != item_chunks_size:
raise BackupError(
"Size inconsistency detected: size {}, chunks size {}".format(
Avoid deeply nested control flow statements. Open
Open
if changed_while_backup:
# regular file changed while we backed it up, might be inconsistent/corrupt!
if last_try:
status = "C" # crap! retries did not help.
else:
Function call_many
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def call_many(self, cmd, calls, wait=True, is_preloaded=False, async_wait=True):
Avoid deeply nested control flow statements. Open
Open
for data in self.pipeline.fetch_many(
[c.id for c in item.chunks], is_preloaded=True, ro_type=ROBJ_FILE_STREAM
):
if pi:
pi.show(increase=len(data), info=[remove_surrogates(item.path)])
Avoid deeply nested control flow statements. Open
Open
if stdout:
sys.stdout.buffer.flush()
if "size" in item:
Avoid deeply nested control flow statements. Open
Open
for chunk in chunks:
if not cache.seen_chunk(chunk.id):
# cache said it is unmodified, but we lost a chunk: process file like modified
status = "M"
break
Avoid deeply nested control flow statements. Open
Open
if not is_win32: # TODO for win32
with backup_io("fstat2"):
st2 = os.fstat(fd)
if is_special_file:
# special files:
Function process_fifo
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def process_fifo(self, *, path, parent_fd, name, st, strip_prefix):