davidlatwe/MontyDB

View on GitHub

Showing 181 of 188 total issues

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

def find_storage_cls(storage_name):
    """Internal function to find storage engine class

    This function use `importlib.import_module` to find storage module by
    module name. And then it will try to find if there is a class that is
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_size has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def parse_size(query):
    if isinstance(query, float):
        raise OperationFailure("$size must be a whole number")
    if not isinstance(query, int):
        raise OperationFailure("$size needs a number")
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 325..326

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

Avoid too many return statements within this function.
Open

                return cls.custom_json_hooks[key](obj, opts)
Severity: Major
Found in montydb/types/_nobson.py - About 30 mins to fix

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

        def collection_drop(self, col_name):
            if self.collection_exists(col_name):
                os.remove(self._col_path(col_name))
    Severity: Minor
    Found in montydb/storage/sqlite.py and 1 other location - About 30 mins to fix
    montydb/storage/lightning.py on lines 159..161

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

    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

    Avoid too many return statements within this function.
    Open

            return obj
    Severity: Major
    Found in montydb/types/_nobson.py - About 30 mins to fix

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

          def collection_drop(self, col_name):
              if self.collection_exists(col_name):
                  os.remove(self._col_path(col_name))
      Severity: Minor
      Found in montydb/storage/lightning.py and 1 other location - About 30 mins to fix
      montydb/storage/sqlite.py on lines 321..323

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

      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

      Avoid too many return statements within this function.
      Open

              return None
      Severity: Major
      Found in montydb/engine/project.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return _no_val
        Severity: Major
        Found in montydb/engine/project.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return NoBSON.JSONEncoder.default(self, obj)
          Severity: Major
          Found in montydb/types/_nobson.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return True
            Severity: Major
            Found in montydb/engine/queries.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return obj.to_json()
              Severity: Major
              Found in montydb/types/_nobson.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return new_doc
                Severity: Major
                Found in montydb/engine/project.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return doc
                  Severity: Major
                  Found in montydb/engine/project.py - About 30 mins to fix

                    Function _validate_sort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _validate_sort(self, sort, int_only=False):
                            if is_integer_type(sort) or int_only:
                                if sort not in (1, -1):
                                    raise WriteError(
                                        "The $sort element value must be either 1 or -1", code=2
                    Severity: Minor
                    Found in montydb/engine/update.py - About 25 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 update_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def update_one(
                            self,
                            filter,
                            update,
                            upsert=False,
                    Severity: Minor
                    Found in montydb/collection.py - About 25 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 read_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def read_array(self, node, field):
                            new_nodes = list()
                            doc = node.value
                    
                            for i, elem in enumerate(doc):
                    Severity: Minor
                    Found in montydb/engine/field_walker.py - About 25 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 on_err_close has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def on_err_close(generator):
                        """Decorator, to close `generator` passed into the function on error
                    
                        Ensure the `generator` which holds the storage database connection to
                        close that connection right on error occurred and then raise the error.
                    Severity: Minor
                    Found in montydb/types/helper.py - About 25 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 insert_many has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def insert_many(
                            self, documents, ordered=True, bypass_document_validation=False, *args, **kwargs
                        ):
                            """ """
                            if not isinstance(documents, abc.Iterable) or not documents:
                    Severity: Minor
                    Found in montydb/collection.py - About 25 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 re_int_flag_to_str has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def re_int_flag_to_str(int_flags):
                        """Ripped from bson.json_util"""
                        flags = ""
                        if int_flags & re.IGNORECASE:
                            flags += "i"
                    Severity: Minor
                    Found in montydb/types/helper.py - About 25 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