CSCfi/pebbles

View on GitHub

Showing 106 of 169 total issues

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

    def post(self):
        user = g.user

        form = ApplicationSessionForm()
        if not form.validate_on_submit():
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 check_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def check_data(datadir):
    """
    Checks given applications and templates YAML data files in given directory for consistency.
    """
    applications_file = datadir + '/applications.yaml'
Severity: Minor
Found in manage.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 render_template_objects has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def render_template_objects(self, namespace, application_session):
        """ Render the template for the application session. This is done on OpenShift server.
        """
        application_config = application_session['provisioning_config']

Severity: Minor
Found in pebbles/drivers/provisioning/openshift_template_driver.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 process_application has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def process_application(application):
    # cache application template names in the request context to avoid lookups on every call
    template_name_cache = g.setdefault('template_name_cache', dict())
    if application.template_id not in template_name_cache.keys():
        result = db.session.execute(
Severity: Minor
Found in pebbles/views/applications.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 get has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self):
        user = g.user
        args = self.get_parser.parse_args()

        workspace_user_query = WorkspaceMembership.query
Severity: Minor
Found in pebbles/views/workspaces.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 process_volume_restore_task has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def process_volume_restore_task(self, task):
        task_data = task.get('data')
        driver = self.get_driver(task_data.get('tgt_cluster'))
        if not driver:
            raise RuntimeError(
Severity: Minor
Found in pebbles/worker/controllers.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 post has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self):
        user = g.user
        user_owned_workspaces = WorkspaceMembership.query.filter_by(user_id=user.id, is_owner=True)
        num_user_owned_workspaces = [
            w.workspace.status == Workspace.STATUS_ACTIVE for w in user_owned_workspaces].count(True)
Severity: Minor
Found in pebbles/views/workspaces.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 delete has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def delete(self, application_id):
        user = g.user
        s = rules.generate_application_query(user, dict(application_id=application_id))
        application = db.session.scalar(s)
        if not application:
Severity: Minor
Found in pebbles/views/applications.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 11 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, name=None, description=None, template_id=None, workspace_id=None, labels=None,
Severity: Major
Found in pebbles/models.py - About 1 hr to fix

    Function list_application_images has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_application_images():
        """
        Lists images used by non-deleted applications
        """
        applications = Application.query.filter(Application.status != 'deleted').all()
    Severity: Minor
    Found in manage.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 post has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def post(self):
            parser = reqparse.RequestParser()
            parser.add_argument('agreement_sign', type=str, default=False)
            args = parser.parse_args()
            form = SessionCreateForm()
    Severity: Minor
    Found in pebbles/views/sessions.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 createuser_bulk has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def createuser_bulk(user_prefix=None, domain_name=None, count=0, lifetime_in_days=0):
        """Creates new demo users"""
        if not count:
            count = int(input('Enter the number of demo user accounts needed: '))
        print()
    Severity: Minor
    Found in manage.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 post has 29 lines of code (exceeds 25 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 1 hr to fix

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

      def check_attribute_limit_format(limits):
          """Check attribute limit format. Return None if AOK, error string otherwise"""
          for limit in limits:
              name = limit.get('name', None)
              min = limit.get('min', None)
      Severity: Minor
      Found in pebbles/utils.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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def update(self, token, application_session_id):
              """ an update call  updates the status of an application_session.
      
              If an application_session is
                * queued it will be provisioned
      Severity: Minor
      Found in pebbles/drivers/provisioning/base_driver.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 get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(self, workspace_id):
              applications = Application.query.filter_by(workspace_id=workspace_id).all()
      
              session_accounting = {}
              total_gib_hours = 0
      Severity: Minor
      Found in pebbles/views/workspaces.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 run_membership_expiry_cleanup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def run_membership_expiry_cleanup(pb_client):
          """Deletes expired workspace memberships by
              - listing workspaces with matching policy
              - asking API to clean up the mappings
          """
      Severity: Minor
      Found in pebbles/maintenance/main.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 put has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def put(self, application_id):
              user = g.user
              application = Application.query.filter_by(id=application_id).first_or_404()
              args = self.parser.parse_args()
      
      
      Severity: Minor
      Found in pebbles/views/applications.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 patch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def patch(self, workspace_id):
              user = g.user
              args = self.patch_parser.parse_args()
              workspace = Workspace.query.filter_by(id=workspace_id).first()
              if not workspace:
      Severity: Minor
      Found in pebbles/views/workspaces.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 oauth2_login has 26 lines of code (exceeds 25 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 1 hr to fix
        Severity
        Category
        Status
        Source
        Language