emory-libraries/eulxml

View on GitHub

Showing 71 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

      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

          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

          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

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

          def _remove_xml(xast, node, context, if_empty=False):
              '''Remove a node or attribute.  For multipart XPaths that are
              constructible by :mod:`eulxml.xmlmap`, the corresponding nodes
              will be removed if they are empty (other than predicates specified
              in the XPath).
          Severity: Minor
          Found in eulxml/xmlmap/fields.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 xmlobject_to_dict has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          def xmlobject_to_dict(instance, fields=None, exclude=None, prefix=''):
              """
              Generate a dictionary based on the data in an XmlObject instance to pass as
              a Form's ``initial`` keyword argument.
          
          
          Severity: Minor
          Found in eulxml/forms/xmlobject.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 update_instance has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_instance(self):
                  for form in getattr(self, 'deleted_forms', []):
                      # update_instance may be called multiple times - instance can only
                      # be removed the first time, so don't consider it an error if it's not present
                      if form.instance in self.instances:
          Severity: Minor
          Found in eulxml/forms/xmlobject.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 from_email_message has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              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
                  id is specified, it will be stored in the Message <LocalId>.
          Severity: Minor
          Found in eulxml/xmlmap/cerp.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 mods.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

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

            def _set_in_xml(node, val, context, step):
            
                # node could be either an element or an attribute
                if isinstance(node, etree._Element): # if it's an element
                    if isinstance(val, etree._Element):
            Severity: Minor
            Found in eulxml/xmlmap/fields.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

            NodeList has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class NodeList(object):
                """Custom List-like object to handle ListFields like :class:`IntegerListField`,
                :class:`StringListField`, and :class:`NodeListField`, which allows for getting,
                setting, and deleting list members.  :class:`NodeList` should **not** be
                initialized directly, but instead should only be accessed as the return type
            Severity: Minor
            Found in eulxml/xmlmap/fields.py - About 2 hrs to fix

              File cerp.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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