snorklerjoe/CubeServer

View on GitHub

Showing 284 of 284 total issues

Function login has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def login():
    """The login page
    Users must be activated to be able to log in.
    Logging in is only useful for admin privileges so far."""
    # Make sure there is a default admin user if the database is empty:
Severity: Minor
Found in src/CubeServer-app/cubeserver_app/blueprints/home/__init__.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 admin_home has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def admin_home():
    """Renders the admin console"""
    # Check admin status:
    if current_user.level != UserLevel.ADMIN:
        return abort(403)
Severity: Minor
Found in src/CubeServer-app/cubeserver_app/blueprints/admin/__init__.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_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def parse_query(cls, cols, args, filter=None):
    # order[0][column]=0&order[0][dir]=desc&start=0&length=5
    order = [
        (int(a[0].groups()[0]), a[0].groups()[1], a[1])
        for a in [(order_re.match(x[0]), x[1]) for x in args.items()]
Severity: Minor
Found in src/CubeServer-app/cubeserver_app/util.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 validate_to has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_to(_, field):  # TODO: This code is UGLY (like the Predator)!
        """Validates the recipient list"""
        txt = field.data
        if not "," in txt:
            if not ("@" in txt and "." in txt):
Severity: Minor
Found in src/CubeServer-app/cubeserver_app/blueprints/admin/email_form.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 encode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def encode(self, message: str | bytes) -> bytes:
        """Encodes a message according to the encoding of this enum value

        Returns the parameter unchanged if already bytes.

Severity: Minor
Found in src/CubeServer-common/cubeserver_common/models/beaconmessage.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 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

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

    def __init__(
Severity: Minor
Found in src/CubeServer-app/cubeserver_app/tables/columns.py - About 45 mins to fix

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

        def __init__(
    Severity: Minor
    Found in src/CubeServer-app/cubeserver_app/tables/columns.py - About 45 mins to fix

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

          def __init__(
      Severity: Minor
      Found in src/CubeServer-common/cubeserver_common/models/mail.py - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

                        if (
                            row["time"] == ""
                            or row["body"] == ""
                            or row["output"] == ""
                            or row["encoding"] == ""
        Severity: Major
        Found in src/CubeServer-app/cubeserver_app/blueprints/admin/__init__.py - About 40 mins to fix

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

          def _render_form(
          Severity: Minor
          Found in src/CubeServer-app/cubeserver_app/tables/columns.py - About 35 mins to fix

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

                def __init__(
            Severity: Minor
            Found in src/CubeServer-common/cubeserver_common/models/datapoint.py - About 35 mins to fix

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

                  def _score(self, team: Team, datapoint: DataPoint, scoring_key, force=False):
              Severity: Minor
              Found in src/CubeServer-common/cubeserver_common/models/config/rules.py - About 35 mins to fix

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

                    def __init__(self, name, pre_classes="", *args, **kwargs):
                Severity: Minor
                Found in src/CubeServer-app/cubeserver_app/tables/columns.py - About 35 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return redirect(url_for(".beacon_table"))
                  Severity: Major
                  Found in src/CubeServer-app/cubeserver_app/blueprints/admin/__init__.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return abort(403)
                    Severity: Major
                    Found in src/CubeServer-app/cubeserver_app/blueprints/home/__init__.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return redirect(url_for(".admin_home"))
                      Severity: Major
                      Found in src/CubeServer-app/cubeserver_app/blueprints/admin/__init__.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return render_template("regclosed.html.jinja2")
                        Severity: Major
                        Found in src/CubeServer-app/cubeserver_app/blueprints/team/__init__.py - About 30 mins to fix

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

                              def send(self) -> bool:
                                  """Sends the message.
                                  Or at least tries to.
                                  Returns True if we think it worked."""
                          
                          
                          Severity: Minor
                          Found in src/CubeServer-common/cubeserver_common/models/mail.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 configure_db has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def configure_db(app=None):
                              """Configures the database"""
                              # Configure MongoDB:
                          
                              driver = os.environ.get("MONGODB_DRIVER", "mongodb")
                          Severity: Minor
                          Found in src/CubeServer-common/cubeserver_common/__init__.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