knsv/mermaid

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

Summary

Maintainability
F
1 wk
Test Coverage

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

import { select, line, curveLinear } from 'd3';
import { insertNode } from '../../../dagre-wrapper/nodes.js';
import insertMarkers from '../../../dagre-wrapper/markers.js';
import { insertEdgeLabel } from '../../../dagre-wrapper/edges.js';
import { findCommonAncestor } from './render-utils.js';
Severity: Major
Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 1 day to fix

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

    export const addVertices = async function (vert, svgId, root, doc, diagObj, parentLookupDb, graph) {
      const svg = root.select(`[id="${svgId}"]`);
      const nodes = svg.insert('g').attr('class', 'nodes');
      const keys = Object.keys(vert);
    
    
    Severity: Major
    Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 6 hrs to fix

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

      export const addEdges = function (edges, diagObj, graph, svg) {
        log.info('abc78 edges = ', edges);
        const labelsEl = svg.insert('g').attr('class', 'edgeLabels');
        let linkIdCnt = {};
        let dir = diagObj.db.getDirection();
      Severity: Major
      Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 5 hrs to fix

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

        export const draw = async function (text, id, _version, diagObj) {
          // Add temporary render element
          diagObj.db.clear();
          nodeDb = {};
          portPos = {};
        Severity: Major
        Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 4 hrs to fix

          Function getNextPort has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const getNextPort = (node, edgeDirection, graphDirection) => {
            log.info('getNextPort', { node, edgeDirection, graphDirection });
            if (!portPos[node]) {
              switch (graphDirection) {
                case 'TB':
          Severity: Minor
          Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 1 hr to fix

            Function drawNodes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, diagObj, depth) => {
              nodeArray.forEach(function (node) {
                if (node) {
                  nodeDb[node.id].offset = {
                    posX: node.x + relX,
            Severity: Minor
            Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 1 hr to fix

              Function getNextPosition has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const getNextPosition = (position, edgeDirection, graphDirection) => {
                const portPos = {
                  TB: {
                    in: {
                      north: 'north',
              Severity: Minor
              Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 1 hr to fix

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

                const insertEdge = function (edgesEl, edge, edgeData, diagObj, parentLookupDb, id) {
                  const offset = calcOffset(edge.sourceId, edge.targetId, parentLookupDb);
                
                  const src = edge.sections[0].startPoint;
                  const dest = edge.sections[0].endPoint;
                Severity: Minor
                Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 1 hr to fix

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

                  export const addVertices = async function (vert, svgId, root, doc, diagObj, parentLookupDb, graph) {
                  Severity: Major
                  Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 50 mins to fix

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

                    const insertEdge = function (edgesEl, edge, edgeData, diagObj, parentLookupDb, id) {
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 45 mins to fix

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

                      const addMarkersToEdge = function (svgPath, edgeData, diagramType, arrowMarkerAbsolute, id) {
                      Severity: Minor
                      Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 35 mins to fix

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

                              const node = {
                                labelStyle: styles.labelStyle,
                                shape: _shape,
                                labelText: vertexText,
                                labelType: vertex.labelType,
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 146..166

                        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

                            switch (edge.type) {
                              case 'double_arrow_cross':
                                edgeData.arrowTypeStart = 'arrow_cross';
                              case 'arrow_cross':
                                edgeData.arrowTypeEnd = 'arrow_cross';
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 243..259

                        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 {
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 301..307
                        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

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

                          if (arrowMarkerAbsolute) {
                            url =
                              window.location.protocol +
                              '//' +
                              window.location.host +
                        packages/mermaid/src/dagre-wrapper/edges.js on lines 436..445
                        packages/mermaid/src/diagrams/class/svgDraw.js on lines 44..53
                        packages/mermaid/src/diagrams/er/erRenderer.js on lines 453..462
                        packages/mermaid/src/diagrams/state/shapes.js on lines 449..458

                        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

                        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]++;
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 215..221

                        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;
                                }
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 265..275

                        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 {
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 309..316

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

                          if (edges.defaultStyle !== undefined) {
                            const defaultStyles = getStylesFromArray(edges.defaultStyle);
                            defaultStyle = defaultStyles.style;
                            defaultLabelStyle = defaultStyles.labelStyle;
                          }
                        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
                        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;
                            }
                        packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 410..414
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 203..207
                        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

                        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/elk/flowRenderer-elk.js and 1 other location - About 50 mins to fix
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 400..407

                        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/elk/flowRenderer-elk.js and 1 other location - About 35 mins to fix
                        packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 232..236

                        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