snorklerjoe/CubeServer

View on GitHub

Showing 284 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function recompute_score(item, id) {
        // TODO: Replace confirm() and alert() with a nice-looking Bootstrap modal
        var confirmationMessage = `Are you certain you wish to RECOMPUTE object #${id}'s score?\n
    All/the datapoint(s) will be re-evaluated under the current scoring rules and multiplier.\n
    All manual score increments on this object will be lost.\n
    Severity: Major
    Found in src/CubeServer-app/cubeserver_app/static/js/admin.js and 1 other location - About 7 hrs to fix
    src/CubeServer-app/cubeserver_app/static/js/admin.js on lines 17..42

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 193.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function deleteItem(item, id) {
        // TODO: Replace confirm() and alert() with a nice-looking Bootstrap modal
        var confirmationMessage = `Are you certain you wish to DELETE object #${id} FOREVER?\n
    This action is PERMANANT and CANNOT BE UNDONE!`;
    //var comment = prompt("Please comment on this change.");  // TODO: Add comment in case of deleted objects also
    Severity: Major
    Found in src/CubeServer-app/cubeserver_app/static/js/admin.js and 1 other location - About 7 hrs to fix
    src/CubeServer-app/cubeserver_app/static/js/admin.js on lines 44..71

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 193.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

                      Severity
                      Category
                      Status
                      Source
                      Language