davidlatwe/MontyDB

View on GitHub

Showing 181 of 188 total issues

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

def _index_document(index_list):
    """Helper to generate an index specifying document.

    Takes a list of (key, direction) pairs.
    """
Severity: Minor
Found in montydb/base.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

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

    def find(self,
             filter=None,
             projection=None,
             sort=None):
        """Return a filtered MontyList()
Severity: Minor
Found in montydb/utils/mt_list.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

Avoid deeply nested control flow statements.
Open

                        if value is not _no_val:
                            new_doc[field] = value
                else:
Severity: Major
Found in montydb/engine/project.py - About 45 mins to fix

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

    def parse_max(field, value, array_filters):
        @keep(value)
        def _max(fieldwalker):
            def evaluator(node, max_val):
                old_val = node.value
    Severity: Minor
    Found in montydb/engine/update.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

        def __eq__(self, other):
            if isinstance(other, self.__class__):
                return self.address == other.address
            return NotImplemented
    Severity: Minor
    Found in montydb/client.py and 1 other location - About 40 mins to fix
    montydb/types/objectid.py on lines 282..285

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

    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 __eq__(self, other):
            if isinstance(other, self._objectId_types):
                return self.__id == other.binary
            return NotImplemented
    Severity: Minor
    Found in montydb/types/objectid.py and 1 other location - About 40 mins to fix
    montydb/client.py on lines 54..57

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

    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 spawn has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def spawn(self, value, field, located=False, exists=True, in_array=False):
    Severity: Minor
    Found in montydb/engine/field_walker.py - About 35 mins to fix

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

      def _update(fieldwalker, field, value, evaluator, array_filters):
      Severity: Minor
      Found in montydb/engine/update.py - About 35 mins to fix

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

            def wconcern_parser(self,
        Severity: Minor
        Found in montydb/storage/sqlite.py - About 35 mins to fix

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

              def document_encode(cls, doc, check_keys=False, *args, **kwargs):
          Severity: Minor
          Found in montydb/types/_nobson.py - About 35 mins to fix

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

            def set_storage(
            Severity: Minor
            Found in montydb/configure.py - About 35 mins to fix

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

                  def insert_many(
              Severity: Minor
              Found in montydb/collection.py - About 35 mins to fix

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

                    def document_decode(cls, serialized, codec_options=None, *args, **kwargs):
                Severity: Minor
                Found in montydb/types/_nobson.py - About 35 mins to fix

                  Function parser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def parser(self, spec):
                          """Top-level parser"""
                  
                          # Implementation of implicitly $and operation, fundamental query
                          # container.
                  Severity: Minor
                  Found in montydb/engine/queries.py - About 35 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_matched has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_matched(self, position_path=None):
                          for path, node in self.matched.items():
                              if position_path is None or path.startswith(position_path + "."):
                                  matched = node
                                  break
                  Severity: Minor
                  Found in montydb/engine/field_walker.py - About 35 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 provide_storage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def provide_storage(repository):
                      """Internal function to get storage engine class from config
                  
                      Args:
                          repository (str): A dir path for database to live on disk.
                  Severity: Minor
                  Found in montydb/configure.py - About 35 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 parse_logic has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def parse_logic(self, theme):
                          """Logical operator parser (un-themed)"""
                  
                          def _parse_logic(sub_spec):
                              """Themed logical operator"""
                  Severity: Minor
                  Found in montydb/engine/queries.py - About 35 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

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

                                  if id not in documents[col]:
                                      documents[col][id] = doc
                  Severity: Minor
                  Found in montydb/utils/io.py and 1 other location - About 35 mins to fix
                  montydb/utils/io.py on lines 337..338

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

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

                      def _parse_elemMatch(self, sub_spec):
                          # $elemMatch only available in field-level
                          if not is_duckument_type(sub_spec):
                              raise OperationFailure("$elemMatch needs an Object")
                  
                  
                  Severity: Minor
                  Found in montydb/engine/queries.py - About 35 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 object_hook has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def object_hook(cls, obj, opts=DEFAULT_CODEC_OPTIONS):
                          if "$oid" in obj:
                              return cls.ObjectId(obj["$oid"])
                          if "$binary" in obj:
                              return base64.b64decode(obj["$binary"]["base64"])
                  Severity: Minor
                  Found in montydb/types/_nobson.py - About 35 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

                  Severity
                  Category
                  Status
                  Source
                  Language