CSCfi/pebbles

View on GitHub

Showing 169 of 169 total issues

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

    def check_volume_backup_job(self, token, workspace_id, volume_name):
        namespace = self.get_namespace(workspace_id)

        # check if the namespace exists
        if not self.namespace_exists(namespace):
Severity: Major
Found in pebbles/drivers/provisioning/kubernetes_driver.py and 1 other location - About 2 days to fix
pebbles/drivers/provisioning/kubernetes_driver.py on lines 701..728

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 262.

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

    def check_volume_restore_job(self, token, workspace_id, volume_name):
        namespace = self.get_namespace(workspace_id)

        # check if the namespace exists
        if not self.namespace_exists(namespace):
Severity: Major
Found in pebbles/drivers/provisioning/kubernetes_driver.py and 1 other location - About 2 days to fix
pebbles/drivers/provisioning/kubernetes_driver.py on lines 632..659

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 262.

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

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

        class WorkspaceModifyMembershipExpiryPolicy(restful.Resource):
        
            @auth.login_required
            @requires_admin
            def put(self, workspace_id):
        Severity: Major
        Found in pebbles/views/workspaces.py and 1 other location - About 1 day to fix
        pebbles/views/workspaces.py on lines 809..830

        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 151.

        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

        class WorkspaceModifyMembershipJoinPolicy(restful.Resource):
        
            @auth.login_required
            @requires_admin
            def put(self, workspace_id):
        Severity: Major
        Found in pebbles/views/workspaces.py and 1 other location - About 1 day to fix
        pebbles/views/workspaces.py on lines 785..806

        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 151.

        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

        def is_workspace_manager(user, workspace=None):
            if workspace:
                if workspace.status != Workspace.STATUS_ACTIVE:
                    return False
                manager_cache = g.setdefault('manager_cache', dict())
        Severity: Major
        Found in pebbles/views/commons.py and 1 other location - About 1 day to fix
        pebbles/views/commons.py on lines 134..147

        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 141.

        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

        def is_workspace_owner(user, workspace=None):
            if workspace:
                if workspace.status != Workspace.STATUS_ACTIVE:
                    return False
        
        
        Severity: Major
        Found in pebbles/views/commons.py and 1 other location - About 1 day to fix
        pebbles/views/commons.py on lines 119..131

        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 141.

        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

        def downgrade():
            # environment_sessions -> instances
            op.rename_table('environment_sessions', 'instances')
            op.alter_column('instances', 'session_data', new_column_name='instance_data')
            op.execute('ALTER INDEX pk_environment_sessions RENAME TO pk_instances')
        migrations/versions/63e1cbb91610_rename_instance_to_environment_session.py on lines 16..36

        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 124.

        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

        def upgrade():
            # instances -> environment_sessions
            op.rename_table('instances', 'environment_sessions')
            op.alter_column('environment_sessions', 'instance_data', new_column_name='session_data')
            op.execute('ALTER INDEX pk_instances RENAME TO pk_environment_sessions')
        migrations/versions/63e1cbb91610_rename_instance_to_environment_session.py on lines 40..60

        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 124.

        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

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

            op.create_table('alerts',
            sa.Column('target', sa.String(length=64), nullable=False),
            sa.Column('source', sa.String(length=64), nullable=False),
            sa.Column('status', sa.String(length=64), nullable=False),
            sa.Column('data', sa.Text(), nullable=True),
        Severity: Major
        Found in migrations/versions/e5ec28975cca_alert_history.py and 1 other location - About 7 hrs to fix
        migrations/versions/da41c0a6e015_add_alerts.py on lines 17..25

        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 119.

        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

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

        def upgrade():
            # ### commands auto generated by Alembic - please adjust! ###
            op.create_table('alerts',
            sa.Column('target', sa.String(length=64), nullable=False),
            sa.Column('source', sa.String(length=64), nullable=False),
        Severity: Major
        Found in migrations/versions/da41c0a6e015_add_alerts.py and 1 other location - About 7 hrs to fix
        migrations/versions/e5ec28975cca_alert_history.py on lines 36..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 119.

        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

        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

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

        application_session_fields_manager = {
            'id': fields.String,
            'name': fields.String,
            'created_at': fields.DateTime(dt_format='iso8601'),
            'provisioned_at': fields.DateTime(dt_format='iso8601'),
        Severity: Major
        Found in pebbles/views/application_sessions.py and 1 other location - About 5 hrs to fix
        pebbles/views/application_sessions.py on lines 64..82

        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 97.

        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

        application_session_fields_user = {
            'id': fields.String,
            'name': fields.String,
            'created_at': fields.DateTime(dt_format='iso8601'),
            'provisioned_at': fields.DateTime(dt_format='iso8601'),
        Severity: Major
        Found in pebbles/views/application_sessions.py and 1 other location - About 5 hrs to fix
        pebbles/views/application_sessions.py on lines 42..60

        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 97.

        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

        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
              Severity
              Category
              Status
              Source
              Language