knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/flowchart/flowDb.js

Summary

Maintainability
F
4 days
Test Coverage

File flowDb.js has 618 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { select } from 'd3';
import utils from '../../utils.js';
import { getConfig, defaultConfig } from '../../diagram-api/diagramAPI.js';
import common from '../common/common.js';
import { log } from '../../logger.js';
Severity: Major
Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 1 day to fix

    Function addVertex has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const addVertex = function (_id, textObj, type, style, classes, dir, props = {}) {
      let txt;
      let id = _id;
      if (id === undefined) {
        return;
    Severity: Major
    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 2 hrs to fix

      Function addSubGraph has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const addSubGraph = function (_id, list, _title) {
        let id = _id.text.trim();
        let title = _title.text;
        if (_id === _title && _title.text.match(/\s/)) {
          id = undefined;
      Severity: Major
      Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 2 hrs to fix

        Function destructEndLink has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const destructEndLink = (_str) => {
          const str = _str.trim();
          let line = str.slice(0, -1);
          let type = 'arrow_open';
        
        
        Severity: Minor
        Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 1 hr to fix

          Function setClickFun has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const setClickFun = function (id, functionName, functionArgs) {
            let domId = lookUpDomId(id);
            // if (_id[0].match(/\d/)) id = MERMAID_DOM_ID_PREFIX + id;
            if (getConfig().securityLevel !== 'loose') {
              return;
          Severity: Minor
          Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 1 hr to fix

            Function indexNodes2 has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const indexNodes2 = function (id, pos) {
              const nodes = subGraphs[pos].nodes;
              secCount = secCount + 1;
              if (secCount > 2000) {
                return;
            Severity: Minor
            Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 1 hr to fix

              Function addSingleLink has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const addSingleLink = function (_start, _end, type) {
                let start = _start;
                let end = _end;
                // if (start[0].match(/\d/)) start = MERMAID_DOM_ID_PREFIX + start;
                // if (end[0].match(/\d/)) end = MERMAID_DOM_ID_PREFIX + end;
              Severity: Minor
              Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 1 hr to fix

                Function setupToolTips has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const setupToolTips = function (element) {
                  let tooltipElem = select('.mermaidTooltip');
                  if ((tooltipElem._groups || tooltipElem)[0][0] === null) {
                    tooltipElem = select('body').append('div').attr('class', 'mermaidTooltip').style('opacity', 0);
                  }
                Severity: Minor
                Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 1 hr to fix

                  Function addVertex has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  export const addVertex = function (_id, textObj, type, style, classes, dir, props = {}) {
                  Severity: Major
                  Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 50 mins to fix

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

                      if (typeof functionArgs === 'string') {
                        /* Splits functionArgs by ',', ignoring all ',' in double quoted strings */
                        argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
                        for (let i = 0; i < argList.length; i++) {
                          let item = argList[i].trim();
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js and 1 other location - About 6 hrs to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 661..673

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

                    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

                    export const setClickEvent = function (ids, functionName, functionArgs) {
                      ids.split(',').forEach(function (id) {
                        setClickFun(id, functionName, functionArgs);
                      });
                      setClass(ids, 'clickable');
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js and 1 other location - About 1 hr to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 725..730

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

                    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 (classes !== undefined && classes !== null) {
                        classes.forEach(function (s) {
                          vertices[id].classes.push(s);
                        });
                      }
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js and 1 other location - About 1 hr to fix
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 103..107

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

                    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 (style !== undefined && style !== null) {
                        style.forEach(function (s) {
                          vertices[id].styles.push(s);
                        });
                      }
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js and 1 other location - About 1 hr to fix
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 108..112

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

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

                        case 'o':
                          type = 'arrow_circle';
                          if (str[0] === 'o') {
                            type = 'double_' + type;
                            line = line.slice(1);
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js and 2 other locations - About 55 mins to fix
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 682..688
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 689..695

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

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

                        case '>':
                          type = 'arrow_point';
                          if (str[0] === '<') {
                            type = 'double_' + type;
                            line = line.slice(1);
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js and 2 other locations - About 55 mins to fix
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 682..688
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 696..702

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

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

                        case 'x':
                          type = 'arrow_cross';
                          if (str[0] === 'x') {
                            type = 'double_' + type;
                            line = line.slice(1);
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/flowchart/flowDb.js and 2 other locations - About 55 mins to fix
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 689..695
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 696..702

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

                    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