pydanny/django-mongonaut

View on GitHub

Showing 26 of 44 total issues

Avoid too many return statements within this function.
Open

        return forms.TextInput(attrs=attrs)
Severity: Major
Found in mongonaut/forms/widgets.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return None
    Severity: Major
    Found in mongonaut/forms/widgets.py - About 30 mins to fix

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

          def get_mongoadmins(self):
              """ Returns a list of all mongoadmin implementations for the site """
              apps = []
              for app_name in settings.INSTALLED_APPS:
                  mongoadmin = "{0}.mongoadmin".format(app_name)
      Severity: Minor
      Found in mongonaut/mixins.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 get_queryset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_queryset(self):
              """Replicates Django CBV `get_queryset()` method, but for MongoEngine.
              """
              if hasattr(self, "queryset") and self.queryset:
                  return self.queryset
      Severity: Minor
      Found in mongonaut/views.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def post(self, request, *args, **kwargs):
              """Creates new mongoengine records."""
              # TODO - make sure to check the rights of the poster
              #self.get_queryset() # TODO - write something that grabs the document class better
              form_class = self.get_form_class()
      Severity: Minor
      Found in mongonaut/views.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 has_digit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def has_digit(string_or_list, sep="_"):
          """
          Given a string or a list will return true if the last word or
          element is a digit.  sep is used when a string is given to know
          what separates one word from another.
      Severity: Minor
      Found in mongonaut/forms/form_utils.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