CSCfi/pebbles

View on GitHub

Showing 106 of 169 total issues

File models.py has 752 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import hashlib
import importlib
import inspect
import json
Severity: Major
Found in pebbles/models.py - About 1 day to fix

    File workspaces.py has 702 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import datetime
    import json
    import logging
    import re
    import time
    Severity: Major
    Found in pebbles/views/workspaces.py - About 1 day to fix

      File kubernetes_driver.py has 643 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import datetime
      import logging
      import os
      import time
      from enum import Enum, unique
      Severity: Major
      Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 1 day to fix

        Function oauth2_login has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

        def oauth2_login():
            parser = reqparse.RequestParser()
            parser.add_argument('agreement_sign', type=str, default=False, location='args')
            args = parser.parse_args()
            if not current_app.config['OAUTH2_LOGIN_ENABLED']:
        Severity: Minor
        Found in pebbles/views/sso.py - About 6 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 do_check_readiness has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_check_readiness(self, token, application_session_id):
                application_session = self.fetch_and_populate_application_session(token, application_session_id)
                namespace = self.get_application_session_namespace(application_session)
                pod_api = self.dynamic_client.resources.get(api_version='v1', kind='Pod')
                pods = pod_api.get(
        Severity: Minor
        Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 5 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 applications.py has 350 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import datetime
        import logging
        import uuid
        
        import flask_restful as restful
        Severity: Minor
        Found in pebbles/views/applications.py - About 4 hrs to fix

          KubernetesDriverBase has 34 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class KubernetesDriverBase(base_driver.ProvisioningDriverBase):
              def __init__(self, logger, config, cluster_config, token):
                  super().__init__(logger, config, cluster_config, token)
          
                  self.ingress_app_domain = cluster_config.get('appDomain', 'localhost')
          Severity: Minor
          Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 4 hrs to fix

            File application_sessions.py has 338 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import datetime
            import json
            import logging
            
            import flask_restful as restful
            Severity: Minor
            Found in pebbles/views/application_sessions.py - About 4 hrs to fix

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

                  def put(self, workspace_id):
                      form = WorkspaceForm()
                      if not form.validate_on_submit():
                          logging.warning('validation error on updating workspace')
                          return form.errors, 422
              Severity: Minor
              Found in pebbles/views/workspaces.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

              User has 31 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class User(db.Model):
                  __tablename__ = 'users'
              
                  id = db.Column(db.String(32), primary_key=True)
                  # ext_id is mandatory and unique. ext_id can be used to retrieve database objects
              Severity: Minor
              Found in pebbles/models.py - About 3 hrs to fix

                File controllers.py has 321 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import logging
                import os
                import time
                import traceback
                from random import randrange
                Severity: Minor
                Found in pebbles/worker/controllers.py - About 3 hrs to fix

                  Function process has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def process(self):
                          # process sessions in increased intervals
                          if time.time() < self.next_check_ts:
                              return
                          self.update_next_check_ts(self.polling_interval_min, self.polling_interval_max)
                  Severity: Minor
                  Found in pebbles/worker/controllers.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

                  Function process has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def process(self):
                          # process clusters in increased intervals
                          if time.time() < self.next_check_ts:
                              return
                          self.update_next_check_ts(self.polling_interval_min, self.polling_interval_max)
                  Severity: Minor
                  Found in pebbles/worker/controllers.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

                  PBClient has 27 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class PBClient:
                      def __init__(self, token, api_base_url, ssl_verify=True):
                          self.token = token
                          self.api_base_url = api_base_url
                          self.ssl_verify = ssl_verify
                  Severity: Minor
                  Found in pebbles/client.py - About 3 hrs to fix

                    Function init_api has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    def init_api(app: Flask):
                        from pebbles.views.alerts import AlertList, AlertView, SystemStatus, AlertReset
                        from pebbles.views.application_categories import ApplicationCategoryList
                        from pebbles.views.application_sessions import ApplicationSessionList, ApplicationSessionView, \
                            ApplicationSessionLogs
                    Severity: Major
                    Found in pebbles/app.py - About 2 hrs to fix

                      Function patch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def patch(self, application_session_id):
                              user = g.user
                      
                              # check that the user has rights to access the session
                              opts = dict(application_session_id=application_session_id)
                      Severity: Minor
                      Found in pebbles/views/application_sessions.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 get_provisioning_config has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_provisioning_config(application):
                          """Render provisioning config for application"""
                      
                          app_config = application.config if application.config else {}
                          provisioning_config = application.base_config.copy()
                      Severity: Minor
                      Found in pebbles/utils.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 handle_status_change has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def handle_status_change(self, user, workspace_id, new_status):
                              workspace = Workspace.query.filter_by(id=workspace_id).first()
                      
                              if not workspace:
                                  abort(404)
                      Severity: Minor
                      Found in pebbles/views/workspaces.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 do_deprovision has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def do_deprovision(self, token, application_session_id):
                              application_session = self.fetch_and_populate_application_session(token, application_session_id)
                              namespace = self.get_application_session_namespace(application_session)
                              # remove deployment
                              try:
                      Severity: Minor
                      Found in pebbles/drivers/provisioning/kubernetes_driver.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 patch has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def patch(self, application_session_id):
                              patch_parser = reqparse.RequestParser()
                              patch_parser.add_argument('log_record', type=dict)
                              args = patch_parser.parse_args()
                      
                      
                      Severity: Minor
                      Found in pebbles/views/application_sessions.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

                      Severity
                      Category
                      Status
                      Source
                      Language