CSCfi/pebbles

View on GitHub

Showing 106 of 169 total issues

Function get_driver has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_driver(self, cluster_name):
        """Create driver instance for given cluster.
        We cache the driver instances to avoid login for every new request"""
        cluster = None
        for c in self.cluster_config['clusters']:
Severity: Minor
Found in pebbles/worker/controllers.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 check_config_against_attribute_limits has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def check_config_against_attribute_limits(config, limits):
    """Check application config against attribute limits. Return None if AOK, error string otherwise"""
    for limit in limits:
        if limit['name'] in config:
            name = limit['name']
Severity: Minor
Found in pebbles/utils.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 process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def process(self):
        # process workspace management 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 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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self):
        if 'TEST_MODE' not in current_app.config:
            cluster_config = load_cluster_config(load_passwords=False)
        else:
            # rig unit tests to use dummy data
Severity: Minor
Found in pebbles/views/clusters.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 create_app has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def create_app(test_config=None):
    app = Flask(__name__, static_url_path='')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    # initialize migrations with Alembic
Severity: Minor
Found in pebbles/app.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 load_cluster_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def load_cluster_config(
        load_passwords=True,
        cluster_config_file='/run/secrets/pebbles/cluster-config.yaml',
        cluster_passwords_file='/run/secrets/pebbles/cluster-passwords.yaml',
):
Severity: Minor
Found in pebbles/utils.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, ext_id, password=None, is_admin=False, email_id=None, expiry_ts=None, pseudonym=None,
Severity: Major
Found in pebbles/models.py - About 50 mins to fix

    Function ensure_volume has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def ensure_volume(self, namespace, application_session, volume_name, volume_size, storage_class_name,
    Severity: Major
    Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 50 mins to fix

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

          def create_volume(self, namespace, volume_name, volume_size, storage_class_name,
      Severity: Minor
      Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 45 mins to fix

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

            def create_volume_restore_job(self, token, workspace_id, volume_name, volume_size_spec, storage_class, src_cluster):
        Severity: Minor
        Found in pebbles/drivers/provisioning/kubernetes_driver.py - About 45 mins to fix

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

              def post(self, workspace_id):
                  args = self.parser.parse_args()
                  workspace = Workspace.query.filter_by(id=workspace_id).first()
                  if not workspace:
                      logging.warning('workspace %s does not exist', workspace_id)
          Severity: Minor
          Found in pebbles/views/workspaces.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 put has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def put(self, application_id):
                  form = ApplicationForm()
                  if not form.validate_on_submit():
                      logging.warning("validation error on update application config")
                      return form.errors, 422
          Severity: Minor
          Found in pebbles/views/applications.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 get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get(self, workspace_id):
                  args = self.get_parser.parse_args()
                  user = g.user
                  workspace = Workspace.query.filter_by(id=workspace_id).first()
                  if not workspace:
          Severity: Minor
          Found in pebbles/views/workspaces.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 create_user has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def create_user(ext_id, password, is_admin=False, email_id=None, expiry_ts=None, annotations=None):
          Severity: Minor
          Found in pebbles/views/commons.py - About 45 mins to fix

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

                def create_volume_restore_job(self, token, workspace_id, volume_name, volume_size_spec, storage_class,
            Severity: Minor
            Found in pebbles/drivers/provisioning/base_driver.py - About 45 mins to fix

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

                  def get(self):
                      args = self.parser.parse_args()
                      user = get_current_user()
                      query = Message.query
                      if args.get('show_unread'):
              Severity: Minor
              Found in pebbles/views/messages.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__(self, name=None, description=None, application_type='generic', attribute_limits=None,
              Severity: Minor
              Found in pebbles/models.py - About 45 mins to fix

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

                    def __init__(self, subject, content, level, targets, is_enabled, is_public):
                Severity: Minor
                Found in pebbles/models.py - About 45 mins to fix

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

                      def do_deprovision(self, token, application_session_id):
                          """ Implements deprovisioning, called by superclass.
                              Iterates through template object types, queries them by label and deletes all objects.
                          """
                          application_session = self.fetch_and_populate_application_session(token, application_session_id)
                  Severity: Minor
                  Found in pebbles/drivers/provisioning/openshift_template_driver.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 post has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def post(self):
                          form = ApplicationForm()
                          if not form.validate_on_submit():
                              logging.warning("Form validation error on create application %s" % form.errors)
                              return form.errors, 422
                  Severity: Minor
                  Found in pebbles/views/applications.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

                  Severity
                  Category
                  Status
                  Source
                  Language