snorklerjoe/CubeServer

View on GitHub
src/CubeServer-common/cubeserver_common/models/team.py

Summary

Maintainability
C
7 hrs
Test Coverage

Team has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class Team(PyMongoModel):
    """Models a team"""

    RESERVED_NAMES = [config.BEACON_TEAM_NAME] + [
        config.REFERENCE_TEAM_NAME.format(i) for i in range(10)
Severity: Minor
Found in src/CubeServer-common/cubeserver_common/models/team.py - About 3 hrs to fix

    File team.py has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Models teams of participants"""
    
    import logging
    import secrets
    from enum import Enum, unique
    Severity: Minor
    Found in src/CubeServer-common/cubeserver_common/models/team.py - About 2 hrs to fix

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

          def __init__(
      Severity: Major
      Found in src/CubeServer-common/cubeserver_common/models/team.py - About 1 hr to fix

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

            def find_unused_port(cls) -> int:
                """Returns a port within the range specified in the configuration"""
                port_range = range(
                    config.REFERENCE_PORT_RANGE[0], config.REFERENCE_PORT_RANGE[1] + 1
                )
        Severity: Minor
        Found in src/CubeServer-common/cubeserver_common/models/team.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

        Test for membership should be 'not in'
        Open

                if not member.id in self._members:

        Negative comparison should be done using "not in" and "is not".

        Okay: if x not in y:\n    pass
        Okay: assert (X in Y or X is Z)
        Okay: if not (X in Y):\n    pass
        Okay: zz = x is not y
        E713: Z = not X in Y
        E713: if not X.B in Y:\n    pass
        E714: if not X is Y:\n    pass
        E714: Z = not X.B is Y

        Line too long (84 > 79 characters)
        Open

                """Returns the port that the appropriate reference server is listening on"""

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (81 > 79 characters)
        Open

            #        if points < 0:  # Separate reward/penalize methods for expandability

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Module level import not at top of file
        Open

        from cubeserver_common.models.multiplier import DEFAULT_MULTIPLIER, Multiplier

        Place imports at the top of the file.

        Always put imports at the top of the file, just after any module
        comments and docstrings, and before module globals and constants.
        
        Okay: import os
        Okay: # this is a comment\nimport os
        Okay: '''this is a module docstring'''\nimport os
        Okay: r'''this is a module docstring'''\nimport os
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
        Okay:
        try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
        E402: a=1\nimport os
        E402: 'One string'\n"Two string"\nimport os
        E402: a=1\nfrom sys import x
        
        Okay: if x:\n    import os

        Line too long (88 > 79 characters)
        Open

                msg = Message(config.FROM_NAME, config.FROM_ADDR, self.emails, subject, message)

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (80 > 79 characters)
        Open

                return _filter_nonetype_from_list([user.email for user in self.members])

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (81 > 79 characters)
        Open

                # TODO: Replace all usages with id_secondary (property of PyMongoModel's)

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (92 > 79 characters)
        Open

                """Just to allow multiple columns in the adminteamstable to rely upon the name..."""

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (84 > 79 characters)
        Open

            PSYCHO_KILLER = "Talking Head"  # Qu'est-ce que c'est, better run run run run...

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (90 > 79 characters)
        Open

                """Just to allow multiple columns in the adminteamstable to rely upon the id..."""

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Line too long (84 > 79 characters)
        Open

            """Handles states of approval, participation, disqualification, & elimination"""

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        Ambiguous variable name 'l'
        Open

        def _filter_nonetype_from_list(l: list[Any]) -> list:

        Never use the characters 'l', 'O', or 'I' as variable names.

        In some fonts, these characters are indistinguishable from the
        numerals one and zero. When tempted to use 'l', use 'L' instead.
        
        Okay: L = 0
        Okay: o = 123
        Okay: i = 42
        E741: l = 0
        E741: O = 123
        E741: I = 42
        
        Variables can be bound in several other contexts, including class
        and function definitions, 'global' and 'nonlocal' statements,
        exception handlers, and 'with' and 'for' statements.
        In addition, we have a special handling for function parameters.
        
        Okay: except AttributeError as o:
        Okay: with lock as L:
        Okay: foo(l=12)
        Okay: for a in foo(l=12):
        E741: except AttributeError as O:
        E741: with lock as l:
        E741: global I
        E741: nonlocal l
        E741: def foo(l):
        E741: def foo(l=12):
        E741: l = foo(l=12)
        E741: for l in range(10):
        E742: class I(object):
        E743: def l(x):

        Line too long (93 > 79 characters)
        Open

                    "The entire reserved port range for reference servers has already been assigned."

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.

        There are no issues that match your filters.

        Category
        Status