knsv/mermaid

View on GitHub
packages/mermaid/src/dagre-wrapper/edges.js

Summary

Maintainability
F
6 days
Test Coverage

File edges.js has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { log } from '../logger.js';
import createLabel from './createLabel.js';
import { createText } from '../rendering-util/createText.js';
import { line, curveBasis, select } from 'd3';
import { getConfig } from '../diagram-api/diagramAPI.js';
Severity: Minor
Found in packages/mermaid/src/dagre-wrapper/edges.js - About 4 hrs to fix

    Function insertEdgeLabel has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const insertEdgeLabel = (elem, edge) => {
      const useHtmlLabels = evaluate(getConfig().flowchart.htmlLabels);
      // Create the actual text element
      const labelElement =
        edge.labelType === 'markdown'
    Severity: Major
    Found in packages/mermaid/src/dagre-wrapper/edges.js - About 3 hrs to fix

      Function positionEdgeLabel has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const positionEdgeLabel = (edge, paths) => {
        log.debug('Moving label abc88 ', edge.id, edge.label, edgeLabels[edge.id], paths);
        let path = paths.updatedPath ? paths.updatedPath : paths.originalPath;
        const siteConfig = getConfig();
        const { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig);
      Severity: Major
      Found in packages/mermaid/src/dagre-wrapper/edges.js - About 3 hrs to fix

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

        export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph, id) {
          let points = edge.points;
          log.debug('abc88 InsertEdge: edge=', edge, 'e=', e);
          let pointsHasChanged = false;
          const tail = graph.node(e.v);
        Severity: Major
        Found in packages/mermaid/src/dagre-wrapper/edges.js - About 3 hrs to fix

          Function intersection has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const intersection = (node, outsidePoint, insidePoint) => {
            log.debug(`intersection calc abc89:
            outsidePoint: ${JSON.stringify(outsidePoint)}
            insidePoint : ${JSON.stringify(insidePoint)}
            node        : x:${node.x} y:${node.y} w:${node.width} h:${node.height}`);
          Severity: Major
          Found in packages/mermaid/src/dagre-wrapper/edges.js - About 2 hrs to fix

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

            export const insertEdge = function (elem, e, edge, clusterDb, diagramType, graph, id) {
            Severity: Major
            Found in packages/mermaid/src/dagre-wrapper/edges.js - About 50 mins to fix

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

                if (edge.endLabelRight) {
                  // Create the actual text element
                  const endLabelElement = createLabel(edge.endLabelRight, edge.labelStyle);
                  const endEdgeLabelRight = elem.insert('g').attr('class', 'edgeTerminals');
                  const inner = endEdgeLabelRight.insert('g').attr('class', 'inner');
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 1 other location - About 1 day to fix
              packages/mermaid/src/dagre-wrapper/edges.js on lines 88..104

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

              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 (edge.endLabelLeft) {
                  // Create the actual text element
                  const endLabelElement = createLabel(edge.endLabelLeft, edge.labelStyle);
                  const endEdgeLabelLeft = elem.insert('g').attr('class', 'edgeTerminals');
                  const inner = endEdgeLabelLeft.insert('g').attr('class', 'inner');
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 1 other location - About 1 day to fix
              packages/mermaid/src/dagre-wrapper/edges.js on lines 105..121

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

              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

                if (edge.startLabelRight) {
                  const el = terminalLabels[edge.id].startRight;
                  let x = edge.x;
                  let y = edge.y;
                  if (path) {
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 2 other locations - About 5 hrs to fix
              packages/mermaid/src/dagre-wrapper/edges.js on lines 196..207
              packages/mermaid/src/dagre-wrapper/edges.js on lines 208..219

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

              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

                if (edge.endLabelLeft) {
                  const el = terminalLabels[edge.id].endLeft;
                  let x = edge.x;
                  let y = edge.y;
                  if (path) {
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 2 other locations - About 5 hrs to fix
              packages/mermaid/src/dagre-wrapper/edges.js on lines 180..195
              packages/mermaid/src/dagre-wrapper/edges.js on lines 208..219

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

              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

                if (edge.endLabelRight) {
                  const el = terminalLabels[edge.id].endRight;
                  let x = edge.x;
                  let y = edge.y;
                  if (path) {
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 2 other locations - About 5 hrs to fix
              packages/mermaid/src/dagre-wrapper/edges.js on lines 180..195
              packages/mermaid/src/dagre-wrapper/edges.js on lines 196..207

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

              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 (getConfig().flowchart.arrowMarkerAbsolute || getConfig().state.arrowMarkerAbsolute) {
                  url =
                    window.location.protocol +
                    '//' +
                    window.location.host +
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 4 other locations - About 2 hrs to fix
              packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js on lines 577..586
              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

              There are no issues that match your filters.

              Category
              Status