Showing 507 of 611 total issues
Avoid deeply nested control flow statements. 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
def call_many(self, cmd, calls, wait=True, is_preloaded=False, async_wait=True):
Avoid deeply nested control flow statements. 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
if stdout:
sys.stdout.buffer.flush()
if "size" in item:
Avoid deeply nested control flow statements. 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
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
def process_fifo(self, *, path, parent_fd, name, st, strip_prefix):
Avoid deeply nested control flow statements. Open
if not isinstance(unpacked, dict):
raise UnexpectedRPCDataFormatFromServer(data)
Function save
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def save(self, name=None, comment=None, timestamp=None, stats=None, additional_metadata=None):
Function extract_helper
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def extract_helper(self, item, path, hlm, *, dry_run=False):
Avoid deeply nested control flow statements. Open
if lr_dict is not None:
# Re-emit remote log messages locally.
_logger = logging.getLogger(lr_dict["name"])
if _logger.isEnabledFor(lr_dict["level"]):
_logger.handle(logging.LogRecord(**lr_dict))
Avoid deeply nested control flow statements. Open
if is_preloaded:
assert cmd == "get", "is_preload is only supported for 'get'"
if calls[0]["id"] in self.chunkid_to_msgids:
waiting_for.append(pop_preload_msgid(calls.pop(0)["id"]))
else:
Function save
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def save(self, name=None, comment=None, timestamp=None, stats=None, additional_metadata=None):
name = name or self.name
self.items_buffer.flush(flush=True)
item_ptrs = archive_put_items(
self.items_buffer.chunks, repo_objs=self.repo_objs, cache=self.cache, stats=self.stats
- 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
if size_invalid or tag > MAX_TAG_ID:
d = d[1:]
continue
if tag == TAG_PUT2:
Function do_benchmark_cpu
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def do_benchmark_cpu(self, args):
"""Benchmark CPU bound operations."""
from timeit import timeit
random_10M = os.urandom(10 * 1000 * 1000)
- 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 save
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def save(self, archive, target, comment=None, delete_original=True):
if self.dry_run:
return
if comment is None:
comment = archive.metadata.get("comment", "")
- 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 pack
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def pack(o, stream, *, use_bin_type=USE_BIN_TYPE, unicode_errors=UNICODE_ERRORS, **kwargs):
Function unpackb
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def unpackb(packed, *, raw=RAW, unicode_errors=UNICODE_ERRORS, strict_map_key=False, **kwargs):
Function archive_put_items
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def archive_put_items(chunk_ids, *, repo_objs, cache=None, stats=None, add_reference=None):
Function process
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process(input):
unpacker = RobustUnpacker(validator=_validator, item_keys=ITEM_KEYS)
result = []
for should_sync, chunks in input:
if should_sync:
- 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"