Defelo/PyCrypCli

View on GitHub

Showing 40 of 40 total issues

Function network_accept_deny_completer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def network_accept_deny_completer(context: DeviceContext, args: list[str]) -> list[str]:
    if len(args) == 1:
        return [*{*device_network_names(context), *invitation_network_names(context)}]
    if len(args) == 2:
        try:
Severity: Minor
Found in PyCrypCli/commands/network.py - About 55 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 update_presence has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def update_presence(
Severity: Minor
Found in PyCrypCli/context/context.py - About 45 mins to fix

    Function list_shop_products has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_shop_products(client: Client) -> dict[str, ShopProduct]:
        out = {}
        for category in ShopCategory.shop_list(client):
            for subcategory in category.subcategories:
                for item in subcategory.items:
    Severity: Minor
    Found in PyCrypCli/commands/shop.py - About 45 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 build has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def build(client: Client, mainboard: str, cpu: str, gpu: str, ram: list[str], disk: list[str]) -> Device:
    Severity: Minor
    Found in PyCrypCli/models/device.py - About 35 mins to fix

      Function ms has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def ms(self, ms: str, endpoint: list[str], *, retry: int = 0, **data: Any) -> dict[str, Any]:
      Severity: Minor
      Found in PyCrypCli/client.py - About 35 mins to fix

        Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Minor
        Found in PyCrypCli/commands/command.py - About 35 mins to fix

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

              def request(self, data: dict[str, Any], no_response: bool = False) -> dict[str, Any]:
                  if self.websocket is None:
                      raise ConnectionError
          
                  while self.waiting_for_response:
          Severity: Minor
          Found in PyCrypCli/client.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 register has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def register(self, username: str, password: str) -> TokenResponse:
                  if self.logged_in:
                      raise LoggedInError
          
                  self.init()
          Severity: Minor
          Found in PyCrypCli/client.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_inventory_trade has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def handle_inventory_trade(context: MainContext, args: List[str]) -> None:
              """
              Trade with other players
              """
          
          
          Severity: Minor
          Found in PyCrypCli/commands/inventory.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 print_help has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def print_help(context: Context, cmd: Command | None) -> None:
              if cmd is None:
                  cmds: dict[str, Command] = {c.name: c for c in context.get_commands().values()}
              else:
                  print(cmd.description)
          Severity: Minor
          Found in PyCrypCli/commands/help.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

          Avoid too many return statements within this function.
          Open

                  return [name.replace(" ", "") for name in list(hardware.ram) + list(hardware.disk)]
          Severity: Major
          Found in PyCrypCli/commands/device.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return []
            Severity: Major
            Found in PyCrypCli/commands/device.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return
              Severity: Major
              Found in PyCrypCli/commands/device.py - About 30 mins to fix

                Function network_kick_completer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def network_kick_completer(context: DeviceContext, args: list[str]) -> list[str]:
                    if len(args) == 1:
                        return [*{*device_network_names(context)}]
                    if len(args) == 2:
                        try:
                Severity: Minor
                Found in PyCrypCli/commands/network.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

                Function handle_hostname has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def handle_hostname(context: DeviceContext, args: list[str]) -> None:
                    """
                    Show or modify the name of the device
                    """
                
                
                Severity: Minor
                Found in PyCrypCli/commands/device.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

                Function handle_feedback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def handle_feedback(context: LoginContext, _: Any) -> None:
                    """
                    Send feedback to the developer
                    """
                
                
                Severity: Minor
                Found in PyCrypCli/commands/shell.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

                Function handle_main_help has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def handle_main_help(context: Context, args: list[str]) -> None:
                    """
                    Show a list of available commands
                    """
                
                
                Severity: Minor
                Found in PyCrypCli/commands/help.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

                Function stop_bruteforce has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def stop_bruteforce(context: DeviceContext, service: BruteforceService) -> None:
                    try:
                        access, _, target_device = service.stop()
                    except AttackNotRunningError:
                        raise CommandError("Bruteforce attack is not running.")
                Severity: Minor
                Found in PyCrypCli/commands/service.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

                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

                Severity
                Category
                Status
                Source
                Language