davidlatwe/MontyDB

View on GitHub
montydb/types/_nobson.py

Summary

Maintainability
B
6 hrs
Test Coverage

Function document_encode has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def document_encode(cls, doc, check_keys=False, *args, **kwargs):
        _encoder = cls.BSONEncoder()
        _key_sep = _encoder.key_separator
        candidate = serialized = ""
        for s in _encoder.iterencode(doc):
Severity: Minor
Found in montydb/types/_nobson.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 default has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def default(self, obj):
            self.key_is_keyword = True

            if isinstance(obj, NoBSON.ObjectId):
                return {"$oid": str(obj)}
Severity: Minor
Found in montydb/types/_nobson.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 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 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 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

      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 cls.custom_json_hooks[key](obj, opts)
        Severity: Major
        Found in montydb/types/_nobson.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return obj
          Severity: Major
          Found in montydb/types/_nobson.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

              There are no issues that match your filters.

              Category
              Status