divio/django-cms

View on GitHub
cms/static/cms/js/libs/jstree/jstree.grid.min.js

Summary

Maintainability
F
1 wk
Test Coverage

Function grid has 553 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    $.jstree.plugins.grid = function(options,parent) {
        this._initialize = function () {
            if (!this._initialized) {
                var s = this.settings.grid || {}, styles,    container = this.element, gridparent = container.parent(), i,
                gs = this._gridSettings = {
Severity: Major
Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 2 days to fix

    File jstree.grid.min.js has 626 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * https://github.com/deitch/jstree-grid
     *
     * This plugin handles adding a grid to a tree to display additional data
     *
    Severity: Major
    Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 1 day to fix

      Function _prepare_grid has 150 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              this._prepare_grid = function (obj) {
                  var gs = this._gridSettings, c = gs.treeClass, _this = this, t, cols = gs.columns || [], width, tr = gs.isThemeroller,
                  tree = this.element, rootid = this.rootid,
                  classAdd = (tr?"themeroller":"regular"), img, objData = this.get_node(obj),
                  defaultWidth = gs.columnWidth, conf = gs.defaultConf, cellClickHandler = function (tree,node,val,col,t) {
      Severity: Major
      Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 6 hrs to fix

        Function _prepare_headers has 109 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                this._prepare_headers = function() {
                    var header, i, col, gs = this._gridSettings,cols = gs.columns || [], width, defaultWidth = gs.columnWidth, resizable = gs.resizable || false,
                    cl, ccl, val, margin, last, tr = gs.isThemeroller, classAdd = (tr?"themeroller":"regular"), puller,
                    hasHeaders = false, gridparent = this.gridparent,
                    conf = gs.defaultConf,
        Severity: Major
        Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 4 hrs to fix

          Function bind has 102 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  this.bind = function () {
                      parent.bind.call(this);
                      this._initialize();
                      this.element
                      .on("move_node.jstree create_node.jstree clean_node.jstree change_node.jstree", $.proxy(function (e, data) {
          Severity: Major
          Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 4 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                        if (a.length === 1) {
                            closed = !objData.state.opened;
                            gridCellName = GRIDCELLID_PREFIX+escapeId(lid)+GRIDCELLID_POSTFIX;
                            gridCellParentId = objData.parent === "#" ? null : objData.parent;
                            a.addClass(c);
            Severity: Critical
            Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 3 hrs to fix

              Function _edit has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      this._edit = function (obj, col, element) {
                          if(!obj) { return false; }
                          if (element) {
                              element = $(element);
                              if (element.prop("tagName").toLowerCase() === "div") {
              Severity: Major
              Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 2 hrs to fix

                Function _initialize has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        this._initialize = function () {
                            if (!this._initialized) {
                                var s = this.settings.grid || {}, styles,    container = this.element, gridparent = container.parent(), i,
                                gs = this._gridSettings = {
                                    columns : s.columns || [],
                Severity: Major
                Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 2 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                                              if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) {
                                                  event.stopImmediatePropagation();
                                              }
                  Severity: Major
                  Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if (gridCellPrev && gridCellPrev.length > 0) {
                                                    last.insertAfter(gridCellPrev);
                                                } else if (gridCellChild && gridCellChild.length > 0) {
                                                    last.insertBefore(gridCellChild);
                                                } else if (gridCellNext && gridCellNext.length > 0) {
                    Severity: Major
                    Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 45 mins to fix

                      Function cellClickHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                                  defaultWidth = gs.columnWidth, conf = gs.defaultConf, cellClickHandler = function (tree,node,val,col,t) {
                      Severity: Minor
                      Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 35 mins to fix

                        Function cellRightClickHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                    }, cellRightClickHandler = function (tree,node,val,col,t) {
                        Severity: Minor
                        Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js - About 35 mins to fix

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

                                                  if (gridCellParent && gridCellParent.length > 0) {
                                                      if (gridCellPrev && gridCellPrev.length > 0) {
                                                          last.insertAfter(gridCellPrev);
                                                      } else if (gridCellChild && gridCellChild.length > 0) {
                                                          last.insertBefore(gridCellChild);
                          Severity: Major
                          Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js and 1 other location - About 4 hrs to fix
                          cms/static/cms/js/libs/jstree/jstree.grid.min.js on lines 785..796

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

                          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 {
                                                  if (gridCellPrev && gridCellPrev.length > 0) {
                                                      last.insertAfter(gridCellPrev);
                                                  } else if (gridCellChild && gridCellChild.length > 0) {
                                                      last.insertBefore(gridCellChild);
                          Severity: Major
                          Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js and 1 other location - About 4 hrs to fix
                          cms/static/cms/js/libs/jstree/jstree.grid.min.js on lines 769..780

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

                          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

                                              valClass = col.valueClass && objData.data !== null && objData.data !== undefined ? objData.data[col.valueClass] || "" : "";
                          Severity: Major
                          Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js and 1 other location - About 1 hr to fix
                          cms/static/cms/js/libs/jstree/jstree.grid.min.js on lines 711..711

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

                          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

                                              wideValClass = col.wideValueClass && objData.data !== null && objData.data !== undefined ? objData.data[col.wideValueClass] || "" : "";
                          Severity: Major
                          Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js and 1 other location - About 1 hr to fix
                          cms/static/cms/js/libs/jstree/jstree.grid.min.js on lines 706..706

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

                          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 4 locations. Consider refactoring.
                          Open

                                          this.element
                                              .on("select_node.jstree",$.proxy(function(e,data){
                                                  data.rslt.obj.children("a").nextAll("div").addClass("ui-state-active");
                                              },this))
                          Severity: Major
                          Found in cms/static/cms/js/libs/jstree/jstree.grid.min.js and 3 other locations - About 55 mins to fix
                          cms/static/cms/js/libs/jstree/jstree.grid.min.js on lines 317..323
                          cms/static/cms/js/libs/jstree/jstree.grid.min.js on lines 317..326
                          cms/static/cms/js/libs/jstree/jstree.grid.min.js on lines 317..329

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

                          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