pydanny/django-mongonaut

View on GitHub

Showing 44 of 44 total issues

Function attachButtonEmbedded has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function attachButtonEmbedded(inputs) {
    /* Used to place the add button on the page.  Upon each click it
       copies the previous input and increments the id and name by using
       the addInputFromPrevious function. */
    var finalInput = null;
Severity: Minor
Found in mongonaut/templates/mongonaut/includes/list_add.js - About 1 hr to fix

    Function get_qset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_qset(self, queryset, q):
            """Performs filtering against the default queryset returned by
                mongoengine.
            """
            if self.mongoadmin.search_fields and q:
    Severity: Minor
    Found in mongonaut/views.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 process_document has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_document(self, document, form_key, passed_key):
            """
            Given the form_key will evaluate the document and set values correctly for
            the document given.
            """
    Severity: Minor
    Found in mongonaut/mixins.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 create_doc_dict has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_doc_dict(self, document, doc_key=None, owner_document=None):
            """
            Generate a dictionary representation of the document.  (no recursion)
    
            DO NOT CALL DIRECTLY
    Severity: Minor
    Found in mongonaut/forms/forms.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 addInputFromPrevious has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    function addInputFromPrevious(input, embeddedDoc){
        /* This is a fuction to insert an input after an existing
            input.  It will correclty update the id and name so the
            input can be posted as desired.
    
    
    Severity: Minor
    Found in mongonaut/templates/mongonaut/includes/list_add.js - 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

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

    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'handlers': {
            'mail_admins': {
    Severity: Major
    Found in examples/blog/settings.py and 1 other location - About 1 hr to fix
    examples/blog_1_7/blog_1_7/settings.py on lines 117..130

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

    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

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

    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'handlers': {
            'mail_admins': {
    Severity: Major
    Found in examples/blog_1_7/blog_1_7/settings.py and 1 other location - About 1 hr to fix
    examples/blog/settings.py on lines 124..137

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

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

        def set_post_data(self):
            """
                Need to set form data so that validation on all post data occurs and
                places newly entered form data on the form object.
            """
    Severity: Minor
    Found in mongonaut/forms/forms.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 set_mongoadmin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_mongoadmin(self):
            """ Returns the MongoAdmin object for an app_label/document_name style view
            """
            if hasattr(self, "mongoadmin"):
                return None
    Severity: Minor
    Found in mongonaut/mixins.py - About 55 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_widget has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_widget(model_field, disabled=False):
        """Choose which widget to display for a field."""
    
        attrs = get_attrs(model_field, disabled)
    
    
    Severity: Minor
    Found in mongonaut/forms/widgets.py - About 55 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_form_field_dict has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_form_field_dict(self, model_dict):
            """
            Takes a model dictionary representation and creates a dictionary
            keyed by form field.  Each value is a  keyed 4 tuple of:
            (widget, mode_field_instance, model_field_type, field_key)
    Severity: Minor
    Found in mongonaut/forms/form_mixins.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

                if isinstance(self.document._fields[key], EmbeddedDocumentField):
                    context['embedded_documents'].append(key)
                    continue
    Severity: Minor
    Found in mongonaut/views.py and 1 other location - About 45 mins to fix
    mongonaut/views.py on lines 220..222

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

    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 deeply nested control flow statements.
    Open

                            if field_type != EmbeddedDocumentField:
                                field_value.widget.attrs['class'] += ' listField {0}'.format(form_key)
                            set_list_class = True
    Severity: Major
    Found in mongonaut/forms/form_mixins.py - About 45 mins to fix

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

                  if isinstance(self.document._fields[key], ListField):
                      context['list_fields'].append(key)
                      continue
      Severity: Minor
      Found in mongonaut/views.py and 1 other location - About 45 mins to fix
      mongonaut/views.py on lines 217..219

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

      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

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

      Severity: Minor
      Found in examples/blog/urls.py and 1 other location - About 45 mins to fix
      examples/blog_1_7/blog_1_7/urls.py on lines 0..5

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

      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

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

      Severity: Minor
      Found in examples/blog_1_7/blog_1_7/urls.py and 1 other location - About 45 mins to fix
      examples/blog/urls.py on lines 0..6

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

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

          def set_list_field(self, document, form_key, current_key, remaining_key, key_array_digit):
      Severity: Minor
      Found in mongonaut/mixins.py - About 35 mins to fix

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

            def create_document_dictionary(self, document, document_key=None,
                                                                owner_document=None):
                """
                Given document generates a dictionary representation of the document.
                Includes the widget for each for each field in the document.
        Severity: Minor
        Found in mongonaut/forms/forms.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 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
            Severity
            Category
            Status
            Source
            Language