CSCfi/pebbles

View on GitHub
pebbles/views/workspaces.py

Summary

Maintainability
F
1 wk
Test Coverage

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

    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

    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 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 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 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 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 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 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 patch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def patch(self, workspace_id):
            parser = reqparse.RequestParser()
            parser.add_argument('new_owner_id', type=str)
    
            args = parser.parse_args()
    Severity: Minor
    Found in pebbles/views/workspaces.py - About 35 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

    Avoid too many return statements within this function.
    Open

            return marshal_based_on_role(user, workspace)
    Severity: Major
    Found in pebbles/views/workspaces.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return msg, 422
      Severity: Major
      Found in pebbles/views/workspaces.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return 'Account properties prohibit joining', 422
        Severity: Major
        Found in pebbles/views/workspaces.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return {'error': 'User %s needs owner privileges, please contact administrator' % args.new_owner_id}, 403
          Severity: Major
          Found in pebbles/views/workspaces.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return dict(message=msg), 422
            Severity: Major
            Found in pebbles/views/workspaces.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return marshal_based_on_role(user, workspace)
              Severity: Major
              Found in pebbles/views/workspaces.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return marshal_based_on_role(user, workspace)
                Severity: Major
                Found in pebbles/views/workspaces.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return {'error': 'User is already owner of the workspace'}, 403
                  Severity: Major
                  Found in pebbles/views/workspaces.py - About 30 mins to fix

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

                        def put(self, join_code):
                            user = g.user
                            workspace = Workspace.query.filter_by(join_code=join_code).first()
                            if not workspace:
                                logging.warning('invalid workspace join code %s', join_code)
                    Severity: Minor
                    Found in pebbles/views/workspaces.py - About 25 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 marshal_based_on_role has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def marshal_based_on_role(user, workspace):
                        if user.is_admin:
                            if workspace.name.startswith('System.'):
                                workspace.membership_type = 'public'
                            return restful.marshal(workspace, workspace_fields_admin)
                    Severity: Minor
                    Found in pebbles/views/workspaces.py - About 25 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

                    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

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

                            if 'TEST_MODE' not in current_app.config:
                                cluster_config = load_cluster_config(load_passwords=False)
                            else:
                                # rig unit tests to use dummy data
                                cluster_config = dict(clusters=[
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 2 hrs to fix
                    pebbles/views/clusters.py on lines 26..32

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

                    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

                            wm_new_owner = WorkspaceMembership.query \
                                .filter_by(workspace_id=workspace_id) \
                                .filter_by(user_id=args.new_owner_id) \
                                .options(sa.orm.subqueryload(WorkspaceMembership.user)) \
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 491..494

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

                    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

                            wm = WorkspaceMembership.query \
                                .filter_by(workspace_id=workspace_id) \
                                .filter_by(user_id=args.user_id) \
                                .options(sa.orm.subqueryload(WorkspaceMembership.user)) \
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 540..543

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

                    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

                            if not (user.is_admin or commons.is_workspace_manager(user, workspace)):
                                logging.warning('workspace %s not managed by %s, cannot see users', workspace_id, user.ext_id)
                                abort(403)
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 449..451

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

                    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

                            if not (user.is_admin or commons.is_workspace_manager(user, workspace)):
                                logging.warning('workspace %s not managed by %s, cannot see users', workspace_id, user.ext_id)
                                abort(403)
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 487..489

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

                    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

                                if form.name.data.lower().startswith('system'):
                                    logging.warning('Workspace name cannot start with "System"')
                                    return dict(error='Workspace name cannot start with "System"'), 422
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 168..170

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

                    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

                            if new_limit < 0:
                                logging.warning('rejecting illegal memory_limit_gib "%s" for workspace %s', new_limit, workspace_id)
                                return dict(error='illegal memory limit %s' % new_limit), 422
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 731..733

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

                    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

                            if new_size < 0:
                                logging.warning('rejecting illegal user_work_folder_size "%s" for workspace %s', new_size, workspace_id)
                                return dict(error='illegal work folder size %s' % new_size), 422
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 702..704

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

                    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

                            if form.name.data.lower().startswith('system'):
                                logging.warning('Workspace name cannot start with System')
                                return dict(message='Workspace name cannot start with \'System\'.'), 422
                    Severity: Major
                    Found in pebbles/views/workspaces.py and 1 other location - About 1 hr to fix
                    pebbles/views/workspaces.py on lines 263..265

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

                    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

                    There are no issues that match your filters.

                    Category
                    Status