dgk/django-business-logic

View on GitHub

Showing 18 of 213 total issues

BlocklyXmlParser has 35 functions (exceeds 20 allowed). Consider refactoring.
Open

class BlocklyXmlParser(object):

    def parse(self, xml_str):
        """
        :param xml_str: blockly native XML string
Severity: Minor
Found in business_logic/blockly/parse.py - About 4 hrs to fix

Function execute has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def execute(self, context=None, **kwargs):
        """
        Main function for program execution

        Args:
Severity: Minor
Found in business_logic/models/program.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

File node.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

from __future__ import unicode_literals, print_function

import sys
Severity: Minor
Found in business_logic/models/node.py - About 2 hrs to fix

Function interpret has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def interpret(self, ctx):
        """
        Interprets the held code.

        Args:
Severity: Minor
Found in business_logic/models/node.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

File program.py has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from django.contrib.contenttypes.models import ContentType
Severity: Minor
Found in business_logic/models/program.py - About 2 hrs to fix

Function visit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def visit(self, node, parent_xml):
        content_object = node.content_object

        if content_object is None:
            last_xml = None
Severity: Minor
Found in business_logic/blockly/build.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 create_variable_definitions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def create_variable_definitions(self, data, external_variable_definitions=None):
        variable_definitions = []
        variable_by_name = {}

        if external_variable_definitions is not None:
Severity: Minor
Found in business_logic/blockly/create.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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def create(self, data, program_version=None):

        def is_block(__data):
            return 'content_type' not in __data['data']

Severity: Minor
Found in business_logic/blockly/create.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_representation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def to_representation(self, instance):
        representation = {}
        representation['name'] = instance.name

        argument = instance.program_argument
Severity: Minor
Found in business_logic/rest/serializers.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 visit_if_statement has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def visit_if_statement(self, node, parent_xml):
        children = self.get_children(node)
        block = etree.SubElement(parent_xml, 'block', type='controls_if')

        if len(children) > 2:
Severity: Minor
Found in business_logic/blockly/build.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 save has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
Severity: Minor
Found in business_logic/models/program.py - About 35 mins to fix

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

    def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
Severity: Minor
Found in business_logic/models/program.py - About 35 mins to fix

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

    def run_validation(self, data=serializers.empty):
        if data == '' or (self.trim_whitespace and six.text_type(data).strip() == ''):
            if not self.allow_blank:
                self.fail('blank')
            return ''
Severity: Minor
Found in business_logic/rest/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 clone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def clone(self):
        """
        Creates a clone of entire tree starting from self

        Returns:
Severity: Minor
Found in business_logic/models/node.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 current
Severity: Major
Found in business_logic/models/context.py - About 30 mins to fix

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

    def _process_next(self, node):
        children = []
        _node = node

        while True:
Severity: Minor
Found in business_logic/blockly/parse.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 _visit_children has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def _visit_children(self, node, data, children=None):
        if 'children' not in data:
            data['children'] = []
        for child in node.getchildren() if children is None else children:
            child_data = self.visit(child)
Severity: Minor
Found in business_logic/blockly/parse.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 get_variable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get_variable(self, variable_definition):
        """
        Get variable value in current context

        Args:
Severity: Minor
Found in business_logic/models/context.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