emory-libraries/eulexistdb

View on GitHub

Showing 58 of 58 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            xpath_str = '%(left)s%(op)s%(right)s' % {
                    'op': parsed_xpath.op,
                    'left': self.prep_xpath(parsed_xpath.left, context=context),
                    'right': self.prep_xpath(parsed_xpath.right, context=context),
Severity: Major
Found in eulexistdb/query.py and 1 other location - About 1 hr to fix
eulexistdb/query.py on lines 1352..1355

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    xpath_str = '%(left)s%(op)s%(right)s' % {
                        'op': arg.op,
                        'left': self.prep_xpath(arg.left, context=context),
                        'right': self.prep_xpath(arg.right, context=context),
Severity: Major
Found in eulexistdb/query.py and 1 other location - About 1 hr to fix
eulexistdb/query.py on lines 1316..1319

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def query(self, xquery=None, start=1, how_many=10, cache=False, session=None,
        release=None, result_type=None):
        """Execute an XQuery query, returning the results directly.

        :param xquery: a string XQuery query
Severity: Minor
Found in eulexistdb/db.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def return_also(self, fields, raw=False):
        """Return additional specified fields.  See :meth:`return_only` for
        syntax of xpaths in raw mode.

        Not compatible with :meth:`return_only`.
Severity: Major
Found in eulexistdb/query.py and 1 other location - About 1 hr to fix
eulexistdb/query.py on lines 1172..1187

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 43.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def return_only(self, fields, raw=False):
        """Only return the specified fields.

        When specifying xpaths in raw mode, use ``%(xq_var)s`` if some portion
        of the xpath should be made relative to the main xquery variable.  To
Severity: Major
Found in eulexistdb/query.py and 1 other location - About 1 hr to fix
eulexistdb/query.py on lines 1189..1200

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 43.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function set_limits has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def set_limits(self, low=None, high=None):
        """
        Adjusts the limits on the results to be retrieved.

        Any limits passed in here are applied relative to the existing
Severity: Minor
Found in eulexistdb/query.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 _store_xquery_info has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _store_xquery_info(self, sender, name=None, time_taken=0,
Severity: Major
Found in eulexistdb/debug_panel.py - About 1 hr to fix

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

        def __init__(self, server_url=None, username=None, password=None,
    Severity: Major
    Found in eulexistdb/db.py - About 1 hr to fix

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

          def __getitem__(self, k):
              """Return a single result or slice of results from the query."""
              if not isinstance(k, (slice, int, long)):
                  raise TypeError
      
      
      Severity: Minor
      Found in eulexistdb/query.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 query has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def query(self, xquery=None, start=1, how_many=10, cache=False, session=None,
      Severity: Major
      Found in eulexistdb/db.py - About 50 mins to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                elif self.collection is not None:
                    # if a collection is specified, add it it to the top-level query xpath
                    # -- prep_xpath handles logic for top-level xpath with multiple components, e.g. foo|bar
                    collection_xquery = 'collection("/db/%s")' % self.collection
                    xpath_parts.append(self.prep_xpath(self.xpath, context=collection_xquery))
        Severity: Minor
        Found in eulexistdb/query.py and 1 other location - About 45 mins to fix
        eulexistdb/query.py on lines 909..913

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            def __init__(self, model=None, xpath=None, using=None, collection=None,
        Severity: Minor
        Found in eulexistdb/query.py - About 45 mins to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      if 'files' in self.exist_fixtures:
                          for filename in self.exist_fixtures['files']:
                              self._remove_file_from_exist(filename)
          Severity: Minor
          Found in eulexistdb/testutil.py and 1 other location - About 45 mins to fix
          eulexistdb/testutil.py on lines 102..104

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  if self.document is not None:
                      # if a document is specified, add it it to the top-level query xpath
                      # -- document takes precedence over collection
                      document_xquery = 'doc("%s")' % self.document
                      xpath_parts.append(self.prep_xpath(self.xpath, context=document_xquery))
          Severity: Minor
          Found in eulexistdb/query.py and 1 other location - About 45 mins to fix
          eulexistdb/query.py on lines 915..919

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function _return_field_xpath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def _return_field_xpath(self, xpath):
                  if isinstance(xpath, ast.Step):
                      # FIXME: should predicates be removed here?
                      # field[x] should be sufficient to identify return node, and predicates may not match
                      return "field[%d]/%s" % (self._return_field_count, serialize(xpath))
          Severity: Minor
          Found in eulexistdb/query.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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      if 'files' in self.exist_fixtures:
                          for filename in self.exist_fixtures['files']:
                              self._load_file_to_exist(filename)
          Severity: Minor
          Found in eulexistdb/testutil.py and 1 other location - About 45 mins to fix
          eulexistdb/testutil.py on lines 116..118

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Consider simplifying this complex logical expression.
          Open

                  if self.order_by or self.return_fields or self.additional_return_fields \
                     or self.where_filters or (self.ft_query and self.fulltext_options):
          
                      # some let statements must come at the beginning of a FLOWR query
                      if self.ft_query and self.fulltext_options:
          Severity: Major
          Found in eulexistdb/query.py - About 40 mins to fix

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

                def __init__(self, timeout=ExistDB.DEFAULT_TIMEOUT, session=None,
            Severity: Minor
            Found in eulexistdb/db.py - About 35 mins to fix

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

              def _wrap(begin, text, parts, end, tail):
              Severity: Minor
              Found in eulexistdb/templatetags/existdb.py - About 35 mins to fix

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

                    def __init__(self, xpath=None, collection=None, document=None,
                Severity: Minor
                Found in eulexistdb/query.py - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language