knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js

Summary

Maintainability
F
1 wk
Test Coverage

Function addVertices has 135 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const addVertices = async function (vert, g, svgId, root, doc, diagObj) {
  const svg = root.select(`[id="${svgId}"]`);
  const keys = Object.keys(vert);

  // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition
Severity: Major
Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js - About 5 hrs to fix

    File flowRenderer-v2.js has 391 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';
    import { select, curveLinear, selectAll } from 'd3';
    import { getConfig } from '../../diagram-api/diagramAPI.js';
    import utils from '../../utils.js';
    import { render } from '../../dagre-wrapper/index.js';
    Severity: Minor
    Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js - About 5 hrs to fix

      Function addEdges has 112 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const addEdges = async function (edges, g, diagObj) {
        log.info('abc78 edges = ', edges);
        let cnt = 0;
        let linkIdCnt = {};
      
      
      Severity: Major
      Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js - About 4 hrs to fix

        Function draw has 111 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const draw = async function (text, id, _version, diagObj) {
          log.info('Drawing flowchart');
        
          // Fetch the default direction, use TD if none was found
          let dir = diagObj.db.getDirection();
        Severity: Major
        Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js - About 4 hrs to fix

          Function addVertices has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          export const addVertices = async function (vert, g, svgId, root, doc, diagObj) {
          Severity: Minor
          Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js - About 45 mins to fix

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

                  if (node) {
                    const link = doc.createElementNS('http://www.w3.org/2000/svg', 'a');
                    link.setAttributeNS('http://www.w3.org/2000/svg', 'class', vertex.classes.join(' '));
                    link.setAttributeNS('http://www.w3.org/2000/svg', 'href', vertex.link);
                    link.setAttributeNS('http://www.w3.org/2000/svg', 'rel', 'noopener');
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 1 day to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 471..499

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

            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

                g.setNode(vertex.id, {
                  labelStyle: styles.labelStyle,
                  shape: _shape,
                  labelText,
                  labelType: vertex.labelType,
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 1 day to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 161..181

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

            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

                  if (evaluate(getConfig().flowchart.htmlLabels)) {
                    // TODO: addHtmlLabel accepts a labelStyle. Do we possibly have that?
                    const node = {
                      label: vertexText,
                    };
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 6 hrs to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 57..85

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

            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

                switch (edge.type) {
                  case 'double_arrow_cross':
                    edgeData.arrowTypeStart = 'arrow_cross';
                  case 'arrow_cross':
                    edgeData.arrowTypeEnd = 'arrow_cross';
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 3 hrs to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 448..464

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

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

                if (edge.interpolate !== undefined) {
                  edgeData.curve = interpolateToCurve(edge.interpolate, curveLinear);
                } else if (edges.defaultInterpolate !== undefined) {
                  edgeData.curve = interpolateToCurve(edges.defaultInterpolate, curveLinear);
                } else {
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 2 other locations - About 3 hrs to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 501..507
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 225..231

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

            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 g = new graphlib.Graph({
                multigraph: true,
                compound: true,
              })
                .setGraph({
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 2 hrs to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 315..328

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

            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

                if (linkIdCnt[linkIdBase] === undefined) {
                  linkIdCnt[linkIdBase] = 0;
                  log.info('abc78 new entry', linkIdBase, linkIdCnt[linkIdBase]);
                } else {
                  linkIdCnt[linkIdBase]++;
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 2 hrs to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 420..426

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

            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

                  case 'normal':
                    style = 'fill:none;';
                    if (defaultStyle !== undefined) {
                      style = defaultStyle;
                    }
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 1 hr to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 470..480

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

            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

                if (edge.text === undefined) {
                  if (edge.style !== undefined) {
                    edgeData.arrowheadStyle = 'fill: #333';
                  }
                } else {
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 1 hr to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 509..516

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

            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

            export const setConf = function (cnf) {
              const keys = Object.keys(cnf);
              for (const key of keys) {
                conf[key] = cnf[key];
              }
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 1 hr to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 14..19

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

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

              if (edges.defaultStyle !== undefined) {
                const defaultStyles = getStylesFromArray(edges.defaultStyle);
                defaultStyle = defaultStyles.style;
                defaultLabelStyle = defaultStyles.labelStyle;
              }
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 4 other locations - About 50 mins to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 410..414
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 492..496
            packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 292..296
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 172..176

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

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

                if (edge.style !== undefined) {
                  const styles = getStylesFromArray(edge.style);
                  style = styles.style;
                  labelStyle = styles.labelStyle;
                }
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 4 other locations - About 50 mins to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 410..414
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 492..496
            packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 203..207
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 172..176

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

            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

                diagObj.db.addVertex(
                  subG.id,
                  { text: subG.title, type: subG.labelType },
                  'group',
                  undefined,
            Severity: Minor
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 50 mins to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 779..786

            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

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

                if (edge.type === 'arrow_open') {
                  edgeData.arrowhead = 'none';
                } else {
                  edgeData.arrowhead = 'normal';
                }
            Severity: Minor
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 35 mins to fix
            packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 437..441

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

            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