django/django

View on GitHub
django/contrib/admin/static/admin/js/inlines.js

Summary

Maintainability
F
4 days
Test Coverage

Function formset has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    $.fn.formset = function(opts) {
        const options = $.extend({}, $.fn.formset.defaults, opts);
        const $this = $(this);
        const $parent = $this.parent();
        const updateElementIndex = function(el, prefix, ndx) {
Severity: Minor
Found in django/contrib/admin/static/admin/js/inlines.js - About 6 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 formset has 129 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    $.fn.formset = function(opts) {
        const options = $.extend({}, $.fn.formset.defaults, opts);
        const $this = $(this);
        const $parent = $this.parent();
        const updateElementIndex = function(el, prefix, ndx) {
Severity: Major
Found in django/contrib/admin/static/admin/js/inlines.js - About 5 hrs to fix

    File inlines.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*global DateTimeShortcuts, SelectFilter*/
    /**
     * Django admin inlines
     *
     * Based on jQuery Formset 1.1
    Severity: Minor
    Found in django/contrib/admin/static/admin/js/inlines.js - About 2 hrs to fix

      Function stackedFormset has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $.fn.stackedFormset = function(selector, options) {
              const $rows = $(this);
              const updateInlineLabel = function(row) {
                  $(selector).find(".inline_label").each(function(i) {
                      const count = i + 1;
      Severity: Major
      Found in django/contrib/admin/static/admin/js/inlines.js - About 2 hrs to fix

        Function tabularFormset has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            $.fn.tabularFormset = function(selector, options) {
                const $rows = $(this);
        
                const reinitDateTimeShortCuts = function() {
                    // Reinitialize the calendar and clock widgets by force
        Severity: Minor
        Found in django/contrib/admin/static/admin/js/inlines.js - About 1 hr to fix

          Function inlineDeleteHandler has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  const inlineDeleteHandler = function(e1) {
                      e1.preventDefault();
                      const deleteButton = $(e1.target);
                      const row = deleteButton.closest('.' + options.formCssClass);
                      const inlineGroup = row.closest('.inline-group');
          Severity: Minor
          Found in django/contrib/admin/static/admin/js/inlines.js - About 1 hr to fix

            Function addInlineClickHandler has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    const addInlineClickHandler = function(e) {
                        e.preventDefault();
                        const template = $("#" + options.prefix + "-empty");
                        const row = template.clone(true);
                        row.removeClass(options.emptyCssClass)
            Severity: Minor
            Found in django/contrib/admin/static/admin/js/inlines.js - About 1 hr to fix

              Function tabularFormset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  $.fn.tabularFormset = function(selector, options) {
                      const $rows = $(this);
              
                      const reinitDateTimeShortCuts = function() {
                          // Reinitialize the calendar and clock widgets by force
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js - 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 stackedFormset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  $.fn.stackedFormset = function(selector, options) {
                      const $rows = $(this);
                      const updateInlineLabel = function(row) {
                          $(selector).find(".inline_label").each(function(i) {
                              const count = i + 1;
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js - 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

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

                          if (typeof SelectFilter !== 'undefined') {
                              $('.selectfilter').each(function(index, value) {
                                  SelectFilter.init(value.id, this.dataset.fieldName, false);
                              });
                              $('.selectfilterstacked').each(function(index, value) {
              Severity: Major
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 3 hrs to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 291..298

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

              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 (typeof SelectFilter !== "undefined") {
                              $(".selectfilter").each(function(index, value) {
                                  SelectFilter.init(value.id, this.dataset.fieldName, false);
                              });
                              $(".selectfilterstacked").each(function(index, value) {
              Severity: Major
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 3 hrs to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 228..235

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

              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

                      const reinitDateTimeShortCuts = function() {
                          // Reinitialize the calendar and clock widgets by force, yuck.
                          if (typeof DateTimeShortcuts !== "undefined") {
                              $(".datetimeshortcuts").remove();
                              DateTimeShortcuts.init();
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 50 mins to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 217..223

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

              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

                      const reinitDateTimeShortCuts = function() {
                          // Reinitialize the calendar and clock widgets by force
                          if (typeof DateTimeShortcuts !== "undefined") {
                              $(".datetimeshortcuts").remove();
                              DateTimeShortcuts.init();
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 50 mins to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 281..287

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

              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

                          } else {
                              // Otherwise, just insert the remove button as the
                              // last child element of the form's container:
                              row.children(":first").append('<span><a class="' + options.deleteCssClass + '" href="#">' + options.deleteText + "</a></span>");
                          }
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 40 mins to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 104..108

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

              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 (row.is("tr")) {
                              // If the forms are laid out in table rows, insert
                              // the remove button into the last table cell:
                              row.children(":last").append('<div><a class="' + options.deleteCssClass + '" href="#">' + options.deleteText + "</a></div>");
                          } else if (row.is("ul") || row.is("ol")) {
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 40 mins to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 112..116

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

              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

                              const field = $(this),
                                  input = field.find('input, select, textarea'),
                                  dependency_list = input.data('dependency_list') || [],
                                  dependencies = [];
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 40 mins to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 240..243

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

              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

                              const field = $(this),
                                  input = field.find('input, select, textarea'),
                                  dependency_list = input.data('dependency_list') || [],
                                  dependencies = [];
              Severity: Minor
              Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 40 mins to fix
              django/contrib/admin/static/admin/js/inlines.js on lines 303..306

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

              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

              There are no issues that match your filters.

              Category
              Status