knsv/mermaid

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

Summary

Maintainability
F
6 days
Test Coverage

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

export const draw = async function (text, id, _version, diagObj) {
  log.info('Drawing flowchart');
  const { securityLevel, flowchart: conf } = getConfig();
  let sandboxElement;
  if (securityLevel === 'sandbox') {
Severity: Major
Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js - About 6 hrs to fix

    File flowRenderer.js has 390 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 { render as Render } from 'dagre-d3-es';
    import { applyStyle } from 'dagre-d3-es/src/dagre-js/util.js';
    Severity: Minor
    Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js - About 5 hrs to fix

      Function addVertices has 106 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}"]`) : root.select(`[id="${svgId}"]`);
        const doc = !_doc ? document : _doc;
        const keys = Object.keys(vert);
      
      
      Severity: Major
      Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js - About 4 hrs to fix

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

        export const addEdges = async function (edges, g, diagObj) {
          let cnt = 0;
        
          let defaultStyle;
          let defaultLabelStyle;
        Severity: Major
        Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js - About 3 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.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.js and 1 other location - About 1 day to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 472..500

            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

            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: await renderKatex(
                      vertexText.replace(
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js and 1 other location - About 6 hrs to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 59..81

            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 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.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-v2.js on lines 301..307

            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

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

                const marker = parent
                  .append('marker')
                  .attr('id', id)
                  .attr('viewBox', '0 0 10 10')
                  .attr('refX', 9)
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js and 1 other location - About 2 hrs to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 387..396

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

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                const marker = parent
                  .append('marker')
                  .attr('id', id)
                  .attr('viewBox', '0 0 10 10')
                  .attr('refX', 9)
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js and 1 other location - About 2 hrs to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 370..379

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

            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.js and 1 other location - About 2 hrs to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 379..392

            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

            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.js and 1 other location - About 1 hr to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 13..18

            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.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-v2.js on lines 292..296

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

                  const clusterEl = doc.querySelectorAll(
                    '#' + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"]'
                  );
            Severity: Minor
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js and 1 other location - About 35 mins to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 424..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 47.

            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 clusterRects = doc.querySelectorAll(
                    '#' + id + ' [id="' + diagObj.db.lookUpDomId(subG.id) + '"] rect'
                  );
            Severity: Minor
            Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js and 1 other location - About 35 mins to fix
            packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 427..429

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

            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