CSCfi/pebbles

View on GitHub
pebbles/models.py

Summary

Maintainability
F
3 days
Test Coverage

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

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

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

      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 __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 __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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, id, target, source, status, data):
              Severity: Minor
              Found in pebbles/models.py - About 35 mins to fix

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

                    def __init__(self, application_session_id, log_level, log_type, timestamp, message):
                Severity: Minor
                Found in pebbles/models.py - About 35 mins to fix

                  Function check_membership_expiry_policy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def check_membership_expiry_policy(mep):
                          """ Return validation errors for given membership expiry policy or None if successful """
                          if not isinstance(mep, dict):
                              return 'membership expiry policy must be a dict'
                          kind = mep.get('kind')
                  Severity: Minor
                  Found in pebbles/models.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

                  Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __init__(self, ext_id, password=None, is_admin=False, email_id=None, expiry_ts=None, pseudonym=None,
                                   workspace_quota=None):
                          self.id = uuid.uuid4().hex
                          self.ext_id = ext_id
                          self.is_admin = is_admin
                  Severity: Minor
                  Found in pebbles/models.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 None
                  Severity: Major
                  Found in pebbles/models.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return None
                    Severity: Major
                    Found in pebbles/models.py - About 30 mins to fix

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

                      def load_yaml(yaml_data):
                          """
                          A function to load annotated yaml data into the database.
                          Example can be found in devel_dataset.yaml
                          """
                      Severity: Minor
                      Found in pebbles/models.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

                      There are no issues that match your filters.

                      Category
                      Status