Shoobx/OrgChart.js

View on GitHub

Showing 67 of 67 total issues

File orgchart.js has 1620 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export default class OrgChart {
  constructor(options) {
    this._name = 'OrgChart';
    Promise.prototype.finally = function (callback) {
      let P = this.constructor;
Severity: Major
Found in src/orgchart.js - About 4 days to fix

    OrgChart has 66 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class OrgChart {
      constructor(options) {
        this._name = 'OrgChart';
        Promise.prototype.finally = function (callback) {
          let P = this.constructor;
    Severity: Major
    Found in src/orgchart.js - About 1 day to fix

      Function _clickHorizontalEdge has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

        _clickHorizontalEdge(event) {
          event.stopPropagation();
          let that = this,
            opts = this.options,
            hEdge = event.target,
      Severity: Minor
      Found in src/orgchart.js - About 5 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

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

          if (!event.targetTouches) { // pan on desktop
            startX = event.pageX - lastX;
            startY = event.pageY - lastY;
          } else if (event.targetTouches.length === 1) { // pan on mobile device
            startX = event.targetTouches[0].pageX - lastX;
      Severity: Major
      Found in src/orgchart.js and 1 other location - About 4 hrs to fix
      src/orgchart.js on lines 1780..1788

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

      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 (!event.targetTouches) { // pand on desktop
            newX = event.pageX - startX;
            newY = event.pageY - startY;
          } else if (event.targetTouches.length === 1) { // pan on mobile device
            newX = event.targetTouches[0].pageX - startX;
      Severity: Major
      Found in src/orgchart.js and 1 other location - About 4 hrs to fix
      src/orgchart.js on lines 1755..1763

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

      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 _createNode has 119 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _createNode(nodeData, level) {
          let that = this,
            opts = this.options;
      
          return new Promise(function (resolve, reject) {
      Severity: Major
      Found in src/orgchart.js - About 4 hrs to fix

        Function buildHierarchy has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

          buildHierarchy(appendTo, nodeData, level, callback) {
            // Construct the node
            let that = this,
              opts = this.options,
              nodeWrapper,
        Severity: Minor
        Found in src/orgchart.js - About 4 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

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

            if (!direction || (direction && direction !== 'left')) {
              let nextSibs = this._nextAll(nodeContainer);
        
              nextSibs.forEach((sib) => {
                Array.from(sib.querySelectorAll('.node')).forEach((node) => {
        Severity: Major
        Found in src/orgchart.js and 1 other location - About 4 hrs to fix
        src/orgchart.js on lines 502..512

        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

            if (!direction || (direction && direction === 'left')) {
              let preSibs = this._prevAll(nodeContainer);
        
              preSibs.forEach((sib) => {
                Array.from(sib.querySelectorAll('.node')).forEach((node) => {
        Severity: Major
        Found in src/orgchart.js and 1 other location - About 4 hrs to fix
        src/orgchart.js on lines 513..523

        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

        Function buildHierarchy has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          buildHierarchy(appendTo, nodeData, level, callback) {
            // Construct the node
            let that = this,
              opts = this.options,
              nodeWrapper,
        Severity: Major
        Found in src/orgchart.js - About 3 hrs to fix

          Function constructor has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(options) {
              this._name = 'OrgChart';
              Promise.prototype.finally = function (callback) {
                let P = this.constructor;
          
          
          Severity: Major
          Found in src/orgchart.js - About 3 hrs to fix

            Function _onDrop has 92 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _onDrop(event) {
                let dropZone = event.currentTarget,
                  chart = this.chart,
                  dragged = this.dragged,
                  dragZone = this._closest(dragged, function (el) {
            Severity: Major
            Found in src/orgchart.js - About 3 hrs to fix

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

                _removeClass(elements, classNames) {
                  elements.forEach((el) => {
                    if (classNames.indexOf(' ') > 0) {
                      classNames.split(' ').forEach((className) => el.classList.remove(className));
                    } else {
              Severity: Major
              Found in src/orgchart.js and 1 other location - About 3 hrs to fix
              src/orgchart.js on lines 179..187

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

              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

                _addClass(elements, classNames) {
                  elements.forEach((el) => {
                    if (classNames.indexOf(' ') > 0) {
                      classNames.split(' ').forEach((className) => el.classList.add(className));
                    } else {
              Severity: Major
              Found in src/orgchart.js and 1 other location - About 3 hrs to fix
              src/orgchart.js on lines 188..196

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

              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 hideSiblings has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                hideSiblings(node, direction) {
                  let nodeContainer = this._closest(node, (el) => el.nodeName === 'TABLE').parentNode,
                    siblings = this._siblings(nodeContainer);
              
                  siblings.forEach((sib) => {
              Severity: Major
              Found in src/orgchart.js - About 3 hrs to fix

                Function _onDragStart has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _onDragStart(event) {
                    let nodeDiv = event.target,
                      opts = this.options,
                      isFirefox = /firefox/.test(window.navigator.userAgent.toLowerCase());
                
                
                Severity: Major
                Found in src/orgchart.js - About 2 hrs to fix

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

                        if (!node.querySelector('.leftEdge')) {
                          let rightEdge = document.createElement('i'),
                            leftEdge = document.createElement('i');
                  
                          rightEdge.setAttribute('class', 'edge horizontalEdge rightEdge fa');
                  Severity: Major
                  Found in src/orgchart.js and 1 other location - About 2 hrs to fix
                  src/orgchart.js on lines 1316..1324

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

                  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 (!dragged.querySelector('.horizontalEdge')) {
                          let rightEdge = document.createElement('i'),
                            leftEdge = document.createElement('i');
                  
                          rightEdge.setAttribute('class', 'edge horizontalEdge rightEdge fa');
                  Severity: Major
                  Found in src/orgchart.js and 1 other location - About 2 hrs to fix
                  src/orgchart.js on lines 1022..1030

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

                  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 (prevSib) {
                          if (prevSib.classList.contains('hidden')) {
                            leftEdge.classList.add('fa-chevron-left');
                            leftEdge.classList.remove('fa-chevron-right');
                          } else {
                  Severity: Major
                  Found in src/orgchart.js and 1 other location - About 2 hrs to fix
                  src/orgchart.js on lines 349..357

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

                  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 (nextSib) {
                          if (nextSib.classList.contains('hidden')) {
                            rightEdge.classList.add('fa-chevron-right');
                            rightEdge.classList.remove('fa-chevron-left');
                          } else {
                  Severity: Major
                  Found in src/orgchart.js and 1 other location - About 2 hrs to fix
                  src/orgchart.js on lines 340..348

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language