snorklerjoe/CubeServer

View on GitHub

Showing 38 of 284 total issues

File __init__.py has 644 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Flask blueprint managing the administration side of the application"""

# TODO: Restructure blueprint files- This whole thing is an absolute mess!
# Arnold Schwarzenegger looked at this code and called it "one ugly motha*****".

Severity: Major
Found in src/CubeServer-app/cubeserver_app/blueprints/admin/__init__.py - About 1 day to fix

    File modelutils.py has 368 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Some utility classes to help with object mapping"""
    
    from abc import ABC, abstractmethod
    from enum import Enum
    from typing import Any, List, Mapping, Optional, Tuple, Type, cast
    Severity: Minor
    Found in src/CubeServer-common/cubeserver_common/models/utils/modelutils.py - About 4 hrs to fix

      File columns.py has 322 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Defines custom column types for flask-table"""
      
      from enum import Enum
      from typing import List, Mapping, Optional, Tuple, Any
      from flask import render_template_string, url_for
      Severity: Minor
      Found in src/CubeServer-app/cubeserver_app/tables/columns.py - About 3 hrs to fix

        Function register has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def register():
            """Renders the team registration page"""
            if current_app.config["CONFIGURABLE"].registration_open:
                form = registration_form.RegistrationForm()
        
        
        Severity: Minor
        Found in src/CubeServer-app/cubeserver_app/blueprints/team/__init__.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

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

            def activation():
                """Activates a user invitation
                When the HTTP method is GET, this assumes it is from the
                invitation URL generated by the admin panel and shared with
                a prospective user. When this link is opened by the user, it
            Severity: Minor
            Found in src/CubeServer-app/cubeserver_app/blueprints/home/__init__.py - About 2 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

            Function static_cache_buster has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                def static_cache_buster(endpoint, values):
                    if "." in endpoint and "filename" in values:
                        (bp_name, vf_name) = endpoint.rsplit(".", 1)
                    else:
                        (bp_name, vf_name) = (None, endpoint)
            Severity: Minor
            Found in src/CubeServer-app/cubeserver_app/__init__.py - About 2 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

            File rules.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """Models the game rules
            
            See app.models.team for more information regarding the game aspect"""
            
            import logging
            Severity: Minor
            Found in src/CubeServer-common/cubeserver_common/models/config/rules.py - About 2 hrs to fix

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

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

                Function post_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def post_data(self, datapoint: DataPoint, _force: bool = False) -> bool:
                        """This is executed whenever a team sends in some data
                        If this returns true, it sends an OK response to the client"""
                
                        # Prevent double-dipping on points:
                Severity: Minor
                Found in src/CubeServer-common/cubeserver_common/models/config/rules.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 beacon_csv has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                def beacon_csv():
                    """CSV beacon packet bulk-upload"""
                    # 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 __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
                Open

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

                  Function _score has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _score(self, team: Team, datapoint: DataPoint, scoring_key, force=False):
                          """Scores the datapoint, storing the score in the datapoint.
                          Set force to True to recalculate an already-scored datapoint
                          THIS MAKES THE *ASS*UMPTION* THAT THE TIME WINDOW IS VALID!"""
                          # Make sure the point is scoreable:
                  Severity: Minor
                  Found in src/CubeServer-common/cubeserver_common/models/config/rules.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 __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 table_endpoint has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def table_endpoint(table, identifier, field):
                        """Endpoint for the team/user modification API
                        -- Action for forms within the table of users/teams"""
                        # Check admin status:
                        if current_user.level != UserLevel.ADMIN:
                    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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(  # Default gameplay parameters:
                    Severity: Major
                    Found in src/CubeServer-common/cubeserver_common/models/config/rules.py - About 1 hr to fix

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

                      def register_commands(app):
                          from cubeserver_common.models.config.rules import RegularOccurrence, Rules
                          from cubeserver_common.models.datapoint import DataPoint, DataClass
                          from cubeserver_common.models.team import Team, TeamLevel
                      
                      
                      Severity: Minor
                      Found in src/CubeServer-app/cubeserver_app/command.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 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

                      Severity
                      Category
                      Status
                      Source
                      Language