davidlatwe/MontyDB

View on GitHub

Showing 181 of 188 total issues

Function inclusion has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

def inclusion(fieldwalker, positioned, located_match, init_doc):
    _doc_type = fieldwalker.doc_type

    def _inclusion(node, init_doc=None):
        doc = node.value
Severity: Minor
Found in montydb/engine/project.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 parser has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

    def parser(self, spec, qfilter):
        """ """
        self.array_op_type = self.ARRAY_OP_NORMAL

        for key, val in spec.items():
Severity: Minor
Found in montydb/engine/project.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 queries.py has 671 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re
from copy import deepcopy
from datetime import datetime
from collections.abc import Mapping

Severity: Major
Found in montydb/engine/queries.py - About 1 day to fix

    File field_walker.py has 650 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class _NoVal(object):
        def __repr__(self):
            return "_NoVal()"
        __slots__ = ()
    
    
    Severity: Major
    Found in montydb/engine/field_walker.py - About 1 day to fix

      File update.py has 606 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from collections import OrderedDict
      from datetime import datetime
      
      from ..errors import WriteError
      
      
      Severity: Major
      Found in montydb/engine/update.py - About 1 day to fix

        Function exclusion has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
        Open

        def exclusion(fieldwalker, init_doc):
            _doc_type = fieldwalker.doc_type
        
            def _exclusion(node, init_doc=None):
                doc = node.value
        Severity: Minor
        Found in montydb/engine/project.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 extract has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
        Open

            def extract(self, visited_only=False):
                ON_DELETE = False
                if isinstance(self.handler, FieldTreeWriter):
                    ON_DELETE = self.handler.on_delete
        
        
        Severity: Minor
        Found in montydb/engine/field_walker.py - About 7 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 collection.py has 410 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import warnings
        from copy import deepcopy
        
        from .base import (
            BaseObject,
        Severity: Minor
        Found in montydb/collection.py - About 5 hrs to fix

          Function parse_all has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

          def parse_all(query):
          
              field_op_ls = set(QueryFilter({}).field_ops.keys())
              field_op_ls.remove("$eq")
              field_op_ls.remove("$not")
          Severity: Minor
          Found in montydb/engine/queries.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 ordering has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

          def ordering(fieldwalkers, order, doc_type=None):
              """ """
              total = len(fieldwalkers)
              pre_sect_stack = []
          
          
          Severity: Minor
          Found in montydb/engine/queries.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 project.py has 356 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from ..errors import OperationFailure
          from .queries import QueryFilter
          from .field_walker import _no_val
          from ..types import (
              string_types,
          Severity: Minor
          Found in montydb/engine/project.py - About 4 hrs to fix

            File sqlite.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import os
            import shutil
            import sqlite3
            import contextlib
            from collections import OrderedDict
            Severity: Minor
            Found in montydb/storage/sqlite.py - About 4 hrs to fix

              Function parse_slice has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_slice(self, field_path, slicing):
                      def _slice(fieldwalker):
                          if "$" in field_path:
                              return
              
              
              Severity: Minor
              Found in montydb/engine/project.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 __call__ has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __call__(self, array):
                      new_array = (array or [])[:]
                      new_elems = self.mods["$each"][:]
              
                      position = self.mods["$position"]
              Severity: Minor
              Found in montydb/engine/update.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 parse_lte has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

              def parse_lte(query):
                  _dec_NaN_INF_ls = list(bson.decimal128_NaN_ls) + [bson.decimal128_INF]
              
                  @keep(query)
                  def _lte(fieldwalker):
              Severity: Minor
              Found in montydb/engine/queries.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

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

                          if node.exists and not is_numeric_type(old_val):
                              _id = fieldwalker.doc["_id"]
                              value_type = type(old_val).__name__
                              msg = (
                                  "Cannot apply $inc to a value of non-numeric type. "
              Severity: Major
              Found in montydb/engine/update.py and 1 other location - About 3 hrs to fix
              montydb/engine/update.py on lines 273..281

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

              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 node.exists and not is_numeric_type(old_val):
                              _id = fieldwalker.doc["_id"]
                              value_type = type(old_val).__name__
                              msg = (
                                  "Cannot apply $mul to a value of non-numeric type. "
              Severity: Major
              Found in montydb/engine/update.py and 1 other location - About 3 hrs to fix
              montydb/engine/update.py on lines 198..206

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

              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

                      for mod, value in spec.items():
                          try:
                              type_check = self.validators[mod]
                          except KeyError:
                              raise WriteError(
              Severity: Major
              Found in montydb/engine/update.py and 1 other location - About 3 hrs to fix
              montydb/engine/update.py on lines 670..676

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

              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

                      for mod, value in spec.items():
                          try:
                              type_check = self.validators[mod]
                          except KeyError:
                              raise WriteError("Unrecognized clause in $push: %s" % mod, code=2)
              Severity: Major
              Found in montydb/engine/update.py and 1 other location - About 3 hrs to fix
              montydb/engine/update.py on lines 624..633

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

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

              def _eq_match(fieldwalker, query):
                  """ """
                  if is_duckument_type(query):
                      for val in fieldwalker.value:
                          if is_duckument_type(val):
              Severity: Minor
              Found in montydb/engine/queries.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

              Severity
              Category
              Status
              Source
              Language