emory-libraries/eulexistdb

View on GitHub

Showing 58 of 58 total issues

File query.py has 1004 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    File db.py has 634 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

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

          def also(self, *fields):
              """Return additional data in results.
      
              :param fields: names of fields in the QuerySet's :attr:`model`
      
      
      Severity: Major
      Found in eulexistdb/query.py and 1 other location - About 1 day to fix
      eulexistdb/query.py on lines 339..376

      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 136.

      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 only(self, *fields):
              """Limit results to include only specified fields.
      
              :param fields: names of fields in the QuerySet's :attr:`model`
      
      
      Severity: Major
      Found in eulexistdb/query.py and 1 other location - About 1 day to fix
      eulexistdb/query.py on lines 378..406

      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 136.

      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 getQuery has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

          def getQuery(self):
              """
              Generate and return xquery based on configured filters, sorting, return fields.
              Returns xpath or FLOWR XQuery if required based on sorting and return
              """
      Severity: Minor
      Found in eulexistdb/query.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

      Function handle has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, *args, **options):
              if not len(args) or args[0] == 'help':
                  print self.help
                  return
      
      
      Severity: Minor
      Found in eulexistdb/management/commands/existdb.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 _create_return_class has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      def _create_return_class(baseclass, override_fields, xpath_prefix=None,
                               override_xpaths=None):
          """
          Define a new return class which extends the specified baseclass and
          overrides the specified fields.
      Severity: Minor
      Found in eulexistdb/query.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

      ExistDB has 31 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class ExistDB(object):
          """Connect to an eXist database, and manipulate and query it.
      
          Construction doesn't initiate server communication, only store
          information about where the server is, to be used in later
      Severity: Minor
      Found in eulexistdb/db.py - About 3 hrs to fix

        Function add_filter has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_filter(self, xpath, type, value, mode=None):
                """
                Add a filter to the xpath.  Takes xpath, type of filter, and value.
                Filter types currently implemented:
                 * contains
        Severity: Minor
        Found in eulexistdb/query.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 filter has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            def filter(self, combine='AND', **kwargs):
                """Filter the QuerySet to return a subset of the documents.
        
                Arguments take the form ``lookuptype`` or ``field__lookuptype``,
                where ``field`` is the name of a field in the QuerySet's :attr:`model`
        Severity: Minor
        Found in eulexistdb/query.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

        QuerySet has 29 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class QuerySet(object):
        
            """Lazy eXist database lookup for a set of objects.
        
            :param model: the type of object to return from :meth:`__getitem__`. If
        Severity: Minor
        Found in eulexistdb/query.py - About 3 hrs to fix

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

                  if high is not None:
                      if self.end is not None:
                          self.end = min(self.end, self.start + high)
                      else:
                          self.end = (self.start or 0) + high
          Severity: Major
          Found in eulexistdb/query.py and 1 other location - About 3 hrs to fix
          eulexistdb/query.py on lines 1281..1285

          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 65.

          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 low is not None:
                      if self.end is not None:
                          self.start = min(self.end, self.start + low)
                      else:
                          self.start = (self.start or 0) + low
          Severity: Major
          Found in eulexistdb/query.py and 1 other location - About 3 hrs to fix
          eulexistdb/query.py on lines 1276..1280

          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 65.

          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 a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, server_url=None, username=None, password=None,
                           resultType=None, encoding='UTF-8', verbose=False,
                           keep_alive=None, timeout=DEFAULT_TIMEOUT):
          
                  self.resultType = resultType or QueryResult
          Severity: Minor
          Found in eulexistdb/db.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 prep_xpath has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def prep_xpath(self, xpath, context=None, return_field=False):
                  """Prepare an xpath for use in an xquery.
          
                  :param xpath: xpath as string or parsed by :meth:`eulxml.xpath.parse`
                  :param context: optional context to add to xpaths; by default, the current
          Severity: Minor
          Found in eulexistdb/query.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

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

                      if 'directory' in self.exist_fixtures:
                          for filename in glob(path.join(self.exist_fixtures['directory'], '*.xml')):
                              self._load_file_to_exist(filename)
          Severity: Major
          Found in eulexistdb/testutil.py and 1 other location - About 1 hr to fix
          eulexistdb/testutil.py on lines 113..115

          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 46.

          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 'directory' in self.exist_fixtures:
                          for filename in glob(path.join(self.exist_fixtures['directory'], '*.xml')):
                              self._remove_file_from_exist(filename)
          Severity: Major
          Found in eulexistdb/testutil.py and 1 other location - About 1 hr to fix
          eulexistdb/testutil.py on lines 99..101

          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 46.

          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': 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

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

              def _fixture_setup(self):
                  if hasattr(self, 'exist_fixtures'):
                      db = ExistDB()
                      # load index
                      if 'index' in self.exist_fixtures:
          Severity: Minor
          Found in eulexistdb/testutil.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 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

          Severity
          Category
          Status
          Source
          Language