emory-libraries/eulxml

View on GitHub

Showing 71 of 192 total issues

Function _construct_predicate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def _construct_predicate(xast, node, context):
    if isinstance(xast, ast.Step):
        return _create_xml_node(xast, node, context)
    elif isinstance(xast, ast.BinaryExpression):
        if xast.op == '/':
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 __new__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def __new__(cls, name, bases, attrs):
        # let django do all the work of finding declared/inherited fields
        fields = [(field_name, attrs.pop(field_name)) for field_name, obj in list(six.iteritems(attrs)) if isinstance(obj, Field)]
        for base in bases[::-1]:
                if hasattr(base, 'declared_fields'):
Severity: Minor
Found in eulxml/forms/xmlobject.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_subforms has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _init_subforms(self, data=None, prefix=None):
        # initialize each subform class with the appropriate model instance and data
        self.subforms = SortedDict()    # create as sorted dictionary to preserve order
        for name, subform in six.iteritems(self.__class__.subforms):
            # instantiate the new form with the current field as instance, if available
Severity: Minor
Found in eulxml/forms/xmlobject.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 xmlobjectform_factory has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

def xmlobjectform_factory(model, form=XmlObjectForm, fields=None, exclude=None,
Severity: Major
Found in eulxml/forms/xmlobject.py - About 1 hr to fix

    Function _serialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _serialize(self):
            if self.prefix:
                yield self.prefix
                yield ':'
            yield self.name
    Severity: Minor
    Found in eulxml/xpath/ast.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 is_valid has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def is_valid(self):
            """Returns True if this form and all subforms (if any) are valid.
    
            If all standard form-validation tests pass, uses :class:`~eulxml.xmlmap.XmlObject`
            validation methods to check for schema-validity (if a schema is associated)
    Severity: Minor
    Found in eulxml/forms/xmlobject.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 formfields_for_xmlobject has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def formfields_for_xmlobject(model, fields=None, exclude=None, widgets=None, options=None,
    Severity: Major
    Found in eulxml/forms/xmlobject.py - About 1 hr to fix

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

          def to_python(self, node):
              if node is None:
                  return None
              if isinstance(node, six.string_types):
                  rep = node
      Severity: Minor
      Found in eulxml/xmlmap/fields.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_python has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_python(self, node):
              # handle node not present in xml first
              if node is None:
                  # if false is configured as None, then missing node is False
                  if self.false is None:
      Severity: Minor
      Found in eulxml/xmlmap/fields.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 set has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def set(self, xpath, xast, node, context, mapper, value):
              xvalue = mapper.to_xml(value)
              match = _find_xml_node(xpath, node, context)
      
              if xvalue is None:
      Severity: Minor
      Found in eulxml/xmlmap/fields.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 generate_catalog has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def generate_catalog(xsd_schemas=None, xmlcatalog_dir=None, xmlcatalog_file=None):
          """Generating an XML catalog for use in resolving schemas
      
          Creates the XML Catalog directory if it doesn't already exist.
          Uses :meth:`download_schema` to save local copies of schemas,
      Severity: Minor
      Found in eulxml/catalog.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 dcmi_types has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def dcmi_types(self):
                  '''DCMI Type Vocabulary (recommended), as documented at
                  http://dublincore.org/documents/dcmi-type-vocabulary/'''
                  if self._dcmi_types is None:
                      # generate a list of DCMI types based on the RDF dctype document
      Severity: Minor
      Found in eulxml/xmlmap/dc.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 _get_xmlparser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def _get_xmlparser(xmlclass=XmlObject, validate=False, resolver=None):
          """Initialize an instance of :class:`lxml.etree.XMLParser` with appropriate
          settings for validation.  If validation is requested and the specified
          instance of :class:`XmlObject` has an XSD_SCHEMA defined, that will be used.
          Otherwise, uses DTD validation. Switched resolver to None to skip validation.
      Severity: Minor
      Found in eulxml/xmlmap/core.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 _collect_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def _collect_fields(field_parts_list, include_parents):
          """utility function to enable recursion in _parse_field_list()"""
          fields = []
          subpart_lists = defaultdict(list)
      
      
      Severity: Minor
      Found in eulxml/forms/xmlobject.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 _html_output has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _html_output(self, normal_row, error_row, row_ender,  help_text_html, errors_on_separate_row):
              """Extend BaseForm's helper function for outputting HTML. Used by as_table(), as_ul(), as_p().
      
              Combines the HTML version of the main form's fields with the HTML content
              for any subforms.
      Severity: Minor
      Found in eulxml/forms/xmlobject.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, formclass=None, label=None, can_delete=True, can_order=False,
      Severity: Minor
      Found in eulxml/forms/xmlobject.py - About 45 mins to fix

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

            def __init__(self, xpath, manager, mapper, required=None, verbose_name=None,
        Severity: Minor
        Found in eulxml/xmlmap/fields.py - About 45 mins to fix

          Function set has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def set(self, xpath, xast, node, context, mapper, value):
          Severity: Minor
          Found in eulxml/xmlmap/fields.py - About 45 mins to fix

            Function set has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def set(self, xpath, xast, node, context, mapper, value):
            Severity: Minor
            Found in eulxml/xmlmap/fields.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if pred.left.axis in ('@', 'attribute'):
                                      if _remove_attribute_node(node, context, pred.left):
                                          # remove from the xast
                                          xast_c.predicates.remove(pred)
                                  elif pred.left.axis in (None, 'child'):
              Severity: Major
              Found in eulxml/xmlmap/fields.py - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language