Defelo/PyCrypCli

View on GitHub
PyCrypCli/commands/files.py

Summary

Maintainability
B
5 hrs
Test Coverage

File files.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Any, cast

from .command import command, CommandError
from ..context import DeviceContext
from ..exceptions import (
Severity: Minor
Found in PyCrypCli/commands/files.py - About 2 hrs to fix

    Function handle_rm has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def handle_rm(context: DeviceContext, args: list[str]) -> None:
        """
        Remove a file
        """
    
    
    Severity: Minor
    Found in PyCrypCli/commands/files.py - About 1 hr to fix

    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 create_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_file(context: DeviceContext, filepath: str, content: str) -> None:
        *path, filename = filepath.split("/")
        parent: File | None = context.path_to_file("/".join(path))
        if not parent:
            raise CommandError("Parent directory does not exist.")
    Severity: Minor
    Found in PyCrypCli/commands/files.py - About 35 mins to fix

    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 handle_cd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def handle_cd(context: DeviceContext, args: list[str]) -> None:
        """
        Change the current working directory
        """
    
    
    Severity: Minor
    Found in PyCrypCli/commands/files.py - About 25 mins to fix

    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

    There are no issues that match your filters.

    Category
    Status