renalreg/cornflake

View on GitHub

Showing 21 of 40 total issues

File fields.py has 409 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import copy
import uuid
from datetime import date, datetime

Severity: Minor
Found in cornflake/fields.py - About 5 hrs to fix

    File serializers.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import copy
    from collections import OrderedDict
    
    import six
    
    
    Severity: Minor
    Found in cornflake/serializers.py - About 3 hrs to fix

      Function _first has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def _first(errors):
              r = None
      
              if isinstance(errors, list):
                  for x in errors:
      Severity: Minor
      Found in cornflake/exceptions.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_fields has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_fields(self):
              fields = super(ModelSerializer, self).get_fields()
      
              model_fields = self.get_model_fields()
              model_exclude = self.get_model_exclude()
      Severity: Minor
      Found in cornflake/sqlalchemy_orm.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 normalise has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def normalise(errors):
              if isinstance(errors, dict):
                  new_errors = OrderedDict()
      
                  for k, v in errors.items():
      Severity: Minor
      Found in cornflake/exceptions.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 to_internal_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_internal_value(self, data):
              if isinstance(data, dict):
                  data = data.get(self.key_name, empty)
      
                  if data is empty:
      Severity: Minor
      Found in cornflake/fields.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 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in cornflake/fields.py - About 1 hr to fix

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

            def to_internal_value(self, data):
                if not isinstance(data, dict):
                    self.fail('not_a_dict')
        
                errors = {}
        Severity: Minor
        Found in cornflake/serializers.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 to_internal_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_internal_value(self, data):
                if isinstance(data, dict) or isinstance(data, bool):
                    self.fail('invalid')
        
                if isinstance(data, list):
        Severity: Minor
        Found in cornflake/fields.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 _flatten has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _flatten(errors, path=None):
                flattened_errors = []
        
                if path is None:
                    path = tuple()
        Severity: Minor
        Found in cornflake/exceptions.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 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, items, key_field=None, key_name='key', value_name='value', **kwargs):
        Severity: Minor
        Found in cornflake/fields.py - About 35 mins to fix

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

              def __init__(self, instance=None, data=None, partial=False, **kwargs):
                  meta = getattr(self, 'Meta', None)
          
                  if meta is not None:
                      default_validators = getattr(meta, 'validators', None)
          Severity: Minor
          Found in cornflake/serializers.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 run_validators_on_serializer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def run_validators_on_serializer(self, data, validators):
                  try:
                      for validator in validators:
                          if hasattr(validator, 'set_context'):
                              validator.set_context(self)
          Severity: Minor
          Found in cornflake/serializers.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,
                      source=None, field_name=None,
                      read_only=False, write_only=False,
                      required=None, default=None, default_empty=empty,
          Severity: Minor
          Found in cornflake/fields.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 to_representation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_representation(self, instance):
                  data = {}
          
                  for field in self.readable_fields:
                      try:
          Severity: Minor
          Found in cornflake/serializers.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 after has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def after(min_dt, dt_format=HUMAN_DATE_FORMAT):
              if is_date(min_dt):
                  min_dt = date_to_datetime(min_dt)
          
              def after_f(value):
          Severity: Minor
          Found in cornflake/validators.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 to_internal_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_internal_value(self, data):
                  if not isinstance(data, list):
                      self.fail('not_a_list')
          
                  values = []
          Severity: Minor
          Found in cornflake/serializers.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 to_internal_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_internal_value(self, data):
                  if isinstance(data, datetime):
                      self.fail('datetime')
                  elif isinstance(data, date):
                      # Already a date
          Severity: Minor
          Found in cornflake/fields.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 before has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def before(max_dt, dt_format=HUMAN_DATE_FORMAT):
              if is_date(max_dt):
                  max_dt = date_to_datetime(max_dt)
          
              def before_f(value):
          Severity: Minor
          Found in cornflake/validators.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 to_internal_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_internal_value(self, data):
                  if not isinstance(data, list):
                      self.fail('not_a_list')
          
                  values = []
          Severity: Minor
          Found in cornflake/fields.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

          Severity
          Category
          Status
          Source
          Language