emory-libraries/eulxml

View on GitHub

Showing 192 of 192 total issues

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

# file eulxml/xmlmap/fields.py
#
#   Copyright 2010,2011 Emory University Libraries
#
#   Licensed under the Apache License, Version 2.0 (the "License");
Severity: Major
Found in eulxml/xmlmap/fields.py - About 2 days to fix

    Function formfields_for_xmlobject has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
    Open

    def formfields_for_xmlobject(model, fields=None, exclude=None, widgets=None, options=None,
            declared_subforms=None, max_num=None, extra=None):
        """
        Returns three sorted dictionaries (:class:`django.utils.datastructures.SortedDict`).
         * The first is a dictionary of form fields based on the
    Severity: Minor
    Found in eulxml/forms/xmlobject.py - About 1 day 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 xmlobject.py has 621 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # file eulxml/forms/xmlobject.py
    #
    #   Copyright 2010,2011 Emory University Libraries
    #
    #   Licensed under the Apache License, Version 2.0 (the "License");
    Severity: Major
    Found in eulxml/forms/xmlobject.py - About 1 day to fix

      Cyclomatic complexity is too high in function formfields_for_xmlobject. (59)
      Open

      def formfields_for_xmlobject(model, fields=None, exclude=None, widgets=None, options=None,
              declared_subforms=None, max_num=None, extra=None):
          """
          Returns three sorted dictionaries (:class:`django.utils.datastructures.SortedDict`).
           * The first is a dictionary of form fields based on the
      Severity: Minor
      Found in eulxml/forms/xmlobject.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      File core.py has 445 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # file eulxml/xmlmap/core.py
      #
      #   Copyright 2010,2011 Emory University Libraries
      #
      #   Licensed under the Apache License, Version 2.0 (the "License");
      Severity: Minor
      Found in eulxml/xmlmap/core.py - About 6 hrs to fix

        Function __new__ has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def __new__(cls, name, bases, defined_attrs):
                use_attrs = {}
                fields = {}
                recursive_fields = []
        
        
        Severity: Minor
        Found in eulxml/xmlmap/core.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 eadmap.py has 405 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # file eulxml/xmlmap/eadmap.py
        #
        #   Copyright 2010,2011 Emory University Libraries
        #
        #   Licensed under the Apache License, Version 2.0 (the "License");
        Severity: Minor
        Found in eulxml/xmlmap/eadmap.py - About 5 hrs to fix

          Function token has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

              def token(self):
                  tok = lex.Lexer.token(self)
                  if tok is not None:
                      if tok.type == 'STAR_OP':
                          if self.last is not None and self.last.type not in OPERATOR_FORCERS:
          Severity: Minor
          Found in eulxml/xpath/core.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

          Function _remove_predicates has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

          def _remove_predicates(xast, node, context):
              '''Remove any constructible predicates specified in the xpath
              relative to the specified node.
          
              :param xast: parsed xpath (xpath abstract syntax tree) from
          Severity: Minor
          Found in eulxml/xmlmap/fields.py - About 4 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 _predicate_is_constructible has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          def _predicate_is_constructible(pred):
              if isinstance(pred, ast.Step):
                  # only child and attribute for now
                  if pred.axis not in (None, 'child', '@', 'attribute'):
                      return False
          Severity: Minor
          Found in eulxml/xmlmap/fields.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 _create_xml_node has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          def _create_xml_node(xast, node, context, insert_index=None):
              if isinstance(xast, ast.Step):
                  if isinstance(xast.node_test, ast.NameTest):
                      # check the predicates (if any) to verify they're constructable
                      for pred in xast.predicates:
          Severity: Minor
          Found in eulxml/xmlmap/fields.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

          Cyclomatic complexity is too high in method __new__. (15)
          Open

              def __new__(cls, name, bases, defined_attrs):
                  use_attrs = {}
                  fields = {}
                  recursive_fields = []
          
          
          Severity: Minor
          Found in eulxml/xmlmap/core.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Function update_instance has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_instance(self):
                  """Save bound form data into the XmlObject model instance and return the
                  updated instance."""
          
                  # NOTE: django model form has a save method - not applicable here,
          Severity: Minor
          Found in eulxml/forms/xmlobject.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

          Cyclomatic complexity is too high in method update_instance. (14)
          Open

              def update_instance(self):
                  """Save bound form data into the XmlObject model instance and return the
                  updated instance."""
          
                  # NOTE: django model form has a save method - not applicable here,
          Severity: Minor
          Found in eulxml/forms/xmlobject.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Cyclomatic complexity is too high in method token. (13)
          Open

              def token(self):
                  tok = lex.Lexer.token(self)
                  if tok is not None:
                      if tok.type == 'STAR_OP':
                          if self.last is not None and self.last.type not in OPERATOR_FORCERS:
          Severity: Minor
          Found in eulxml/xpath/core.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Cyclomatic complexity is too high in method from_email_message. (13)
          Open

              @classmethod
              def from_email_message(cls, message, local_id=None):
                  '''
                  Convert an :class:`email.message.Message` or compatible message
                  object into a CERP XML :class:`eulxml.xmlmap.cerp.Message`. If an
          Severity: Minor
          Found in eulxml/xmlmap/cerp.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Cyclomatic complexity is too high in class Message. (13)
          Open

          class Message(_BaseMessage, _BaseExternal):
              """A single email message in a :class:`Folder`."""
          
              ROOT_NAME = 'Message'
              STATUS_FLAG_CHOICES = [ 'Seen', 'Answered', 'Flagged', 'Deleted',
          Severity: Minor
          Found in eulxml/xmlmap/cerp.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Cyclomatic complexity is too high in method xsl_transform. (13)
          Open

              def xsl_transform(self, filename=None, xsl=None, return_type=None, **params):
                  """Run an xslt transform on the contents of the XmlObject.
          
                  XSLT can be passed in as an XSLT object generated by :meth:`load_xslt`
                  or as filename or string. If a params dictionary is specified, its items
          Severity: Minor
          Found in eulxml/xmlmap/core.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

          Cyclomatic complexity is too high in function _predicate_is_constructible. (13)
          Open

          def _predicate_is_constructible(pred):
              if isinstance(pred, ast.Step):
                  # only child and attribute for now
                  if pred.axis not in (None, 'child', '@', 'attribute'):
                      return False
          Severity: Minor
          Found in eulxml/xmlmap/fields.py by radon

          Cyclomatic Complexity

          Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

          Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

          Construct Effect on CC Reasoning
          if +1 An if statement is a single decision.
          elif +1 The elif statement adds another decision.
          else +0 The else statement does not cause a new decision. The decision is at the if.
          for +1 There is a decision at the start of the loop.
          while +1 There is a decision at the while statement.
          except +1 Each except branch adds a new conditional path of execution.
          finally +0 The finally block is unconditionally executed.
          with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
          assert +1 The assert statement internally roughly equals a conditional statement.
          Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
          Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

          Source: http://radon.readthedocs.org/en/latest/intro.html

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

              def xsl_transform(self, filename=None, xsl=None, return_type=None, **params):
                  """Run an xslt transform on the contents of the XmlObject.
          
                  XSLT can be passed in as an XSLT object generated by :meth:`load_xslt`
                  or as filename or string. If a params dictionary is specified, its items
          Severity: Minor
          Found in eulxml/xmlmap/core.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

          Severity
          Category
          Status
          Source
          Language