Crystalnix/termius-cli

View on GitHub

Showing 13 of 35 total issues

Function parse has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(self, file_obj): # noqa
        """
        Read an OpenSSH config from the given file object.

        :param file_obj: a file-like object to read the config file from
Severity: Minor
Found in termius/porting/providers/ssh/parser.py - About 3 hrs 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

ApplicationStorage has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationStorage(object):
    """Storage for user data."""

    path = '{application_directory}/storage'
    defaultstorage = list
Severity: Minor
Found in termius/core/storage/__init__.py - About 2 hrs to fix

    Function __call__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, parser, namespace, values, option_string=None):
            app = self.default
            parser.print_help(app.stdout)
            app.stdout.write('\nCommands:\n')
            command_manager = app.command_manager
    Severity: Minor
    Found in termius/core/commands/help.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 take_action has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def take_action(self, parsed_args):
            if parsed_args.cmd:
                try:
                    the_cmd = self.app.command_manager.find_command(
                        parsed_args.cmd,
    Severity: Minor
    Found in termius/core/commands/help.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 parse_sessions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_sessions(self, sessions, parent_node):
            """Parse SecureCRT sessions."""
            for session in sessions:
                if session.get('name') not in self.meta_sessions:
                    if not self.is_session_group(session):
    Severity: Minor
    Found in termius/porting/providers/securecrt/parser.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 serialize_identity_field has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def serialize_identity_field(self, args, instance):
            """Serialize identity."""
            if (args.password or args.username) and args.identity:
                raise InvalidArgumentException()
    
    
    Severity: Minor
    Found in termius/handlers/ssh_config.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, filename, flag='c', mode=None, _format='json',
    Severity: Minor
    Found in termius/core/storage/driver.py - About 45 mins to fix

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

          def __init__(self, command, save_strategy=None,
      Severity: Minor
      Found in termius/core/storage/__init__.py - About 35 mins to fix

        Function is_host_exists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def is_host_exists(self, new_host):
                """Retrieve exited host for new host."""
                existed_hosts = self.storage.filter(Host, label=new_host.label)
                for host in existed_hosts:
                    if host.group and new_host.group:
        Severity: Minor
        Found in termius/porting/providers/base.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 update_model_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_model_fields(self, model, payload):
                """Update model's fields with payload."""
                fk_fields = model.fk_field_names()
                models_fields = {
                    i: payload[i]
        Severity: Minor
        Found in termius/cloud/client/transformers/single.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 serialize_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def serialize_args(self, args, instance=None):
                """Convert args to instance."""
                instance = instance or self.model_class()
                for i in self.model_class.fields:
                    try:
        Severity: Minor
        Found in termius/core/commands/mixins.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 sort_groups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def sort_groups(self, groups):
                """Sort to prevent missing parent groups."""
                def has_parent(group):
                    return group['parent_group'] is not None
        
        
        Severity: Minor
        Found in termius/cloud/client/transformers/many.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 create_entries_from_tree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_entries_from_tree(self, tree, result_hosts, parent_group=None):
                """Create instances from groups tree."""
                for label, node in tree.items():
                    if not isinstance(node, dict):
                        continue
        Severity: Minor
        Found in termius/porting/providers/securecrt/provider.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